target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testConvertOCMustMany() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCMustMany, ou=\n" + " schema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-must: attr1\n" + "m-must: attr2\n" + "m-must: attr3\n\n"; assertEquals( expected, transform( "testOCMustMany" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCNameOne() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCNameOne, ou=s\n" + " chema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: objectClass\n\n"; assertEquals( expected, transform( "testOCNameOne" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCName2() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCName2, ou=sch\n" + " ema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: oc\n" + "m-name: objectClass\n\n"; assertEquals( expected, transform( "testOCName2" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCNameMany() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCNameMany, ou=\n" + " schema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: oc\n" + "m-name: objectClass\n" + "m-name: object\n\n"; assertEquals( expected, transform( "testOCNameMany" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCObsolete() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCObsolete, ou=\n" + " schema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-obsolete: TRUE\n\n"; assertEquals( expected, transform( "testOCObsolete" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCSupOne() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCSupOne, ou=sc\n" + " hema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-supObjectClass: top\n\n"; assertEquals( expected, transform( "testOCSupOne" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCSup2() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCSup2, ou=sche\n" + " ma\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-supObjectClass: top\n" + "m-supObjectClass: 1.3.6.1.4.1.18060.0.4.2.3.15\n\n"; assertEquals( expected, transform( "testOCSup2" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertOCSupMany() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=objectclasses, cn=testOCSupMany, ou=s\n" + " chema\n" + "objectclass: metaObjectClass\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-supObjectClass: top\n" + "m-supObjectClass: 1.3.6.1.4.1.18060.0.4.2.3.15\n" + "m-supObjectClass: metaTop\n\n"; assertEquals( expected, transform( "testOCSupMany" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testDecodeHexString() throws Exception { try { assertEquals( "", Hex.decodeHexString( "" ) ); fail( "should not get here" ); } catch ( NamingException e ) { } assertEquals( "", Hex.decodeHexString( "#" ) ); assertEquals( "F", Hex.decodeHexString( "#46" ) ); try { assertEquals( "F", Hex.decodeHexString( "46" ) ); fail( "should not get here" ); } catch ( NamingException e ) { } assertEquals( "Ferry", Hex.decodeHexString( "#4665727279" ) ); } | public static String decodeHexString( String str ) throws InvalidNameException { if ( str == null || str.length() == 0 ) { throw new InvalidNameException( I18n.err( I18n.ERR_17037_MUST_START_WITH_SHARP ) ); } char[] chars = str.toCharArray(); if ( chars[0] != '#' ) { throw new InvalidNameException( I18n.err( I18n.ERR_17038_MUST_START_WITH_ESC_SHARP, str ) ); } byte[] decoded = new byte[( chars.length - 1 ) >> 1]; for ( int ii = 1, jj = 0; ii < chars.length; ii += 2, jj++ ) { int ch = ( HEX_VALUE[chars[ii]] << 4 ) + ( HEX_VALUE[chars[ii + 1]] & 0xff ); decoded[jj] = ( byte ) ch; } return Strings.utf8ToString( decoded ); } | Hex { public static String decodeHexString( String str ) throws InvalidNameException { if ( str == null || str.length() == 0 ) { throw new InvalidNameException( I18n.err( I18n.ERR_17037_MUST_START_WITH_SHARP ) ); } char[] chars = str.toCharArray(); if ( chars[0] != '#' ) { throw new InvalidNameException( I18n.err( I18n.ERR_17038_MUST_START_WITH_ESC_SHARP, str ) ); } byte[] decoded = new byte[( chars.length - 1 ) >> 1]; for ( int ii = 1, jj = 0; ii < chars.length; ii += 2, jj++ ) { int ch = ( HEX_VALUE[chars[ii]] << 4 ) + ( HEX_VALUE[chars[ii + 1]] & 0xff ); decoded[jj] = ( byte ) ch; } return Strings.utf8ToString( decoded ); } } | Hex { public static String decodeHexString( String str ) throws InvalidNameException { if ( str == null || str.length() == 0 ) { throw new InvalidNameException( I18n.err( I18n.ERR_17037_MUST_START_WITH_SHARP ) ); } char[] chars = str.toCharArray(); if ( chars[0] != '#' ) { throw new InvalidNameException( I18n.err( I18n.ERR_17038_MUST_START_WITH_ESC_SHARP, str ) ); } byte[] decoded = new byte[( chars.length - 1 ) >> 1]; for ( int ii = 1, jj = 0; ii < chars.length; ii += 2, jj++ ) { int ch = ( HEX_VALUE[chars[ii]] << 4 ) + ( HEX_VALUE[chars[ii + 1]] & 0xff ); decoded[jj] = ( byte ) ch; } return Strings.utf8ToString( decoded ); } private Hex(); } | Hex { public static String decodeHexString( String str ) throws InvalidNameException { if ( str == null || str.length() == 0 ) { throw new InvalidNameException( I18n.err( I18n.ERR_17037_MUST_START_WITH_SHARP ) ); } char[] chars = str.toCharArray(); if ( chars[0] != '#' ) { throw new InvalidNameException( I18n.err( I18n.ERR_17038_MUST_START_WITH_ESC_SHARP, str ) ); } byte[] decoded = new byte[( chars.length - 1 ) >> 1]; for ( int ii = 1, jj = 0; ii < chars.length; ii += 2, jj++ ) { int ch = ( HEX_VALUE[chars[ii]] << 4 ) + ( HEX_VALUE[chars[ii + 1]] & 0xff ); decoded[jj] = ( byte ) ch; } return Strings.utf8ToString( decoded ); } private Hex(); static byte getHexValue( char high, char low ); static byte getHexValue( byte high, byte low ); static byte getHexValue( char c ); static String decodeHexString( String str ); static byte[] convertEscapedHex( String str ); static char[] encodeHex( byte[] data ); } | Hex { public static String decodeHexString( String str ) throws InvalidNameException { if ( str == null || str.length() == 0 ) { throw new InvalidNameException( I18n.err( I18n.ERR_17037_MUST_START_WITH_SHARP ) ); } char[] chars = str.toCharArray(); if ( chars[0] != '#' ) { throw new InvalidNameException( I18n.err( I18n.ERR_17038_MUST_START_WITH_ESC_SHARP, str ) ); } byte[] decoded = new byte[( chars.length - 1 ) >> 1]; for ( int ii = 1, jj = 0; ii < chars.length; ii += 2, jj++ ) { int ch = ( HEX_VALUE[chars[ii]] << 4 ) + ( HEX_VALUE[chars[ii + 1]] & 0xff ); decoded[jj] = ( byte ) ch; } return Strings.utf8ToString( decoded ); } private Hex(); static byte getHexValue( char high, char low ); static byte getHexValue( byte high, byte low ); static byte getHexValue( char c ); static String decodeHexString( String str ); static byte[] convertEscapedHex( String str ); static char[] encodeHex( byte[] data ); } |
@Test public void testConvertATMinimal() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATMinimal, ou=\n" + " schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n\n"; assertEquals( expected, transform( "testATMinimal" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATNoName() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATNoName, ou=s\n" + " chema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n\n"; assertEquals( expected, transform( "testATNoName" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATNameOne() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATNameOne, ou=\n" + " schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: attribute\n\n"; assertEquals( expected, transform( "testATNameOne" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATName2() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATName2, ou=sc\n" + " hema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: at\n" + "m-name: attribute\n\n"; assertEquals( expected, transform( "testATName2" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATNameMany() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATNameMany, ou\n" + " =schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-name: at\n" + "m-name: attribute\n" + "m-name: attribute2\n\n"; assertEquals( expected, transform( "testATNameMany" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATDesc() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATDesc, ou=sch\n" + " ema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-description: An attributeType\n\n"; assertEquals( expected, transform( "testATDesc" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATDesWithEscapedChars() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATDescWithEsca\n" + " ped, ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-description: Some 'escaped' chars\n\n"; assertEquals( expected, transform( "testATDescWithEscaped" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATObsolete() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATObsolete, ou\n" + " =schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-obsolete: TRUE\n\n"; assertEquals( expected, transform( "testATObsolete" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSup() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSup, ou=sche\n" + " ma\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-supAttributeType: anotherAttribute\n\n"; assertEquals( expected, transform( "testATSup" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSupOID() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSupOID, ou=s\n" + " chema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-supAttributeType: 1.3.6.1.4.1.18060.0.4.2.3.15\n\n"; assertEquals( expected, transform( "testATSupOID" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testAddNullDNNoElem() throws LdapException { DnNode<Dn> tree = new DnNode<Dn>(); assertThrows( LdapUnwillingToPerformException.class, () -> { tree.add( null ); } ); } | public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testConvertATEquality() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATEquality, ou\n" + " =schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-equality: booleanMatch\n\n"; assertEquals( expected, transform( "testATEquality" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATEqualityOID() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATEqualityOID,\n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-equality: 1.3.6.1.4.1.18060.0.4.2.3.15\n\n"; assertEquals( expected, transform( "testATEqualityOID" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATOrdering() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATOrdering, ou\n" + " =schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-ordering: booleanMatch\n\n"; assertEquals( expected, transform( "testATOrdering" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATOrderingOID() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATOrderingOID,\n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-ordering: 1.3.6.1.4.1.18060.0.4.2.3.15\n\n"; assertEquals( expected, transform( "testATOrderingOID" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSubstr() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSubstr, ou=s\n" + " chema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-substr: booleanMatch\n\n"; assertEquals( expected, transform( "testATSubstr" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSubstrOID() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSubstrOID, o\n" + " u=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-substr: 1.3.6.1.4.1.18060.0.4.2.3.15\n\n"; assertEquals( expected, transform( "testATSubstrOID" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSyntax() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSyntax, ou=s\n" + " chema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-syntax: 1.3.6.1.4.1.18060.0.4.2.3.15\n\n"; assertEquals( expected, transform( "testATSyntax" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSyntaxOidLen() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSyntaxOidLen\n" + " , ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-syntax: 1.3.6.1.4.1.18060.0.4.2.3.15\n" + "m-length: 123\n\n"; assertEquals( expected, transform( "testATSyntaxOidLen" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATSingleValue() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATSingleValue,\n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-singleValue: TRUE\n\n"; assertEquals( expected, transform( "testATSingleValue" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATCollective() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATCollective, \n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-collective: TRUE\n\n"; assertEquals( expected, transform( "testATCollective" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testAdd2EqualDNsNoElem() throws LdapException { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn1 = new Dn( "dc=b,dc=a" ); Dn dn2 = new Dn( "dc=b,dc=a" ); tree.add( dn1 ); assertThrows( LdapUnwillingToPerformException.class, () -> { tree.add( dn2 ); } ); } | public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testConvertATNoUserModification() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATNoUserModifi\n" + " cation, ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-noUserModification: TRUE\n\n"; assertEquals( expected, transform( "testATNoUserModification" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATUsageUserApp() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATUsageUserApp\n" + " , ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n\n"; assertEquals( expected, transform( "testATUsageUserApp" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATUsageDirOp() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATUsageDirOp, \n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-usage: DIRECTORY_OPERATION\n\n"; assertEquals( expected, transform( "testATUsageDirOp" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATUsageDistrOp() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATUsageDistrOp\n" + " , ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-usage: DISTRIBUTED_OPERATION\n\n"; assertEquals( expected, transform( "testATUsageDistrOp" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertATUsageDSAOp() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.18060.0.4.2.3.14, ou=attributetypes, cn=testATUsageDsaOp, \n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.18060.0.4.2.3.14\n" + "m-usage: DSA_OPERATION\n\n"; assertEquals( expected, transform( "testATUsageDsaOp" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertMozillaATWithOidLen() throws ParserException, IOException { String expected = HEADER + "dn: m-oid=1.3.6.1.4.1.13769.3.2, ou=attributetypes, cn=testMozillaATWithOidLen, \n" + " ou=schema\n" + "objectclass: metaAttributeType\n" + "objectclass: metaTop\n" + "objectclass: top\n" + "m-oid: 1.3.6.1.4.1.13769.3.2\n" + "m-name: mozillaHomeStreet2\n" + "m-equality: caseIgnoreMatch\n" + "m-substr: caseIgnoreSubstringsMatch\n" + "m-syntax: 1.3.6.1.4.1.1466.115.121.1.15\n" + "m-length: 128\n" + "m-singleValue: TRUE\n\n"; assertEquals( expected, transform( "testMozillaATWithOidLen" ) ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testConvertWrongLdif() throws ParserException, IOException { assertThrows( ParserException.class, ( ) -> { transform( "testWrongLdif" ); } ); } | public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } | SchemaToLdif { public static void transform( List<Schema> schemas ) throws ParserException { if ( ( schemas == null ) || schemas.isEmpty() ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_15000_NO_SCHEMA_DEFINED ) ); } return; } int i = 1; for ( Schema schema : schemas ) { if ( schema.getName() == null ) { String msg = I18n.err( I18n.ERR_15000_SCHEMA_ELEMENT_NAME_REQUIRED, i ); LOG.error( msg ); throw new ParserException( msg ); } } for ( Schema schema : schemas ) { try { if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_15001_GENERATING_SCHEMA, schema.getName() ) ); } generate( schema ); } catch ( Exception e ) { throw new ParserException( I18n.err( I18n.ERR_15004_CANNOT_GENERATE_SOURCES, schema.getName(), e.getMessage() ) ); } } } private SchemaToLdif(); static void transform( List<Schema> schemas ); } |
@Test public void testAddNullDN() throws LdapException { DnNode<Dn> tree = new DnNode<Dn>(); assertThrows( LdapUnwillingToPerformException.class, () -> { tree.add( ( Dn ) null, null ); } ); } | public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testAdd2EqualDNs() throws LdapException { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn1 = new Dn( "dc=b,dc=a" ); Dn dn2 = new Dn( "dc=b,dc=a" ); tree.add( dn1, dn1 ); assertThrows( LdapUnwillingToPerformException.class, () -> { tree.add( dn2, dn2 ); } ); } | public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized DnNode<N> add( Dn dn ) throws LdapException { return add( dn, null ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testHasChildren() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn1 = new Dn( "dc=b,dc=a" ); tree.add( dn1 ); assertTrue( tree.hasChildren() ); Map<String, DnNode<Dn>> children = tree.getChildren(); assertNotNull( children ); DnNode<Dn> child = children.get( new Rdn( "dc=a" ).getNormName() ); assertTrue( child.hasChildren() ); children = child.getChildren(); child = children.get( new Rdn( "dc=b" ).getNormName() ); assertFalse( child.hasChildren() ); } | public synchronized boolean hasChildren() { return ( children != null ) && children.size() != 0; } | DnNode { public synchronized boolean hasChildren() { return ( children != null ) && children.size() != 0; } } | DnNode { public synchronized boolean hasChildren() { return ( children != null ) && children.size() != 0; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized boolean hasChildren() { return ( children != null ) && children.size() != 0; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized boolean hasChildren() { return ( children != null ) && children.size() != 0; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test @Disabled public void testBytesPerf() { long t0 = System.currentTimeMillis(); for ( int j = 0; j < 1000; j++ ) { Asn1Buffer buffer = new Asn1Buffer(); for ( int i = 0; i < 409600; i++ ) { buffer.put( new byte[] { 0x01, ( byte ) i } ); } } long t1 = System.currentTimeMillis(); System.out.println( "Delta: " + ( t1 - t0 ) ); } | public void put( byte b ) { if ( pos == size ) { extend(); } currentBuffer.buffer[size - pos - 1] = b; pos++; } | Asn1Buffer2 { public void put( byte b ) { if ( pos == size ) { extend(); } currentBuffer.buffer[size - pos - 1] = b; pos++; } } | Asn1Buffer2 { public void put( byte b ) { if ( pos == size ) { extend(); } currentBuffer.buffer[size - pos - 1] = b; pos++; } Asn1Buffer2(); } | Asn1Buffer2 { public void put( byte b ) { if ( pos == size ) { extend(); } currentBuffer.buffer[size - pos - 1] = b; pos++; } Asn1Buffer2(); int getPos(); void put( byte b ); void put( byte[] bytes ); byte[] getBytes(); int getSize(); void clear(); @Override String toString(); } | Asn1Buffer2 { public void put( byte b ) { if ( pos == size ) { extend(); } currentBuffer.buffer[size - pos - 1] = b; pos++; } Asn1Buffer2(); int getPos(); void put( byte b ); void put( byte[] bytes ); byte[] getBytes(); int getSize(); void clear(); @Override String toString(); } |
@Test public void testIsLeaf() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn = new Dn( "dc=c,dc=b,dc=a" ); tree.add( dn ); assertFalse( tree.isLeaf() ); DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) ); assertFalse( child.isLeaf() ); child = child.getChild( new Rdn( "dc=b" ) ); assertFalse( child.isLeaf() ); child = child.getChild( new Rdn( "dc=c" ) ); assertTrue( child.isLeaf() ); } | public synchronized boolean isLeaf() { return !hasChildren(); } | DnNode { public synchronized boolean isLeaf() { return !hasChildren(); } } | DnNode { public synchronized boolean isLeaf() { return !hasChildren(); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized boolean isLeaf() { return !hasChildren(); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized boolean isLeaf() { return !hasChildren(); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testGetElement() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn = new Dn( "dc=c,dc=b,dc=a" ); tree.add( dn, dn ); assertNull( tree.getElement() ); DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) ); assertNull( child.getElement() ); child = child.getChild( new Rdn( "dc=b" ) ); assertNull( child.getElement() ); child = child.getChild( new Rdn( "dc=c" ) ); assertEquals( dn, child.getElement() ); } | public synchronized N getElement() { return nodeElement; } | DnNode { public synchronized N getElement() { return nodeElement; } } | DnNode { public synchronized N getElement() { return nodeElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized N getElement() { return nodeElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized N getElement() { return nodeElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testHasElement() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn = new Dn( "dc=c,dc=b,dc=a" ); tree.add( dn, dn ); assertFalse( tree.hasElement() ); DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) ); assertFalse( child.hasElement() ); child = child.getChild( new Rdn( "dc=b" ) ); assertFalse( child.hasElement() ); child = child.getChild( new Rdn( "dc=c" ) ); assertTrue( child.hasElement() ); } | public synchronized boolean hasElement() { return nodeElement != null; } | DnNode { public synchronized boolean hasElement() { return nodeElement != null; } } | DnNode { public synchronized boolean hasElement() { return nodeElement != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized boolean hasElement() { return nodeElement != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized boolean hasElement() { return nodeElement != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testSize() throws LdapException { DnNode<Dn> tree = new DnNode<Dn>(); assertEquals( 1, tree.size() ); tree.add( new Dn( "dc=b,dc=a" ) ); assertEquals( 3, tree.size() ); tree.add( new Dn( "dc=f,dc=a" ) ); assertEquals( 4, tree.size() ); tree.add( new Dn( "dc=a,dc=f,dc=a" ) ); assertEquals( 5, tree.size() ); tree.add( new Dn( "dc=b,dc=f,dc=a" ) ); assertEquals( 6, tree.size() ); tree.add( new Dn( "dc=z,dc=t" ) ); assertEquals( 8, tree.size() ); } | public synchronized int size() { int size = 1; if ( children.size() != 0 ) { for ( DnNode<N> node : children.values() ) { size += node.size(); } } return size; } | DnNode { public synchronized int size() { int size = 1; if ( children.size() != 0 ) { for ( DnNode<N> node : children.values() ) { size += node.size(); } } return size; } } | DnNode { public synchronized int size() { int size = 1; if ( children.size() != 0 ) { for ( DnNode<N> node : children.values() ) { size += node.size(); } } return size; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized int size() { int size = 1; if ( children.size() != 0 ) { for ( DnNode<N> node : children.values() ) { size += node.size(); } } return size; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized int size() { int size = 1; if ( children.size() != 0 ) { for ( DnNode<N> node : children.values() ) { size += node.size(); } } return size; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testGetParent() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn = new Dn( "dc=c,dc=b,dc=a" ); tree.add( dn, dn ); assertNull( tree.getParent() ); DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) ); assertEquals( tree, child.getParent() ); DnNode<Dn> child1 = child.getChild( new Rdn( "dc=b" ) ); assertEquals( child, child1.getParent() ); child = child1.getChild( new Rdn( "dc=c" ) ); assertEquals( child1, child.getParent() ); } | public synchronized DnNode<N> getParent() { return parent; } | DnNode { public synchronized DnNode<N> getParent() { return parent; } } | DnNode { public synchronized DnNode<N> getParent() { return parent; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized DnNode<N> getParent() { return parent; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized DnNode<N> getParent() { return parent; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testHasParent() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn = new Dn( "dc=c,dc=b,dc=a" ); tree.add( dn, dn ); assertFalse( tree.hasParent() ); DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) ); assertTrue( child.hasParent() ); DnNode<Dn> child1 = child.getChild( new Rdn( "dc=b" ) ); assertTrue( child1.hasParent() ); child = child1.getChild( new Rdn( "dc=c" ) ); assertTrue( child.hasParent() ); } | public synchronized boolean hasParent() { return parent != null; } | DnNode { public synchronized boolean hasParent() { return parent != null; } } | DnNode { public synchronized boolean hasParent() { return parent != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized boolean hasParent() { return parent != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized boolean hasParent() { return parent != null; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testContains() throws Exception { DnNode<Dn> tree = new DnNode<Dn>(); Dn dn = new Dn( "dc=c,dc=b,dc=a" ); tree.add( dn, dn ); Rdn rdnA = new Rdn( "dc=a" ); Rdn rdnB = new Rdn( "dc=b" ); Rdn rdnC = new Rdn( "dc=c" ); assertTrue( tree.contains( rdnA ) ); assertFalse( tree.contains( rdnB ) ); assertFalse( tree.contains( rdnC ) ); DnNode<Dn> child = tree.getChild( rdnA ); assertFalse( child.contains( rdnA ) ); assertTrue( child.contains( rdnB ) ); assertFalse( child.contains( rdnC ) ); child = child.getChild( rdnB ); assertFalse( child.contains( rdnA ) ); assertFalse( child.contains( rdnB ) ); assertTrue( child.contains( rdnC ) ); } | public synchronized boolean contains( Rdn rdn ) { return children.containsKey( rdn.getNormName() ); } | DnNode { public synchronized boolean contains( Rdn rdn ) { return children.containsKey( rdn.getNormName() ); } } | DnNode { public synchronized boolean contains( Rdn rdn ) { return children.containsKey( rdn.getNormName() ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized boolean contains( Rdn rdn ) { return children.containsKey( rdn.getNormName() ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized boolean contains( Rdn rdn ) { return children.containsKey( rdn.getNormName() ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testHasParentElement() throws Exception { DnNode<Dn> dnLookupTree = new DnNode<Dn>(); Dn dn1 = new Dn( "dc=directory,dc=apache,dc=org" ); Dn dn2 = new Dn( "dc=mina,dc=apache,dc=org" ); Dn dn3 = new Dn( "dc=test,dc=com" ); Dn dn4 = new Dn( "dc=acme,dc=com" ); Dn dn5 = new Dn( "dc=acme,c=us,dc=com" ); Dn dn6 = new Dn( "dc=empty" ); Dn org = new Dn( "dc=org" ); dnLookupTree.add( dn1, dn1 ); dnLookupTree.add( dn2, dn2 ); dnLookupTree.add( dn3, dn3 ); dnLookupTree.add( dn4, dn4 ); dnLookupTree.add( dn5 ); dnLookupTree.add( dn6, dn6 ); dnLookupTree.add( org, org ); assertTrue( dnLookupTree.hasParentElement( new Dn( "dc=apache,dc=org" ) ) ); assertTrue( dnLookupTree.hasDescendantElement( org ) ); assertFalse( dnLookupTree.hasDescendantElement( new Dn( "c=us,dc=com" ) ) ); Dn dn7 = new Dn( "dc=elem,dc=mina,dc=apache,dc=org" ); dnLookupTree.add( dn7, dn7 ); List<Dn> dns = dnLookupTree.getDescendantElements( org ); assertNotNull( dns ); assertEquals( 2, dns.size() ); assertTrue( dns.contains( dn1 ) ); assertTrue( dns.contains( dn2 ) ); dns = dnLookupTree.getDescendantElements( dn6 ); assertEquals( 0, dns.size() ); } | public synchronized boolean hasParentElement( Dn dn ) { List<Rdn> rdns = dn.getRdns(); DnNode<N> currentNode = this; boolean hasElement = false; for ( int i = rdns.size() - 1; i >= 0; i-- ) { Rdn rdn = rdns.get( i ); if ( currentNode.hasChildren() ) { currentNode = currentNode.children.get( rdn.getNormName() ); if ( currentNode == null ) { break; } if ( currentNode.hasElement() ) { hasElement = true; } parent = currentNode; } else { break; } } return hasElement; } | DnNode { public synchronized boolean hasParentElement( Dn dn ) { List<Rdn> rdns = dn.getRdns(); DnNode<N> currentNode = this; boolean hasElement = false; for ( int i = rdns.size() - 1; i >= 0; i-- ) { Rdn rdn = rdns.get( i ); if ( currentNode.hasChildren() ) { currentNode = currentNode.children.get( rdn.getNormName() ); if ( currentNode == null ) { break; } if ( currentNode.hasElement() ) { hasElement = true; } parent = currentNode; } else { break; } } return hasElement; } } | DnNode { public synchronized boolean hasParentElement( Dn dn ) { List<Rdn> rdns = dn.getRdns(); DnNode<N> currentNode = this; boolean hasElement = false; for ( int i = rdns.size() - 1; i >= 0; i-- ) { Rdn rdn = rdns.get( i ); if ( currentNode.hasChildren() ) { currentNode = currentNode.children.get( rdn.getNormName() ); if ( currentNode == null ) { break; } if ( currentNode.hasElement() ) { hasElement = true; } parent = currentNode; } else { break; } } return hasElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized boolean hasParentElement( Dn dn ) { List<Rdn> rdns = dn.getRdns(); DnNode<N> currentNode = this; boolean hasElement = false; for ( int i = rdns.size() - 1; i >= 0; i-- ) { Rdn rdn = rdns.get( i ); if ( currentNode.hasChildren() ) { currentNode = currentNode.children.get( rdn.getNormName() ); if ( currentNode == null ) { break; } if ( currentNode.hasElement() ) { hasElement = true; } parent = currentNode; } else { break; } } return hasElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized boolean hasParentElement( Dn dn ) { List<Rdn> rdns = dn.getRdns(); DnNode<N> currentNode = this; boolean hasElement = false; for ( int i = rdns.size() - 1; i >= 0; i-- ) { Rdn rdn = rdns.get( i ); if ( currentNode.hasChildren() ) { currentNode = currentNode.children.get( rdn.getNormName() ); if ( currentNode == null ) { break; } if ( currentNode.hasElement() ) { hasElement = true; } parent = currentNode; } else { break; } } return hasElement; } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testRename() throws Exception { DnNode<Dn> rootNode = new DnNode<Dn>(); Dn dn = new Dn( "dc=directory,dc=apache,dc=org" ); rootNode.add( dn ); Rdn childRdn = new Rdn( "dc=org" ); DnNode<Dn> child = rootNode.getChild( childRdn ); assertNotNull( child ); Rdn newChildRdn = new Rdn( "dc=neworg" ); child.rename( newChildRdn ); assertNull( rootNode.getChild( childRdn ) ); assertEquals( new Dn( "dc=neworg" ), child.getDn() ); DnNode<Dn> child2 = child.getChild( new Rdn( "dc=apache" ) ); assertEquals( new Dn( "dc=apache,dc=neworg" ), child2.getDn() ); assertEquals( new Dn( "dc=directory,dc=apache,dc=neworg" ), child2.getChild( new Rdn( "dc=directory" ) ) .getDn() ); assertNotNull( rootNode.getChild( newChildRdn ) ); } | public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } | DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } } | DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); } | DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } | DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } DnNode(); DnNode( N element ); DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); } |
@Test public void testWithOperationParameters() throws Exception { TriggerSpecification triggerSpecification = null; String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($name, $deletedEntry);"; triggerSpecification = parser.parse( spec ); assertNotNull( triggerSpecification ); assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER ); assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE ); List<SPSpec> spSpecs = triggerSpecification.getSPSpecs(); assertTrue( spSpecs != null ); assertTrue( spSpecs.size() == 1 ); SPSpec theSpec = spSpecs.get( 0 ); assertEquals( theSpec.getName(), "BackupUtilities.backupDeletedEntry" ); assertEquals( theSpec.getOptions().size(), 0 ); assertEquals( theSpec.getParameters().size(), 2 ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Delete_NAME.instance() ) ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) ); } | public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } |
@Test public void testYearMonthDayHourMinSecZulu() throws ParseException { String gt = "20080102121314Z"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testWithGenericParameters() throws Exception { TriggerSpecification triggerSpecification = null; String spec = "AFTER Add CALL \"Logger.logAddOperation\" ($entry, $attributes, $operationPrincipal);"; triggerSpecification = parser.parse( spec ); assertNotNull( triggerSpecification ); assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER ); assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.ADD ); List<SPSpec> spSpecs = triggerSpecification.getSPSpecs(); assertTrue( spSpecs != null ); assertTrue( spSpecs.size() == 1 ); SPSpec theSpec = spSpecs.get( 0 ); assertEquals( theSpec.getName(), "Logger.logAddOperation" ); assertEquals( theSpec.getOptions().size(), 0 ); assertEquals( theSpec.getParameters().size(), 3 ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Add_ENTRY.instance() ) ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Add_ATTRIBUTES.instance() ) ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Generic_OPERATION_PRINCIPAL.instance() ) ); } | public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } |
@Test public void testWithLanguageSchemeOption() throws Exception { TriggerSpecification triggerSpecification = null; String spec = "AFTER Modify CALL \"Logger.logModifyOperation\" {languageScheme \"Java\"}();"; triggerSpecification = parser.parse( spec ); assertNotNull( triggerSpecification ); assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER ); assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.MODIFY ); List<SPSpec> spSpecs = triggerSpecification.getSPSpecs(); assertTrue( spSpecs != null ); assertTrue( spSpecs.size() == 1 ); SPSpec theSpec = spSpecs.get( 0 ); assertEquals( theSpec.getName(), "Logger.logModifyOperation" ); assertEquals( theSpec.getOptions().size(), 1 ); assertTrue( theSpec.getOptions().contains( new StoredProcedureLanguageSchemeOption( "Java" ) ) ); assertEquals( theSpec.getParameters().size(), 0 ); } | public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } |
@Test public void testWithSearchContextOption() throws Exception { TriggerSpecification triggerSpecification = null; String spec = "AFTER ModifyDN.Rename CALL \"Logger.logModifyDNRenameOperation\" \n" + "{ searchContext { scope one } \"cn=Logger,ou=Stored Procedures,ou=system\" } \n" + "($entry, $newrdn); # Stored Procedure Parameter(s)"; triggerSpecification = parser.parse( spec ); assertNotNull( triggerSpecification ); assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER ); assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.MODIFYDN_RENAME ); List<SPSpec> spSpecs = triggerSpecification.getSPSpecs(); assertTrue( spSpecs != null ); assertTrue( spSpecs.size() == 1 ); SPSpec theSpec = spSpecs.get( 0 ); assertEquals( theSpec.getName(), "Logger.logModifyDNRenameOperation" ); assertEquals( theSpec.getOptions().size(), 1 ); assertTrue( theSpec.getOptions().contains( new StoredProcedureSearchContextOption( new Dn( "cn=Logger,ou=Stored Procedures,ou=system" ), SearchScope.ONELEVEL ) ) ); assertEquals( theSpec.getParameters().size(), 2 ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.ModifyDN_ENTRY.instance() ) ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.ModifyDN_NEW_RDN.instance() ) ); } | public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } |
@Test public void testWithLdapContextParameter() throws Exception { TriggerSpecification triggerSpecification = null; String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext \"ou=Backup,ou=System\", $name, $deletedEntry);"; triggerSpecification = parser.parse( spec ); assertNotNull( triggerSpecification ); assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER ); assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE ); List<SPSpec> spSpecs = triggerSpecification.getSPSpecs(); assertTrue( spSpecs != null ); assertTrue( spSpecs.size() == 1 ); SPSpec theSpec = spSpecs.get( 0 ); assertEquals( theSpec.getName(), "BackupUtilities.backupDeletedEntry" ); assertEquals( theSpec.getOptions().size(), 0 ); assertEquals( theSpec.getParameters().size(), 3 ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Delete_NAME.instance() ) ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) ); assertTrue( theSpec.getParameters().contains( StoredProcedureParameter.Generic_LDAP_CONTEXT.instance( new Dn( "ou=Backup,ou=System" ) ) ) ); } | public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } |
@Test public void testMultipleSPCalls() throws Exception { TriggerSpecification triggerSpecification = null; String spec = "AFTER Delete " + "CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext \"ou=Backup,ou=System\", $name, $deletedEntry); " + "CALL \"BackupUtilities.recreateDeletedEntry\" ($name, $deletedEntry);"; triggerSpecification = parser.parse( spec ); assertNotNull( triggerSpecification ); assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER ); assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE ); List<SPSpec> spSpecs = triggerSpecification.getSPSpecs(); assertTrue( spSpecs != null ); assertTrue( spSpecs.size() == 2 ); SPSpec firstSpec = spSpecs.get( 0 ); assertEquals( firstSpec.getName(), "BackupUtilities.backupDeletedEntry" ); assertEquals( firstSpec.getOptions().size(), 0 ); assertEquals( firstSpec.getParameters().size(), 3 ); assertTrue( firstSpec.getParameters().contains( StoredProcedureParameter.Delete_NAME.instance() ) ); assertTrue( firstSpec.getParameters().contains( StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) ); assertTrue( firstSpec.getParameters().contains( StoredProcedureParameter.Generic_LDAP_CONTEXT.instance( new Dn( "ou=Backup,ou=System" ) ) ) ); SPSpec secondSpec = spSpecs.get( 1 ); assertEquals( secondSpec.getName(), "BackupUtilities.recreateDeletedEntry" ); assertEquals( secondSpec.getOptions().size(), 0 ); assertEquals( secondSpec.getParameters().size(), 2 ); assertTrue( secondSpec.getParameters().contains( StoredProcedureParameter.Delete_NAME.instance() ) ); assertTrue( secondSpec.getParameters().contains( StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) ); } | public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } | TriggerSpecificationParser { public synchronized TriggerSpecification parse( String spec ) throws ParseException { TriggerSpecification triggerSpecification; if ( Strings.isEmpty( spec ) ) { return null; } reset( spec ); try { triggerSpecification = this.parser.wrapperEntryPoint(); } catch ( TokenStreamException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, 0 ); } catch ( RecognitionException e ) { String msg = I18n.err( I18n.ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE, spec, e.getLocalizedMessage() ); throw new ParseException( msg, e.getColumn() ); } return triggerSpecification; } TriggerSpecificationParser(); TriggerSpecificationParser( NormalizerMappingResolver<Normalizer> resolver ); synchronized TriggerSpecification parse( String spec ); boolean isNormizing(); } |
@Test public void testEqualsNotInstanceOf() throws Exception { assertFalse( maxValueCountItemA.equals( UndefinedNode.UNDEFINED_NODE ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } MaxValueCountItem( Set<MaxValueCountElem> items ); } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testEqualsNull() throws Exception { assertFalse( maxValueCountItemA.equals( null ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } MaxValueCountItem( Set<MaxValueCountElem> items ); } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxValueCountItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxValueCountItem ) { MaxValueCountItem that = ( MaxValueCountItem ) o; return items.equals( that.items ); } return false; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeReflexive() throws Exception { assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemA.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeSymmetric() throws Exception { assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemACopy.hashCode() ); assertEquals( maxValueCountItemACopy.hashCode(), maxValueCountItemA.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeTransitive() throws Exception { assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemACopy.hashCode() ); assertEquals( maxValueCountItemACopy.hashCode(), maxValueCountItemB.hashCode() ); assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemB.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxValueCountItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( items != null ) { for ( MaxValueCountElem item : items ) { if ( item != null ) { hash = hash * 17 + item.hashCode(); } else { hash = hash * 17 + 37; } } } return hash; } MaxValueCountItem( Set<MaxValueCountElem> items ); Iterator<MaxValueCountElem> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testYearMonthDayHourMinSecPlusHour() throws ParseException { String gt = "20080102121314+04"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void createFlow() throws Exception { String functionId = "functionId"; HttpClient.HttpResponse response = responseWithCreateGraphResponse(testFlowId); when(mockHttpClient.execute(requestContainingFunctionId(functionId))).thenReturn(response); FlowId flowId = completerClient.createFlow(functionId); assertNotNull(flowId); assertEquals(flowId.getId(), testFlowId); } | @Override public FlowId createFlow(String functionId) { try { APIModel.CreateGraphRequest createGraphRequest = new APIModel.CreateGraphRequest(functionId); ObjectMapper objectMapper = FlowRuntimeGlobals.getObjectMapper(); byte[] body = objectMapper.writeValueAsBytes(createGraphRequest); HttpClient.HttpRequest request = preparePost(apiUrlBase + "/flows").withBody(body); try (HttpClient.HttpResponse resp = httpClient.execute(request)) { validateSuccessful(resp); APIModel.CreateGraphResponse createGraphResponse = objectMapper.readValue(resp.body, APIModel.CreateGraphResponse.class); return new FlowId(createGraphResponse.flowId); } catch (Exception e) { throw new PlatformCommunicationException("Failed to create flow ", e); } } catch (IOException e) { throw new PlatformCommunicationException("Failed to create CreateGraphRequest"); } } | RemoteFlowApiClient implements CompleterClient { @Override public FlowId createFlow(String functionId) { try { APIModel.CreateGraphRequest createGraphRequest = new APIModel.CreateGraphRequest(functionId); ObjectMapper objectMapper = FlowRuntimeGlobals.getObjectMapper(); byte[] body = objectMapper.writeValueAsBytes(createGraphRequest); HttpClient.HttpRequest request = preparePost(apiUrlBase + "/flows").withBody(body); try (HttpClient.HttpResponse resp = httpClient.execute(request)) { validateSuccessful(resp); APIModel.CreateGraphResponse createGraphResponse = objectMapper.readValue(resp.body, APIModel.CreateGraphResponse.class); return new FlowId(createGraphResponse.flowId); } catch (Exception e) { throw new PlatformCommunicationException("Failed to create flow ", e); } } catch (IOException e) { throw new PlatformCommunicationException("Failed to create CreateGraphRequest"); } } } | RemoteFlowApiClient implements CompleterClient { @Override public FlowId createFlow(String functionId) { try { APIModel.CreateGraphRequest createGraphRequest = new APIModel.CreateGraphRequest(functionId); ObjectMapper objectMapper = FlowRuntimeGlobals.getObjectMapper(); byte[] body = objectMapper.writeValueAsBytes(createGraphRequest); HttpClient.HttpRequest request = preparePost(apiUrlBase + "/flows").withBody(body); try (HttpClient.HttpResponse resp = httpClient.execute(request)) { validateSuccessful(resp); APIModel.CreateGraphResponse createGraphResponse = objectMapper.readValue(resp.body, APIModel.CreateGraphResponse.class); return new FlowId(createGraphResponse.flowId); } catch (Exception e) { throw new PlatformCommunicationException("Failed to create flow ", e); } } catch (IOException e) { throw new PlatformCommunicationException("Failed to create CreateGraphRequest"); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public FlowId createFlow(String functionId) { try { APIModel.CreateGraphRequest createGraphRequest = new APIModel.CreateGraphRequest(functionId); ObjectMapper objectMapper = FlowRuntimeGlobals.getObjectMapper(); byte[] body = objectMapper.writeValueAsBytes(createGraphRequest); HttpClient.HttpRequest request = preparePost(apiUrlBase + "/flows").withBody(body); try (HttpClient.HttpResponse resp = httpClient.execute(request)) { validateSuccessful(resp); APIModel.CreateGraphResponse createGraphResponse = objectMapper.readValue(resp.body, APIModel.CreateGraphResponse.class); return new FlowId(createGraphResponse.flowId); } catch (Exception e) { throw new PlatformCommunicationException("Failed to create flow ", e); } } catch (IOException e) { throw new PlatformCommunicationException("Failed to create CreateGraphRequest"); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public FlowId createFlow(String functionId) { try { APIModel.CreateGraphRequest createGraphRequest = new APIModel.CreateGraphRequest(functionId); ObjectMapper objectMapper = FlowRuntimeGlobals.getObjectMapper(); byte[] body = objectMapper.writeValueAsBytes(createGraphRequest); HttpClient.HttpRequest request = preparePost(apiUrlBase + "/flows").withBody(body); try (HttpClient.HttpResponse resp = httpClient.execute(request)) { validateSuccessful(resp); APIModel.CreateGraphResponse createGraphResponse = objectMapper.readValue(resp.body, APIModel.CreateGraphResponse.class); return new FlowId(createGraphResponse.flowId); } catch (Exception e) { throw new PlatformCommunicationException("Failed to create flow ", e); } } catch (IOException e) { throw new PlatformCommunicationException("Failed to create CreateGraphRequest"); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void invokesFunctionWithFluxOfMultipleItems() { SpringCloudFunction fnWrapper = new SpringCloudFunction(x -> x, new SimpleFunctionInspector()); Object result = invoker.tryInvoke(fnWrapper, new Object[]{ Arrays.asList("hello", "world") }); assertThat(result).isInstanceOf(List.class); assertThat((List) result).containsSequence("hello", "world"); } | @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); @Override Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt); @Override void close(); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); @Override Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt); @Override void close(); } |
@Test public void supply() throws Exception { String contentType = "application/java-serialized-object"; String testBlobId = "BLOBID"; BlobResponse blobResponse = makeBlobResponse(lambdaBytes, contentType, testBlobId); when(blobStoreClient.writeBlob(testFlowId, lambdaBytes, contentType)).thenReturn(blobResponse); HttpClient.HttpResponse response = responseWithAddStageResponse(testFlowId, testStageId); when(mockHttpClient.execute(requestContainingAddStageRequest(blobResponse.blobId, Collections.emptyList()))).thenReturn(response); CompletionId completionId = completerClient.supply(new FlowId(testFlowId), serializableLambda, codeLocation); assertNotNull(completionId); assertEquals(completionId.getId(), testStageId); } | @Override public CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation) { return addStageWithClosure(APIModel.CompletionOperation.SUPPLY, flowId, supplier, codeLocation, Collections.emptyList()); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation) { return addStageWithClosure(APIModel.CompletionOperation.SUPPLY, flowId, supplier, codeLocation, Collections.emptyList()); } } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation) { return addStageWithClosure(APIModel.CompletionOperation.SUPPLY, flowId, supplier, codeLocation, Collections.emptyList()); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation) { return addStageWithClosure(APIModel.CompletionOperation.SUPPLY, flowId, supplier, codeLocation, Collections.emptyList()); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation) { return addStageWithClosure(APIModel.CompletionOperation.SUPPLY, flowId, supplier, codeLocation, Collections.emptyList()); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void invokeFunctionNormally() throws Exception { String testFunctionId = "TESTFUNCTION"; String blobid = "BLOBID"; byte[] invokeBody = "INPUTDATA".getBytes(); String contentType = "text/plain"; BlobResponse blobResponse = makeBlobResponse(invokeBody, contentType, blobid); when(blobStoreClient.writeBlob(eq(testFlowId), eq(invokeBody), eq(contentType))).thenReturn(blobResponse); HttpClient.HttpResponse response = responseWithAddStageResponse(testFlowId, testStageId); when(mockHttpClient.execute(requestContainingAddInvokeFunctionStageRequest(testFunctionId, APIModel.HTTPMethod.Post))).thenReturn(response); CompletionId completionId = completerClient.invokeFunction(new FlowId(testFlowId), testFunctionId, invokeBody, HttpMethod.POST, Headers.fromMap(Collections.singletonMap("Content-type", contentType)), CodeLocation.unknownLocation()); assertNotNull(completionId); assertEquals(completionId.getId(), testStageId); } | @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void invokeFunctionWithInvalidFunctionId() throws Exception { String testFunctionId = "INVALIDFUNCTIONID"; byte[] invokeBody = "INPUTDATA".getBytes(); String contentType = "text/plain"; BlobResponse blobResponse = makeBlobResponse(invokeBody, contentType, "BLOBID"); when(blobStoreClient.writeBlob(testFlowId, invokeBody, contentType)).thenReturn(blobResponse); when(mockHttpClient.execute(requestContainingAddInvokeFunctionStageRequest(testFunctionId, APIModel.HTTPMethod.Post))).thenReturn(new HttpClient.HttpResponse(400)); thrown.expect(PlatformCommunicationException.class); thrown.expectMessage("Failed to add stage"); Map headersMap = Collections.singletonMap("Content-type", contentType); Headers headers = Headers.fromMap(headersMap); completerClient.invokeFunction(new FlowId(testFlowId), testFunctionId, invokeBody, HttpMethod.POST, headers, locationFn()); } | @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation) { APIModel.HTTPReq httpReq = new APIModel.HTTPReq(); if (headers != null) { if (data.length > 0) { BlobResponse blobResponse = blobStoreClient.writeBlob(flowId.getId(), data, headers.get(CONTENT_TYPE_HEADER).orElse(CONTENT_TYPE_OCTET_STREAM)); httpReq.body = APIModel.Blob.fromBlobResponse(blobResponse); } httpReq.headers = new ArrayList<>(); headers.asMap().forEach((k, vs) -> vs.forEach(v -> httpReq.headers.add(APIModel.HTTPHeader.create(k, v)))); Map<String, List<String>> headersMap = headers.asMap(); headersMap.forEach((key, values) -> values.forEach(value -> httpReq.headers.add(APIModel.HTTPHeader.create(key, value)))); } httpReq.method = APIModel.HTTPMethod.fromFlow(method); APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = new APIModel.AddInvokeFunctionStageRequest(); addInvokeFunctionStageRequest.arg = httpReq; addInvokeFunctionStageRequest.codeLocation = codeLocation.getLocation(); addInvokeFunctionStageRequest.callerId = FlowRuntimeGlobals.getCurrentCompletionId().map(CompletionId::getId).orElse(null); addInvokeFunctionStageRequest.functionId = functionId; try { return executeAddInvokeFunctionStageRequest(flowId, addInvokeFunctionStageRequest); } catch (IOException e) { throw new PlatformCommunicationException("Failed to create invokeFunction stage", e); } } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void waitForCompletionNormally() throws Exception { String testBlobId = "BLOBID"; String testContentType = "application/java-serialized-object"; APIModel.Blob blob = new APIModel.Blob(); blob.blobId = testBlobId; blob.contentType = testContentType; APIModel.CompletionResult completionResult = APIModel.CompletionResult.success(APIModel.BlobDatum.fromBlob(blob)); when(mockHttpClient.execute(requestForAwaitStageResult())).thenReturn(responseWithAwaitStageResponse(completionResult)); when(blobStoreClient.readBlob(eq(testFlowId), eq("BLOBID"), any(), eq("application/java-serialized-object"))).thenReturn(1); Object result = completerClient.waitForCompletion(new FlowId(testFlowId), new CompletionId(testStageId), null); assertEquals(result, 1); } | @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void waitForCompletionOnExceptionallyCompletedStage() throws Exception { String testBlobId = "BLOBID"; String testContentType = "application/java-serialized-object"; APIModel.Blob blob = new APIModel.Blob(); blob.blobId = testBlobId; blob.contentType = testContentType; APIModel.CompletionResult completionResult = APIModel.CompletionResult.failure(APIModel.BlobDatum.fromBlob(blob)); when(mockHttpClient.execute(requestForAwaitStageResult())).thenReturn(responseWithAwaitStageResponse(completionResult)); class MyException extends RuntimeException {} MyException myException = new MyException(); when(blobStoreClient.readBlob(eq(testFlowId), eq(testBlobId), any(), eq(testContentType))).thenReturn(myException); thrown.expect(new BaseMatcher<Object>() { @Override public void describeTo(Description description) { description.appendText("an exception of type FlowCompletionException, containing a cause of type MyException"); } @Override public boolean matches(Object o) { if(o instanceof FlowCompletionException) { FlowCompletionException flowCompletionException = (FlowCompletionException) o; if(flowCompletionException.getCause().equals(myException)) { return true; } } return false; } }); completerClient.waitForCompletion(new FlowId(testFlowId), new CompletionId(testStageId), null); } | @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void waitForCompletionUnknownStage() throws Exception { when(mockHttpClient.execute(requestForAwaitStageResult())).thenReturn(new HttpClient.HttpResponse(404)); thrown.expect(PlatformCommunicationException.class); thrown.expectMessage(contains("unexpected response")); completerClient.waitForCompletion(new FlowId(testFlowId), new CompletionId(testStageId), null); } | @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); } | RemoteFlowApiClient implements CompleterClient { @Override public Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit) throws TimeoutException { long msTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit); long start = System.currentTimeMillis(); do { long lastStart = System.currentTimeMillis(); long remainingTimeout = Math.max(1, start + msTimeout - lastStart); try (HttpClient.HttpResponse response = httpClient.execute(prepareGet(apiUrlBase + "/flows/" + flowId.getId() + "/stages/" + id.getId() + "/await?timeout_ms=" + remainingTimeout))) { if (response.getStatusCode() == 200) { APIModel.AwaitStageResponse resp = FlowRuntimeGlobals.getObjectMapper().readValue(response.getContentStream(), APIModel.AwaitStageResponse.class); if (resp.result.successful) { return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader())); } } else if (response.getStatusCode() == 408) { } else { throw asError(response); } try { Thread.sleep(Math.max(0, 500 - (System.currentTimeMillis() - lastStart))); } catch (InterruptedException e) { throw new PlatformCommunicationException("Interrupted", e); } } catch (IOException e) { throw new PlatformCommunicationException("Error fetching result", e); } } while (System.currentTimeMillis() - start < msTimeout); throw new TimeoutException("Stage did not completed before timeout "); } RemoteFlowApiClient(String apiUrlBase, BlobStoreClient blobClient, HttpClient httpClient); @Override FlowId createFlow(String functionId); @Override CompletionId supply(FlowId flowId, Serializable supplier, CodeLocation codeLocation); @Override CompletionId thenApply(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId whenComplete(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAccept(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenRun(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId acceptEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId applyToEither(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenAcceptBoth(FlowId flowId, CompletionId completionId, CompletionId alternate, Serializable fn, CodeLocation codeLocation); @Override CompletionId createCompletion(FlowId flowId, CodeLocation codeLocation); @Override CompletionId invokeFunction(FlowId flowId, String functionId, byte[] data, HttpMethod method, Headers headers, CodeLocation codeLocation); @Override CompletionId completedValue(FlowId flowId, boolean success, Object value, CodeLocation codeLocation); @Override CompletionId allOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId handle(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionally(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId exceptionallyCompose(FlowId flowId, CompletionId completionId, Serializable fn, CodeLocation codeLocation); @Override CompletionId thenCombine(FlowId flowId, CompletionId completionId, Serializable fn, CompletionId alternate, CodeLocation codeLocation); @Override boolean complete(FlowId flowId, CompletionId completionId, Object value, CodeLocation codeLocation); @Override boolean completeExceptionally(FlowId flowId, CompletionId completionId, Throwable value, CodeLocation codeLocation); @Override CompletionId anyOf(FlowId flowId, List<CompletionId> cids, CodeLocation codeLocation); @Override CompletionId delay(FlowId flowId, long l, CodeLocation codeLocation); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored, long timeout, TimeUnit unit); @Override Object waitForCompletion(FlowId flowId, CompletionId id, ClassLoader ignored); void commit(FlowId flowId); @Override void addTerminationHook(FlowId flowId, Serializable code, CodeLocation codeLocation); static final String CONTENT_TYPE_HEADER; static final String CONTENT_TYPE_JAVA_OBJECT; static final String CONTENT_TYPE_OCTET_STREAM; } |
@Test public void shouldCanonicalizeHeaders(){ for (String[] v : new String[][] { {"",""}, {"a","A"}, {"fn-ID-","Fn-Id-"}, {"myHeader-VaLue","Myheader-Value"}, {" Not a Header "," Not a Header "}, {"-","-"}, {"--","--"}, {"a-","A-"}, {"-a","-A"} }){ assertThat(Headers.canonicalKey(v[0])).isEqualTo(v[1]); } } | public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } | Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } } | Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } private Headers(Map<String, List<String>> headersIn); } | Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } private Headers(Map<String, List<String>> headersIn); Map getAll(); static String canonicalKey(String key); static Headers fromMap(Map<String, String> headers); static Headers fromMultiHeaderMap(Map<String, List<String>> headers); static Headers emptyHeaders(); Headers setHeaders(Map<String, List<String>> vals); Headers addHeader(String key, String v1, String... vs); Headers setHeader(String key, String v1, String... vs); Headers setHeader(String key, Collection<String> vs); Headers removeHeader(String key); Optional<String> get(String key); Collection<String> keys(); Map<String, List<String>> asMap(); List<String> getAllValues(String key); int hashCode(); boolean equals(Object other); @Override String toString(); } | Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } private Headers(Map<String, List<String>> headersIn); Map getAll(); static String canonicalKey(String key); static Headers fromMap(Map<String, String> headers); static Headers fromMultiHeaderMap(Map<String, List<String>> headers); static Headers emptyHeaders(); Headers setHeaders(Map<String, List<String>> vals); Headers addHeader(String key, String v1, String... vs); Headers setHeader(String key, String v1, String... vs); Headers setHeader(String key, Collection<String> vs); Headers removeHeader(String key); Optional<String> get(String key); Collection<String> keys(); Map<String, List<String>> asMap(); List<String> getAllValues(String key); int hashCode(); boolean equals(Object other); @Override String toString(); } |
@Test public void invokesFunctionWithEmptyFlux() { SpringCloudFunction fnWrapper = new SpringCloudFunction(x -> x, new SimpleFunctionInspector()); Object result = invoker.tryInvoke(fnWrapper, new Object[0]); assertThat(result).isNull(); } | @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); @Override Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt); @Override void close(); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); @Override Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt); @Override void close(); } |
@Test public void invokesFunctionWithFluxOfSingleItem() { SpringCloudFunction fnWrapper = new SpringCloudFunction(x -> x, new SimpleFunctionInspector()); Object result = invoker.tryInvoke(fnWrapper, new Object[]{ "hello" }); assertThat(result).isInstanceOf(String.class); assertThat(result).isEqualTo("hello"); } | @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); @Override Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt); @Override void close(); } | SpringCloudFunctionInvoker implements FunctionInvoker, Closeable { @Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, result); } SpringCloudFunctionInvoker(SpringCloudFunctionLoader loader); SpringCloudFunctionInvoker(Class<?> configClass); @Override Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt); @Override void close(); } |
@Test public void testInputHandlerResolveInputInterceptors() throws ExceptionReport, XmlException, IOException { System.out.println("Testing testInputHandlerResolveInputInterceptors..."); InputHandler instance = new InputHandler.Builder(simpleBufferAlgorithmInputArray, "org.n52.wps.server.algorithm.SimpleBufferAlgorithm").build(); Map<String, InterceptorInstance> resolveInputInterceptors = instance.resolveInputInterceptors("org.n52.wps.server.algorithm.SimpleBufferAlgorithm"); assertThat(resolveInputInterceptors.size(), equalTo(0)); instance = new InputHandler.Builder(dummyTestClassAlgorithmInputArray, "org.n52.wps.server.algorithm.test.DummyTestClass").build(); resolveInputInterceptors = instance.resolveInputInterceptors("org.n52.wps.server.algorithm.SimpleBufferAlgorithm"); assertThat(resolveInputInterceptors.size(), equalTo(0)); } | Map<String, InterceptorInstance> resolveInputInterceptors(String algorithmClassName) { Map<String,InterceptorInstance> result = new HashMap<String, InterceptorInstance>(); Class<?> clazz; try { clazz = Class.forName(algorithmClassName, false, getClass().getClassLoader()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class {}", algorithmClassName); return result; } DataInputInterceptorImplementations annotation = clazz.getAnnotation(DataInputInterceptors.DataInputInterceptorImplementations.class); if (annotation != null) { Class<?> interceptorClazz; try { interceptorClazz = Class.forName(annotation.value()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class "+ annotation.value(), e); return result; } if (DataInputInterceptors.class.isAssignableFrom(interceptorClazz)) { DataInputInterceptors instance; try { instance = (DataInputInterceptors) interceptorClazz.newInstance(); } catch (InstantiationException e) { LOGGER.warn("Could not instantiate class "+ interceptorClazz, e); return result; } catch (IllegalAccessException e) { LOGGER.warn("Could not access class "+ interceptorClazz, e); return result; } return instance.getInterceptors(); } } return result; } | InputHandler { Map<String, InterceptorInstance> resolveInputInterceptors(String algorithmClassName) { Map<String,InterceptorInstance> result = new HashMap<String, InterceptorInstance>(); Class<?> clazz; try { clazz = Class.forName(algorithmClassName, false, getClass().getClassLoader()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class {}", algorithmClassName); return result; } DataInputInterceptorImplementations annotation = clazz.getAnnotation(DataInputInterceptors.DataInputInterceptorImplementations.class); if (annotation != null) { Class<?> interceptorClazz; try { interceptorClazz = Class.forName(annotation.value()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class "+ annotation.value(), e); return result; } if (DataInputInterceptors.class.isAssignableFrom(interceptorClazz)) { DataInputInterceptors instance; try { instance = (DataInputInterceptors) interceptorClazz.newInstance(); } catch (InstantiationException e) { LOGGER.warn("Could not instantiate class "+ interceptorClazz, e); return result; } catch (IllegalAccessException e) { LOGGER.warn("Could not access class "+ interceptorClazz, e); return result; } return instance.getInterceptors(); } } return result; } } | InputHandler { Map<String, InterceptorInstance> resolveInputInterceptors(String algorithmClassName) { Map<String,InterceptorInstance> result = new HashMap<String, InterceptorInstance>(); Class<?> clazz; try { clazz = Class.forName(algorithmClassName, false, getClass().getClassLoader()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class {}", algorithmClassName); return result; } DataInputInterceptorImplementations annotation = clazz.getAnnotation(DataInputInterceptors.DataInputInterceptorImplementations.class); if (annotation != null) { Class<?> interceptorClazz; try { interceptorClazz = Class.forName(annotation.value()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class "+ annotation.value(), e); return result; } if (DataInputInterceptors.class.isAssignableFrom(interceptorClazz)) { DataInputInterceptors instance; try { instance = (DataInputInterceptors) interceptorClazz.newInstance(); } catch (InstantiationException e) { LOGGER.warn("Could not instantiate class "+ interceptorClazz, e); return result; } catch (IllegalAccessException e) { LOGGER.warn("Could not access class "+ interceptorClazz, e); return result; } return instance.getInterceptors(); } } return result; } private InputHandler(Builder builder); } | InputHandler { Map<String, InterceptorInstance> resolveInputInterceptors(String algorithmClassName) { Map<String,InterceptorInstance> result = new HashMap<String, InterceptorInstance>(); Class<?> clazz; try { clazz = Class.forName(algorithmClassName, false, getClass().getClassLoader()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class {}", algorithmClassName); return result; } DataInputInterceptorImplementations annotation = clazz.getAnnotation(DataInputInterceptors.DataInputInterceptorImplementations.class); if (annotation != null) { Class<?> interceptorClazz; try { interceptorClazz = Class.forName(annotation.value()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class "+ annotation.value(), e); return result; } if (DataInputInterceptors.class.isAssignableFrom(interceptorClazz)) { DataInputInterceptors instance; try { instance = (DataInputInterceptors) interceptorClazz.newInstance(); } catch (InstantiationException e) { LOGGER.warn("Could not instantiate class "+ interceptorClazz, e); return result; } catch (IllegalAccessException e) { LOGGER.warn("Could not access class "+ interceptorClazz, e); return result; } return instance.getInterceptors(); } } return result; } private InputHandler(Builder builder); Map<String, List<IData>> getParsedInputData(); } | InputHandler { Map<String, InterceptorInstance> resolveInputInterceptors(String algorithmClassName) { Map<String,InterceptorInstance> result = new HashMap<String, InterceptorInstance>(); Class<?> clazz; try { clazz = Class.forName(algorithmClassName, false, getClass().getClassLoader()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class {}", algorithmClassName); return result; } DataInputInterceptorImplementations annotation = clazz.getAnnotation(DataInputInterceptors.DataInputInterceptorImplementations.class); if (annotation != null) { Class<?> interceptorClazz; try { interceptorClazz = Class.forName(annotation.value()); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find class "+ annotation.value(), e); return result; } if (DataInputInterceptors.class.isAssignableFrom(interceptorClazz)) { DataInputInterceptors instance; try { instance = (DataInputInterceptors) interceptorClazz.newInstance(); } catch (InstantiationException e) { LOGGER.warn("Could not instantiate class "+ interceptorClazz, e); return result; } catch (IllegalAccessException e) { LOGGER.warn("Could not access class "+ interceptorClazz, e); return result; } return instance.getInterceptors(); } } return result; } private InputHandler(Builder builder); Map<String, List<IData>> getParsedInputData(); } |
@Test public void testGetMimeTypeComplexOutputResponseDoc() { try { String sampleFileName = "src/test/resources/DTCExecuteComplexOutputResponseDocMimeTiff.xml"; File sampleFile = new File(sampleFileName); FileInputStream is; is = new FileInputStream(sampleFile); Document doc; doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); OutputDefinitionType definition = executeRequest.getExecute().getResponseForm().getResponseDocument().getOutputArray(0); String originalMimeType = definition.getMimeType(); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(definition); assertTrue(mimeType.equals(originalMimeType)); } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testGetMimeTypeMultipleComplexOutputsResponseDocPerm1() { try { String sampleFileName = "src/test/resources/MCIODTCExecuteComplexOutputResponseDocPerm1.xml"; File sampleFile = new File(sampleFileName); FileInputStream is; is = new FileInputStream(sampleFile); Document doc; doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); DocumentOutputDefinitionType[] outputs = executeRequest.getExecute().getResponseForm().getResponseDocument().getOutputArray(); for (DocumentOutputDefinitionType documentOutputDefinitionType : outputs) { String identifier = documentOutputDefinitionType.getIdentifier().getStringValue(); String originalMimeType = documentOutputDefinitionType.getMimeType(); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(documentOutputDefinitionType); if(identifier.contains("Complex")){ assertTrue(mimeType.equals(originalMimeType)); }else{ assertTrue(mimeType.equals("text/plain") || mimeType.equals("text/xml")); } } } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testGetMimeTypeMultipleComplexOutputsResponseDocPerm2() { try { String sampleFileName = "src/test/resources/MCIODTCExecuteComplexOutputResponseDocPerm2.xml"; File sampleFile = new File(sampleFileName); FileInputStream is; is = new FileInputStream(sampleFile); Document doc; doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); DocumentOutputDefinitionType[] outputs = executeRequest.getExecute().getResponseForm().getResponseDocument().getOutputArray(); for (DocumentOutputDefinitionType documentOutputDefinitionType : outputs) { String identifier = documentOutputDefinitionType.getIdentifier().getStringValue(); String originalMimeType = documentOutputDefinitionType.getMimeType(); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(documentOutputDefinitionType); if(identifier.contains("Complex")){ assertTrue(mimeType.equals(originalMimeType)); }else{ assertTrue(mimeType.equals("text/plain") || mimeType.equals("text/xml")); } } } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testGetMimeTypeBBOXOutputResponseDoc() { try { String sampleFileName = "src/test/resources/DTCExecuteBBOXOutputResponseDoc.xml"; File sampleFile = new File(sampleFileName); FileInputStream is; is = new FileInputStream(sampleFile); Document doc; doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); OutputDefinitionType definition = executeRequest.getExecute().getResponseForm().getResponseDocument().getOutputArray(0); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(definition); assertTrue(mimeType.equals("text/xml")); } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testGetMimeTypeBBOXOutputRawData() { try { String sampleFileName = "src/test/resources/DTCExecuteBBOXOutputRawData.xml"; File sampleFile = new File(sampleFileName); FileInputStream is; is = new FileInputStream(sampleFile); Document doc; doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); OutputDefinitionType definition = executeRequest.getExecute().getResponseForm().getRawDataOutput(); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(definition); assertTrue(mimeType.equals("text/xml")); } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testConstructor() { ExecutionContext ec; ec = new ExecutionContext((OutputDefinitionType)null); assertNotNull(ec.getOutputs()); assertEquals(0, ec.getOutputs().size()); ec = new ExecutionContext(Arrays.asList(new OutputDefinitionType[0])); assertNotNull(ec.getOutputs()); assertEquals(0, ec.getOutputs().size()); ec = new ExecutionContext(Arrays.asList(new OutputDefinitionType[1])); assertNotNull(ec.getOutputs()); assertEquals(1, ec.getOutputs().size()); ec = new ExecutionContext((List<OutputDefinitionType>)null); assertNotNull(ec.getOutputs()); assertEquals(0, ec.getOutputs().size()); ec = new ExecutionContext(OutputDefinitionType.Factory.newInstance()); assertNotNull(ec.getOutputs()); assertEquals(1, ec.getOutputs().size()); ec = new ExecutionContext(); assertNotNull(ec.getOutputs()); assertEquals(0, ec.getOutputs().size()); } | public List<OutputDefinitionType> getOutputs() { return this.outputDefinitionTypes; } | ExecutionContext { public List<OutputDefinitionType> getOutputs() { return this.outputDefinitionTypes; } } | ExecutionContext { public List<OutputDefinitionType> getOutputs() { return this.outputDefinitionTypes; } ExecutionContext(); ExecutionContext(OutputDefinitionType output); ExecutionContext(List< ? extends OutputDefinitionType> outputs); } | ExecutionContext { public List<OutputDefinitionType> getOutputs() { return this.outputDefinitionTypes; } ExecutionContext(); ExecutionContext(OutputDefinitionType output); ExecutionContext(List< ? extends OutputDefinitionType> outputs); String getTempDirectoryPath(); List<OutputDefinitionType> getOutputs(); } | ExecutionContext { public List<OutputDefinitionType> getOutputs() { return this.outputDefinitionTypes; } ExecutionContext(); ExecutionContext(OutputDefinitionType output); ExecutionContext(List< ? extends OutputDefinitionType> outputs); String getTempDirectoryPath(); List<OutputDefinitionType> getOutputs(); } |
@Test public void testInputHandlerResolveInputDescriptionTypes() throws ExceptionReport, XmlException, IOException { System.out.println("Testing testInputHandlerResolveInputDescriptionTypes..."); InputHandler instance = new InputHandler.Builder(simpleBufferAlgorithmInputArray, "org.n52.wps.server.algorithm.SimpleBufferAlgorithm").build(); InputDescriptionType idt = instance.getInputReferenceDescriptionType("data"); assertThat(idt, is(notNullValue())); assertThat(idt.getMaxOccurs().intValue(), equalTo(1)); assertThat(idt.getMinOccurs().intValue(), equalTo(1)); instance = new InputHandler.Builder(dummyTestClassAlgorithmInputArray, "org.n52.wps.server.algorithm.test.DummyTestClass").build(); idt = instance.getInputReferenceDescriptionType("BBOXInputData"); assertThat(idt, is(notNullValue())); assertThat(idt.getMaxOccurs().intValue(), equalTo(1)); assertThat(idt.getMinOccurs().intValue(), equalTo(0)); } | InputDescriptionType getInputReferenceDescriptionType(String inputId) { for (InputDescriptionType tempDesc : this.processDesc.getDataInputs().getInputArray()) { if (inputId.equals(tempDesc.getIdentifier().getStringValue())) { return tempDesc; } } return null; } | InputHandler { InputDescriptionType getInputReferenceDescriptionType(String inputId) { for (InputDescriptionType tempDesc : this.processDesc.getDataInputs().getInputArray()) { if (inputId.equals(tempDesc.getIdentifier().getStringValue())) { return tempDesc; } } return null; } } | InputHandler { InputDescriptionType getInputReferenceDescriptionType(String inputId) { for (InputDescriptionType tempDesc : this.processDesc.getDataInputs().getInputArray()) { if (inputId.equals(tempDesc.getIdentifier().getStringValue())) { return tempDesc; } } return null; } private InputHandler(Builder builder); } | InputHandler { InputDescriptionType getInputReferenceDescriptionType(String inputId) { for (InputDescriptionType tempDesc : this.processDesc.getDataInputs().getInputArray()) { if (inputId.equals(tempDesc.getIdentifier().getStringValue())) { return tempDesc; } } return null; } private InputHandler(Builder builder); Map<String, List<IData>> getParsedInputData(); } | InputHandler { InputDescriptionType getInputReferenceDescriptionType(String inputId) { for (InputDescriptionType tempDesc : this.processDesc.getDataInputs().getInputArray()) { if (inputId.equals(tempDesc.getIdentifier().getStringValue())) { return tempDesc; } } return null; } private InputHandler(Builder builder); Map<String, List<IData>> getParsedInputData(); } |
@Test public void testInputHandlerGetComplexValueNodeString() throws ExceptionReport, XmlException, IOException { System.out.println("Testing testInputHandlerGetComplexValueNodeString..."); InputHandler instance = new InputHandler.Builder(simpleBufferAlgorithmInputArray, "org.n52.wps.server.algorithm.SimpleBufferAlgorithm").build(); String result = instance.getComplexValueNodeString(simpleBufferAlgorithmInputArray[0].getData().getComplexData().getDomNode()); assertThat(result, not(isEmptyOrNullString())); assertThat(result, containsString("147.25674400000003 -42.778393 147.22018400000002 -42.824776 147.179596 -42.82143 147.11132800000001 -42.795731 147.057098 -42.741581 147.00347900000003 -42.704803 146.91909800000002 -42.622734 146.91053799999997 -42.610928 146.88998400000003 -42.585396 146.83844 -42.572792 146.78569 -42.539352 146.724335 -42.485966 146.695023 -42.469582 146.64987200000002 -42.450371 146.604965 -42.432274 146.578781 -42.408531 146.539307 -42.364208 146.525055 -42.30883 146.558044 -42.275948 146.57624800000002 -42.23777 146.58146699999998 -42.203426 146.490005 -42.180222 146.3797 -42.146332 146.33406100000002 -42.138741 146.270966 -42.165703 146.197296 -42.224072 146.167908 -42.244835 146.16493200000002 -42.245171 146.111023 -42.265202 146.03747600000003 -42.239738 145.981628 -42.187851 145.85391199999998 -42.133492 145.819611 -42.129154 145.72052000000002 -42.104084 145.61857600000002 -42.056023 145.541718 -42.027241 145.48628200000002 -41.983326 145.452744 -41.926544 145.494034 -41.896477 145.59173600000003 -41.860214 145.64211999999998 -41.838398 145.669449 -41.830734 145.680923 -41.795753 145.68296800000002 -41.743221 145.67515600000002 -41.710377 145.680115 -41.688908 145.70106500000003 -41.648228 145.71479799999997 -41.609509 145.62919599999998 -41.462051 145.64889499999998 -41.470337 145.633423 -41.420902 145.631866 -41.36528 145.640854 -41.301533 145.700424 -41.242611 145.77242999999999 -41.193897 145.80233800000002 -41.161488 145.856018 -41.08007")); instance = new InputHandler.Builder(dummyTestClassAlgorithmInputArray, "org.n52.wps.server.algorithm.test.DummyTestClass").build(); result = instance.getComplexValueNodeString(dummyTestClassAlgorithmInputArray[0].getData().getBoundingBoxData().getDomNode()); assertThat(result, not(isEmptyOrNullString())); assertThat(result, containsString("46.75 13.05")); } | protected String getComplexValueNodeString(Node complexValueNode) { String complexValue; try { if(complexValueNode.getChildNodes().getLength() > 1){ complexValue = complexValueNode.getChildNodes().item(1).getNodeValue(); if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getChildNodes().item(1)); } }else{ complexValue = complexValueNode.getFirstChild().getNodeValue(); } if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getFirstChild()); } } catch (TransformerFactoryConfigurationError e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } catch (TransformerException e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } return complexValue; } | InputHandler { protected String getComplexValueNodeString(Node complexValueNode) { String complexValue; try { if(complexValueNode.getChildNodes().getLength() > 1){ complexValue = complexValueNode.getChildNodes().item(1).getNodeValue(); if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getChildNodes().item(1)); } }else{ complexValue = complexValueNode.getFirstChild().getNodeValue(); } if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getFirstChild()); } } catch (TransformerFactoryConfigurationError e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } catch (TransformerException e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } return complexValue; } } | InputHandler { protected String getComplexValueNodeString(Node complexValueNode) { String complexValue; try { if(complexValueNode.getChildNodes().getLength() > 1){ complexValue = complexValueNode.getChildNodes().item(1).getNodeValue(); if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getChildNodes().item(1)); } }else{ complexValue = complexValueNode.getFirstChild().getNodeValue(); } if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getFirstChild()); } } catch (TransformerFactoryConfigurationError e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } catch (TransformerException e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } return complexValue; } private InputHandler(Builder builder); } | InputHandler { protected String getComplexValueNodeString(Node complexValueNode) { String complexValue; try { if(complexValueNode.getChildNodes().getLength() > 1){ complexValue = complexValueNode.getChildNodes().item(1).getNodeValue(); if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getChildNodes().item(1)); } }else{ complexValue = complexValueNode.getFirstChild().getNodeValue(); } if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getFirstChild()); } } catch (TransformerFactoryConfigurationError e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } catch (TransformerException e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } return complexValue; } private InputHandler(Builder builder); Map<String, List<IData>> getParsedInputData(); } | InputHandler { protected String getComplexValueNodeString(Node complexValueNode) { String complexValue; try { if(complexValueNode.getChildNodes().getLength() > 1){ complexValue = complexValueNode.getChildNodes().item(1).getNodeValue(); if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getChildNodes().item(1)); } }else{ complexValue = complexValueNode.getFirstChild().getNodeValue(); } if(complexValue == null){ return XMLUtil.nodeToString(complexValueNode.getFirstChild()); } } catch (TransformerFactoryConfigurationError e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } catch (TransformerException e1) { throw new TransformerFactoryConfigurationError("Could not parse inline data. Reason " + e1); } return complexValue; } private InputHandler(Builder builder); Map<String, List<IData>> getParsedInputData(); } |
@Test public void testUpdateStatusError() throws ExceptionReport, XmlException, IOException, SAXException, ParserConfigurationException { FileInputStream fis = new FileInputStream(new File("src/test/resources/LRDTCCorruptInputResponseDocStatusTrue.xml")); Document doc = fac.newDocumentBuilder().parse(fis); ExecuteRequest request = new ExecuteRequest(doc); String exceptionText = "TestError"; request.updateStatusError(exceptionText); File response = DatabaseFactory.getDatabase().lookupResponseAsFile(request.getUniqueId().toString()); ExecuteResponseDocument responseDoc = ExecuteResponseDocument.Factory.parse(response); StatusType statusType = responseDoc.getExecuteResponse().getStatus(); assertTrue(validateExecuteResponse(responseDoc)); assertTrue(statusType.isSetProcessFailed()); assertTrue(statusType.getProcessFailed().getExceptionReport().getExceptionArray(0).getExceptionTextArray(0).equals(exceptionText)); } | public void updateStatusError(String errorMessage) { StatusType status = StatusType.Factory.newInstance(); net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport excRep = status .addNewProcessFailed().addNewExceptionReport(); excRep.setVersion("1.0.0"); ExceptionType excType = excRep.addNewException(); excType.addNewExceptionText().setStringValue(errorMessage); excType.setExceptionCode(ExceptionReport.NO_APPLICABLE_CODE); updateStatus(status); } | ExecuteRequest extends Request implements IObserver { public void updateStatusError(String errorMessage) { StatusType status = StatusType.Factory.newInstance(); net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport excRep = status .addNewProcessFailed().addNewExceptionReport(); excRep.setVersion("1.0.0"); ExceptionType excType = excRep.addNewException(); excType.addNewExceptionText().setStringValue(errorMessage); excType.setExceptionCode(ExceptionReport.NO_APPLICABLE_CODE); updateStatus(status); } } | ExecuteRequest extends Request implements IObserver { public void updateStatusError(String errorMessage) { StatusType status = StatusType.Factory.newInstance(); net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport excRep = status .addNewProcessFailed().addNewExceptionReport(); excRep.setVersion("1.0.0"); ExceptionType excType = excRep.addNewException(); excType.addNewExceptionText().setStringValue(errorMessage); excType.setExceptionCode(ExceptionReport.NO_APPLICABLE_CODE); updateStatus(status); } ExecuteRequest(Document doc); ExecuteRequest(CaseInsensitiveMap ciMap); } | ExecuteRequest extends Request implements IObserver { public void updateStatusError(String errorMessage) { StatusType status = StatusType.Factory.newInstance(); net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport excRep = status .addNewProcessFailed().addNewExceptionReport(); excRep.setVersion("1.0.0"); ExceptionType excType = excRep.addNewException(); excType.addNewExceptionText().setStringValue(errorMessage); excType.setExceptionCode(ExceptionReport.NO_APPLICABLE_CODE); updateStatus(status); } ExecuteRequest(Document doc); ExecuteRequest(CaseInsensitiveMap ciMap); void getKVPDataInputs(); boolean validate(); Response call(); String getAlgorithmIdentifier(); Execute getExecute(); Map<String, IData> getAttachedResult(); boolean isStoreResponse(); boolean isQuickStatus(); ExecuteResponseBuilder getExecuteResponseBuilder(); boolean isRawData(); void update(ISubject subject); void updateStatusAccepted(); void updateStatusStarted(); void updateStatusSuccess(); void updateStatusError(String errorMessage); } | ExecuteRequest extends Request implements IObserver { public void updateStatusError(String errorMessage) { StatusType status = StatusType.Factory.newInstance(); net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport excRep = status .addNewProcessFailed().addNewExceptionReport(); excRep.setVersion("1.0.0"); ExceptionType excType = excRep.addNewException(); excType.addNewExceptionText().setStringValue(errorMessage); excType.setExceptionCode(ExceptionReport.NO_APPLICABLE_CODE); updateStatus(status); } ExecuteRequest(Document doc); ExecuteRequest(CaseInsensitiveMap ciMap); void getKVPDataInputs(); boolean validate(); Response call(); String getAlgorithmIdentifier(); Execute getExecute(); Map<String, IData> getAttachedResult(); boolean isStoreResponse(); boolean isQuickStatus(); ExecuteResponseBuilder getExecuteResponseBuilder(); boolean isRawData(); void update(ISubject subject); void updateStatusAccepted(); void updateStatusStarted(); void updateStatusSuccess(); void updateStatusError(String errorMessage); } |
@Test public void testUpdateResponseForLiteralData() { for (ILiteralData literalData : literalDataList) { try { testLiteralOutput(literalData); } catch (Exception e) { System.out.println("Test failed for " + literalData.getClass() + " " + e); } mockupResponseDocument.getExecuteResponse().getProcessOutputs() .removeOutput(0); } } | public void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference){ OutputDataType output = prepareOutput(res); String processValue = BasicXMLTypeFactory.getStringRepresentation(dataTypeReference, obj); LiteralDataType literalData = output.addNewData().addNewLiteralData(); if (dataTypeReference != null) { literalData.setDataType(dataTypeReference); } literalData.setStringValue(processValue); if(obj instanceof AbstractLiteralDataBinding){ String uom = ((AbstractLiteralDataBinding)obj).getUnitOfMeasurement(); if(uom != null && !uom.equals("")){ literalData.setUom(uom); } } } | OutputDataItem extends ResponseData { public void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference){ OutputDataType output = prepareOutput(res); String processValue = BasicXMLTypeFactory.getStringRepresentation(dataTypeReference, obj); LiteralDataType literalData = output.addNewData().addNewLiteralData(); if (dataTypeReference != null) { literalData.setDataType(dataTypeReference); } literalData.setStringValue(processValue); if(obj instanceof AbstractLiteralDataBinding){ String uom = ((AbstractLiteralDataBinding)obj).getUnitOfMeasurement(); if(uom != null && !uom.equals("")){ literalData.setUom(uom); } } } } | OutputDataItem extends ResponseData { public void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference){ OutputDataType output = prepareOutput(res); String processValue = BasicXMLTypeFactory.getStringRepresentation(dataTypeReference, obj); LiteralDataType literalData = output.addNewData().addNewLiteralData(); if (dataTypeReference != null) { literalData.setDataType(dataTypeReference); } literalData.setStringValue(processValue); if(obj instanceof AbstractLiteralDataBinding){ String uom = ((AbstractLiteralDataBinding)obj).getUnitOfMeasurement(); if(uom != null && !uom.equals("")){ literalData.setUom(uom); } } } OutputDataItem(IData obj, String id, String schema, String encoding,
String mimeType, LanguageStringType title, String algorithmIdentifier, ProcessDescriptionType description); } | OutputDataItem extends ResponseData { public void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference){ OutputDataType output = prepareOutput(res); String processValue = BasicXMLTypeFactory.getStringRepresentation(dataTypeReference, obj); LiteralDataType literalData = output.addNewData().addNewLiteralData(); if (dataTypeReference != null) { literalData.setDataType(dataTypeReference); } literalData.setStringValue(processValue); if(obj instanceof AbstractLiteralDataBinding){ String uom = ((AbstractLiteralDataBinding)obj).getUnitOfMeasurement(); if(uom != null && !uom.equals("")){ literalData.setUom(uom); } } } OutputDataItem(IData obj, String id, String schema, String encoding,
String mimeType, LanguageStringType title, String algorithmIdentifier, ProcessDescriptionType description); void updateResponseForInlineComplexData(ExecuteResponseDocument res); void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference); void updateResponseAsReference(ExecuteResponseDocument res, String reqID, String mimeType); void updateResponseForBBOXData(ExecuteResponseDocument res, IBBOXData bbox); } | OutputDataItem extends ResponseData { public void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference){ OutputDataType output = prepareOutput(res); String processValue = BasicXMLTypeFactory.getStringRepresentation(dataTypeReference, obj); LiteralDataType literalData = output.addNewData().addNewLiteralData(); if (dataTypeReference != null) { literalData.setDataType(dataTypeReference); } literalData.setStringValue(processValue); if(obj instanceof AbstractLiteralDataBinding){ String uom = ((AbstractLiteralDataBinding)obj).getUnitOfMeasurement(); if(uom != null && !uom.equals("")){ literalData.setUom(uom); } } } OutputDataItem(IData obj, String id, String schema, String encoding,
String mimeType, LanguageStringType title, String algorithmIdentifier, ProcessDescriptionType description); void updateResponseForInlineComplexData(ExecuteResponseDocument res); void updateResponseForLiteralData(ExecuteResponseDocument res, String dataTypeReference); void updateResponseAsReference(ExecuteResponseDocument res, String reqID, String mimeType); void updateResponseForBBOXData(ExecuteResponseDocument res, IBBOXData bbox); } |
@Test public void testBBoxRawDataOutputCRS(){ IData envelope = new BoundingBoxData( new double[] { 46, 102 }, new double[] { 47, 103 }, "EPSG:4326"); InputStream is; try { RawData bboxRawData = new RawData(envelope, "BBOXOutputData", null, null, null, identifier, processDescription); is = bboxRawData.getAsStream(); XmlObject bboxXMLObject = XmlObject.Factory.parse(is); assertTrue(bboxXMLObject != null); assertTrue(bboxXMLObject.getDomNode().getFirstChild().getNodeName().equals("wps:BoundingBoxData")); } catch (Exception e) { fail(e.getMessage()); } } | public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
String mimeType, String algorithmIdentifier,
ProcessDescriptionType description); } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
String mimeType, String algorithmIdentifier,
ProcessDescriptionType description); InputStream getAsStream(); } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
String mimeType, String algorithmIdentifier,
ProcessDescriptionType description); InputStream getAsStream(); static final Joiner SPACE_JOINER; } |
@Test public void testBBoxRawDataOutput(){ IData envelope = new BoundingBoxData( new double[] { 46, 102 }, new double[] { 47, 103 }, null); InputStream is; try { RawData bboxRawData = new RawData(envelope, "BBOXOutputData", null, null, null, identifier, processDescription); is = bboxRawData.getAsStream(); XmlObject bboxXMLObject = XmlObject.Factory.parse(is); assertTrue(bboxXMLObject != null); assertTrue(bboxXMLObject.getDomNode().getFirstChild().getNodeName().equals("wps:BoundingBoxData")); } catch (Exception e) { fail(e.getMessage()); } } | public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
String mimeType, String algorithmIdentifier,
ProcessDescriptionType description); } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
String mimeType, String algorithmIdentifier,
ProcessDescriptionType description); InputStream getAsStream(); } | RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
String mimeType, String algorithmIdentifier,
ProcessDescriptionType description); InputStream getAsStream(); static final Joiner SPACE_JOINER; } |
@Test public void testGetMimeTypeLiteralOutputResponseDoc() { try { String sampleFileName = "src/test/resources/DTCExecuteLiteralOutputResponseDoc.xml"; File sampleFile = new File(sampleFileName); FileInputStream is = new FileInputStream(sampleFile); Document doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); OutputDefinitionType definition = executeRequest.getExecute().getResponseForm().getResponseDocument().getOutputArray(0); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(definition); assertTrue(mimeType.equals("text/plain")); } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testGetMimeTypeLiteralOutputRawData() { try { String sampleFileName = "src/test/resources/DTCExecuteLiteralOutputRawData.xml"; File sampleFile = new File(sampleFileName); FileInputStream is = new FileInputStream(sampleFile); Document doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); OutputDefinitionType definition = executeRequest.getExecute().getResponseForm().getRawDataOutput(); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(definition); assertTrue(mimeType.equals("text/plain")); } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void testGetMimeTypeComplexOutputRawData() { try { String sampleFileName = "src/test/resources/DTCExecuteComplexOutputRawDataMimeTiff.xml"; File sampleFile = new File(sampleFileName); FileInputStream is; is = new FileInputStream(sampleFile); Document doc; doc = fac.newDocumentBuilder().parse(is); is.close(); executeRequest = new ExecuteRequest(doc); OutputDefinitionType definition = executeRequest.getExecute().getResponseForm().getRawDataOutput(); String originalMimeType = definition.getMimeType(); String mimeType = executeRequest.getExecuteResponseBuilder() .getMimeType(definition); assertTrue(mimeType.equals(originalMimeType)); } catch (Exception e) { fail(e.getMessage()); } } | public String getMimeType() { return getMimeType(null); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } | ExecuteResponseBuilder { public String getMimeType() { return getMimeType(null); } ExecuteResponseBuilder(ExecuteRequest request); void update(); String getMimeType(); String getMimeType(OutputDefinitionType def); InputStream getAsStream(); void setStatus(StatusType status); } |
@Test public void init_isCalled() { spyViewModel.init(); verify(rightMeshConnector).setOnConnectSuccessListener(any()); verify(rightMeshConnector).setOnPeerChangedListener(any()); verify(rightMeshConnector).setOnDataReceiveListener(any()); verify(spyViewModel).init(); } | void init() { rmConnector.connect(getApplication()); rmConnector.setOnDataReceiveListener(event -> receiveColourMessage(event)); rmConnector.setOnPeerChangedListener(event -> liveDataPeerChangedEvent.postValue(event)); rmConnector.setOnConnectSuccessListener(meshId -> liveDataMyMeshId.setValue(meshId)); } | MainViewModel extends AndroidViewModel { void init() { rmConnector.connect(getApplication()); rmConnector.setOnDataReceiveListener(event -> receiveColourMessage(event)); rmConnector.setOnPeerChangedListener(event -> liveDataPeerChangedEvent.postValue(event)); rmConnector.setOnConnectSuccessListener(meshId -> liveDataMyMeshId.setValue(meshId)); } } | MainViewModel extends AndroidViewModel { void init() { rmConnector.connect(getApplication()); rmConnector.setOnDataReceiveListener(event -> receiveColourMessage(event)); rmConnector.setOnPeerChangedListener(event -> liveDataPeerChangedEvent.postValue(event)); rmConnector.setOnConnectSuccessListener(meshId -> liveDataMyMeshId.setValue(meshId)); } MainViewModel(@NonNull Application application); } | MainViewModel extends AndroidViewModel { void init() { rmConnector.connect(getApplication()); rmConnector.setOnDataReceiveListener(event -> receiveColourMessage(event)); rmConnector.setOnPeerChangedListener(event -> liveDataPeerChangedEvent.postValue(event)); rmConnector.setOnConnectSuccessListener(meshId -> liveDataMyMeshId.setValue(meshId)); } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } | MainViewModel extends AndroidViewModel { void init() { rmConnector.connect(getApplication()); rmConnector.setOnDataReceiveListener(event -> receiveColourMessage(event)); rmConnector.setOnPeerChangedListener(event -> liveDataPeerChangedEvent.postValue(event)); rmConnector.setOnConnectSuccessListener(meshId -> liveDataMyMeshId.setValue(meshId)); } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } |
@Test public void toRightMeshWalletActivty_isCalled() throws RightMeshException { spyViewModel.toRightMeshWalletActivty(); verify(rightMeshConnector).toRightMeshWalletActivty(); verify(spyViewModel).toRightMeshWalletActivty(); } | void toRightMeshWalletActivty() { try { rmConnector.toRightMeshWalletActivty(); } catch (RightMeshException e) { Log.e(TAG, e.toString()); } } | MainViewModel extends AndroidViewModel { void toRightMeshWalletActivty() { try { rmConnector.toRightMeshWalletActivty(); } catch (RightMeshException e) { Log.e(TAG, e.toString()); } } } | MainViewModel extends AndroidViewModel { void toRightMeshWalletActivty() { try { rmConnector.toRightMeshWalletActivty(); } catch (RightMeshException e) { Log.e(TAG, e.toString()); } } MainViewModel(@NonNull Application application); } | MainViewModel extends AndroidViewModel { void toRightMeshWalletActivty() { try { rmConnector.toRightMeshWalletActivty(); } catch (RightMeshException e) { Log.e(TAG, e.toString()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } | MainViewModel extends AndroidViewModel { void toRightMeshWalletActivty() { try { rmConnector.toRightMeshWalletActivty(); } catch (RightMeshException e) { Log.e(TAG, e.toString()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } |
@Test public void sendColorMsg_nullTargetMeshId() throws RightMeshException { MeshId targetId = null; Colour msgColor = Colour.RED; String payload = String.valueOf(targetId) + ":" + msgColor; spyViewModel.sendColorMsg(targetId, msgColor); verify(rightMeshConnector, never()).sendDataReliable(targetId, payload); verify(spyViewModel).sendColorMsg(targetId, msgColor); } | void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } MainViewModel(@NonNull Application application); } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } |
@Test public void sendColorMsg_targetMeshId() throws RightMeshException { MeshId targetId = mockMeshId; Colour msgColor = Colour.RED; String payload = String.valueOf(targetId) + ":" + msgColor; spyViewModel.sendColorMsg(targetId, msgColor); verify(rightMeshConnector).sendDataReliable(targetId, payload); verify(spyViewModel).sendColorMsg(targetId, msgColor); } | void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } MainViewModel(@NonNull Application application); } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } | MainViewModel extends AndroidViewModel { void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while sending data, with message: " + sde.getMessage()); liveDataNotification.setValue(sde.getMessage()); } catch (RightMeshRuntimeException.RightMeshLicenseException le) { Log.e(TAG, le.getMessage()); liveDataNotification.setValue(le.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "Unable to find next hop to peer, with message: " + rme.getMessage()); liveDataNotification.setValue(rme.getMessage()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } |
@Test public void onCleared_isCalled() throws RightMeshException { spyViewModel.onCleared(); verify(rightMeshConnector).stop(); verify(spyViewModel).onCleared(); } | @Override protected void onCleared() { try { rmConnector.stop(); } catch (RightMeshException.RightMeshServiceDisconnectedException e) { Log.e(TAG, "Service disconnected before stopping AndroidMeshManager with message" + e.getMessage()); } } | MainViewModel extends AndroidViewModel { @Override protected void onCleared() { try { rmConnector.stop(); } catch (RightMeshException.RightMeshServiceDisconnectedException e) { Log.e(TAG, "Service disconnected before stopping AndroidMeshManager with message" + e.getMessage()); } } } | MainViewModel extends AndroidViewModel { @Override protected void onCleared() { try { rmConnector.stop(); } catch (RightMeshException.RightMeshServiceDisconnectedException e) { Log.e(TAG, "Service disconnected before stopping AndroidMeshManager with message" + e.getMessage()); } } MainViewModel(@NonNull Application application); } | MainViewModel extends AndroidViewModel { @Override protected void onCleared() { try { rmConnector.stop(); } catch (RightMeshException.RightMeshServiceDisconnectedException e) { Log.e(TAG, "Service disconnected before stopping AndroidMeshManager with message" + e.getMessage()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } | MainViewModel extends AndroidViewModel { @Override protected void onCleared() { try { rmConnector.stop(); } catch (RightMeshException.RightMeshServiceDisconnectedException e) { Log.e(TAG, "Service disconnected before stopping AndroidMeshManager with message" + e.getMessage()); } } MainViewModel(@NonNull Application application); void setRightMeshConnector(RightMeshConnector rmConnector); } |
@Test public void meshStateChanged_successEvent() throws RightMeshException, ClassNotFoundException { spyRightMeshConnector.meshStateChanged(meshId, MeshStateListener.SUCCESS); verify(androidMeshManager).bind(MESH_PORT); verify(spyRightMeshConnector).meshStateChanged(meshId, MeshStateListener.SUCCESS); } | @Override public void meshStateChanged(MeshId meshId, int state) { if (state == SUCCESS) { try { androidMeshManager.bind(meshPort); if (connectSuccessListener != null) { connectSuccessListener.onConnectSuccess(meshId); } androidMeshManager.on(DATA_RECEIVED, event -> { if (dataReceiveListener != null) { dataReceiveListener.onDataReceive(event); } }); androidMeshManager.on(PEER_CHANGED, event -> { if (peerchangedListener != null) { peerchangedListener.onPeerChange(event); } }); } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while binding, with message: " + sde.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "MeshPort already bound, with message: " + rme.getMessage()); } } } | RightMeshConnector implements MeshStateListener { @Override public void meshStateChanged(MeshId meshId, int state) { if (state == SUCCESS) { try { androidMeshManager.bind(meshPort); if (connectSuccessListener != null) { connectSuccessListener.onConnectSuccess(meshId); } androidMeshManager.on(DATA_RECEIVED, event -> { if (dataReceiveListener != null) { dataReceiveListener.onDataReceive(event); } }); androidMeshManager.on(PEER_CHANGED, event -> { if (peerchangedListener != null) { peerchangedListener.onPeerChange(event); } }); } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while binding, with message: " + sde.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "MeshPort already bound, with message: " + rme.getMessage()); } } } } | RightMeshConnector implements MeshStateListener { @Override public void meshStateChanged(MeshId meshId, int state) { if (state == SUCCESS) { try { androidMeshManager.bind(meshPort); if (connectSuccessListener != null) { connectSuccessListener.onConnectSuccess(meshId); } androidMeshManager.on(DATA_RECEIVED, event -> { if (dataReceiveListener != null) { dataReceiveListener.onDataReceive(event); } }); androidMeshManager.on(PEER_CHANGED, event -> { if (peerchangedListener != null) { peerchangedListener.onPeerChange(event); } }); } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while binding, with message: " + sde.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "MeshPort already bound, with message: " + rme.getMessage()); } } } RightMeshConnector(int meshPort); } | RightMeshConnector implements MeshStateListener { @Override public void meshStateChanged(MeshId meshId, int state) { if (state == SUCCESS) { try { androidMeshManager.bind(meshPort); if (connectSuccessListener != null) { connectSuccessListener.onConnectSuccess(meshId); } androidMeshManager.on(DATA_RECEIVED, event -> { if (dataReceiveListener != null) { dataReceiveListener.onDataReceive(event); } }); androidMeshManager.on(PEER_CHANGED, event -> { if (peerchangedListener != null) { peerchangedListener.onPeerChange(event); } }); } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while binding, with message: " + sde.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "MeshPort already bound, with message: " + rme.getMessage()); } } } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } | RightMeshConnector implements MeshStateListener { @Override public void meshStateChanged(MeshId meshId, int state) { if (state == SUCCESS) { try { androidMeshManager.bind(meshPort); if (connectSuccessListener != null) { connectSuccessListener.onConnectSuccess(meshId); } androidMeshManager.on(DATA_RECEIVED, event -> { if (dataReceiveListener != null) { dataReceiveListener.onDataReceive(event); } }); androidMeshManager.on(PEER_CHANGED, event -> { if (peerchangedListener != null) { peerchangedListener.onPeerChange(event); } }); } catch (RightMeshException.RightMeshServiceDisconnectedException sde) { Log.e(TAG, "Service disconnected while binding, with message: " + sde.getMessage()); } catch (RightMeshException rme) { Log.e(TAG, "MeshPort already bound, with message: " + rme.getMessage()); } } } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } |
@Test public void stop_isCalled() throws RightMeshException.RightMeshServiceDisconnectedException { spyRightMeshConnector.stop(); verify(androidMeshManager).stop(); verify(spyRightMeshConnector).stop(); } | public void stop() throws RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.stop(); } | RightMeshConnector implements MeshStateListener { public void stop() throws RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.stop(); } } | RightMeshConnector implements MeshStateListener { public void stop() throws RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.stop(); } RightMeshConnector(int meshPort); } | RightMeshConnector implements MeshStateListener { public void stop() throws RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.stop(); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } | RightMeshConnector implements MeshStateListener { public void stop() throws RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.stop(); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } |
@Test public void toRightMeshWalletActivty_isCalled() throws RightMeshException { spyRightMeshConnector.toRightMeshWalletActivty(); verify(androidMeshManager).showSettingsActivity(); verify(spyRightMeshConnector).toRightMeshWalletActivty(); } | public void toRightMeshWalletActivty() throws RightMeshException { this.androidMeshManager.showSettingsActivity(); } | RightMeshConnector implements MeshStateListener { public void toRightMeshWalletActivty() throws RightMeshException { this.androidMeshManager.showSettingsActivity(); } } | RightMeshConnector implements MeshStateListener { public void toRightMeshWalletActivty() throws RightMeshException { this.androidMeshManager.showSettingsActivity(); } RightMeshConnector(int meshPort); } | RightMeshConnector implements MeshStateListener { public void toRightMeshWalletActivty() throws RightMeshException { this.androidMeshManager.showSettingsActivity(); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } | RightMeshConnector implements MeshStateListener { public void toRightMeshWalletActivty() throws RightMeshException { this.androidMeshManager.showSettingsActivity(); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } |
@Test public void sendDataReliable_isCalled() throws RightMeshException { String payload = "abc"; spyRightMeshConnector.sendDataReliable(meshId, payload); verify(spyRightMeshConnector).sendDataReliable(any(), eq(payload)); } | public void sendDataReliable(MeshId targetMeshId, String payload) throws RightMeshException, RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.sendDataReliable(androidMeshManager.getNextHopPeer(targetMeshId), meshPort, payload.getBytes(Charset.forName("UTF-8"))); } | RightMeshConnector implements MeshStateListener { public void sendDataReliable(MeshId targetMeshId, String payload) throws RightMeshException, RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.sendDataReliable(androidMeshManager.getNextHopPeer(targetMeshId), meshPort, payload.getBytes(Charset.forName("UTF-8"))); } } | RightMeshConnector implements MeshStateListener { public void sendDataReliable(MeshId targetMeshId, String payload) throws RightMeshException, RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.sendDataReliable(androidMeshManager.getNextHopPeer(targetMeshId), meshPort, payload.getBytes(Charset.forName("UTF-8"))); } RightMeshConnector(int meshPort); } | RightMeshConnector implements MeshStateListener { public void sendDataReliable(MeshId targetMeshId, String payload) throws RightMeshException, RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.sendDataReliable(androidMeshManager.getNextHopPeer(targetMeshId), meshPort, payload.getBytes(Charset.forName("UTF-8"))); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } | RightMeshConnector implements MeshStateListener { public void sendDataReliable(MeshId targetMeshId, String payload) throws RightMeshException, RightMeshException.RightMeshServiceDisconnectedException { androidMeshManager.sendDataReliable(androidMeshManager.getNextHopPeer(targetMeshId), meshPort, payload.getBytes(Charset.forName("UTF-8"))); } RightMeshConnector(int meshPort); void connect(Context context); @Override void meshStateChanged(MeshId meshId, int state); void stop(); void setOnDataReceiveListener(OnDataReceiveListener listener); void setOnPeerChangedListener(OnPeerChangedListener listener); void setOnConnectSuccessListener(OnConnectSuccessListener listener); void toRightMeshWalletActivty(); void sendDataReliable(MeshId targetMeshId, String payload); void setAndroidMeshManager(AndroidMeshManager androidMeshManager); } |
Subsets and Splits