@Test public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess() throws IOException, ActivationException, AssemblyException { InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) ); ApplicationBuilder builder = ApplicationBuilder.fromJson( input ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }
@Test public void givenBuilderUseWhenBuildingApplicationExpectSuccess() throws AssemblyException, ActivationException { ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." ); builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" ); builder.withLayer( "layer2" ); builder.withLayer( "layer3" ) .withModule( "test module" ) .withAssemblers( findClasses( getClass() ).filter( matches( ".*ServiceAssembler" ) ) .collect( toList() ) ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }
@Test public void givenJsonWhenBuildingApplicationExpectSuccess() throws ActivationException, AssemblyException { ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }