use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class VisitableDetailTest method visit.
@Test
public void visit() throws AssemblyException, ActivationException {
ApplicationDescriptor application = new Energy4Java().newApplicationModel(new ApplicationAssembler() {
@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
ApplicationAssembly app = applicationFactory.newApplicationAssembly();
app.setName("UnderTestApp");
app.withActivators(ApplicationActivator.class);
LayerAssembly layer = app.layer("LayerName");
layer.withActivators(LayerActivator.class);
ModuleAssembly module = layer.module("ModuleName");
module.withActivators(ModuleActivator.class);
return app;
}
});
ApplicationDetailDescriptor detail = createApplicationDetailDescriptor(application);
Visitor visitor = new Visitor();
detail.accept(visitor);
assertThat(visitor.events, equalTo(Arrays.asList(// Application
"visitEnter( UnderTestApp )", "visit( " + ApplicationActivator.class.getName() + " )", // Layer
"visitEnter( LayerName )", "visit( " + LayerActivator.class.getName() + " )", // Module
"visitEnter( ModuleName )", "visit( " + ModuleActivator.class.getName() + " )", // Leaving Structure
"visitLeave( ModuleName )", "visitLeave( LayerName )", "visitLeave( UnderTestApp )")));
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class SequencingConcernTest method successfulBooking.
/**
* Tests that when shipping service succeeds to make the booking generator gets called and generated value is
* returned.
*/
@Test
@Ignore("Expectations need to be figured out.")
public void successfulBooking() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(ShippingServiceTestComposite.class);
}
};
ShippingService shippingService = createMock(ShippingService.class);
Cargo cargo = createMock(Cargo.class);
Voyage voyage = createMock(Voyage.class);
HasSequence generator = createMock(HasSequence.class);
Property<Integer> sequence = createMock(Property.class);
expect(shippingService.makeBooking(cargo, voyage)).andReturn(100);
expect(generator.sequence()).andReturn(sequence).anyTimes();
expect(sequence.get()).andReturn(1000);
replay(shippingService, cargo, voyage, generator, sequence);
ShippingServiceTestComposite underTest = assembler.module().newTransient(ShippingServiceTestComposite.class);
underTest.useMock(shippingService).forClass(ShippingService.class);
underTest.useMock(generator).forClass(HasSequence.class);
assertThat("Booking result", underTest.makeBooking(cargo, voyage), is(equalTo(1000)));
verify(shippingService, cargo, voyage, generator, sequence);
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class HelloWorldTest method setUp.
@Before
public void setUp() throws Exception {
SingletonAssembler assembly = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(HelloWorldComposite.class);
}
};
helloWorld = assembly.module().newTransientBuilder(HelloWorldComposite.class).newInstance();
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class SchoolAssembler method createInfrastructureLayer.
private LayerAssembly createInfrastructureLayer(ApplicationAssembly appAssembly) throws AssemblyException {
LayerAssembly layerInfrastructure = appAssembly.layer("Infrastructure");
ModuleAssembly moduleMail = layerInfrastructure.module("Mail");
new MailServiceAssembler().assemble(moduleMail);
ModuleAssembly modulePersistence = layerInfrastructure.module("Persistence");
new PersistenceAssembler().assemble(modulePersistence);
return layerInfrastructure;
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class SchoolAssembler method createDomainLayer.
private LayerAssembly createDomainLayer(ApplicationAssembly appAssembly) throws AssemblyException {
LayerAssembly layerDomain = appAssembly.layer("domain");
ModuleAssembly modulePerson = layerDomain.module("person");
new PersonModelAssembler().assemble(modulePerson);
ModuleAssembly moduleSchool = layerDomain.module("school");
new SchoolModelAssembler().assemble(moduleSchool);
return layerDomain;
}
Aggregations