use of org.qi4j.api.composite.AmbiguousTypeException in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method transientsAmbiguousDeclaration.
@Test
public void transientsAmbiguousDeclaration() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(SomeOtherFoo.class, BasicFoo.class);
}
}.module();
assertEquals(CATHEDRAL, module.newTransientBuilder(SomeOtherFoo.class).newInstance().bar());
assertEquals(BAZAR, module.newTransientBuilder(BasicFoo.class).newInstance().bar());
try {
module.newTransientBuilder(Foo.class);
fail("Ambiguous type exception not detected for Transients");
} catch (AmbiguousTypeException expected) {
}
}
use of org.qi4j.api.composite.AmbiguousTypeException in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method objectsAmbiguousDeclaration.
@Test
public void objectsAmbiguousDeclaration() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.objects(SomeOtherFooImpl.class, BasicFooImpl.class);
}
}.module();
assertEquals(CATHEDRAL, module.newObject(SomeOtherFooImpl.class).bar());
assertEquals(BAZAR, module.newObject(BasicFooImpl.class).bar());
try {
module.newObject(Foo.class);
fail("Ambiguous type exception not detected for Objects");
} catch (AmbiguousTypeException expected) {
}
}
use of org.qi4j.api.composite.AmbiguousTypeException in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method entitiesAmbiguousDeclaration.
@Test
public void entitiesAmbiguousDeclaration() throws UnitOfWorkCompletionException, ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
new EntityTestAssembler().assemble(module);
module.entities(SomeOtherFoo.class, BasicFoo.class);
}
}.module();
UnitOfWork uow = module.newUnitOfWork();
SomeOtherFoo someOtherFoo = uow.newEntityBuilder(SomeOtherFoo.class).newInstance();
BasicFoo basicFoo = uow.newEntityBuilder(BasicFoo.class).newInstance();
try {
uow.newEntityBuilder(Foo.class).newInstance();
fail("Ambiguous type exception not detected for Entities");
} catch (AmbiguousTypeException expected) {
}
// Specific Type used
assertEquals(CATHEDRAL, uow.newEntityBuilder(SomeOtherFoo.class).newInstance().bar());
// Specific Type used
assertEquals(BAZAR, uow.newEntityBuilder(BasicFoo.class).newInstance().bar());
String someOtherFooIdentity = ((Identity) someOtherFoo).identity().get();
String basicFooIdentity = ((Identity) basicFoo).identity().get();
uow.complete();
uow = module.newUnitOfWork();
assertEquals(CATHEDRAL, uow.get(SomeOtherFoo.class, someOtherFooIdentity).bar());
assertEquals(BAZAR, uow.get(BasicFoo.class, basicFooIdentity).bar());
assertEquals(CATHEDRAL, uow.get(Foo.class, someOtherFooIdentity).bar());
assertEquals(BAZAR, uow.get(Foo.class, basicFooIdentity).bar());
uow.discard();
}
use of org.qi4j.api.composite.AmbiguousTypeException in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method valuesAmbiguousDeclaration.
@Test
public void valuesAmbiguousDeclaration() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.values(SomeOtherFoo.class, BasicFoo.class);
}
}.module();
assertEquals(CATHEDRAL, module.newValueBuilder(SomeOtherFoo.class).newInstance().bar());
assertEquals(BAZAR, module.newValueBuilder(BasicFoo.class).newInstance().bar());
try {
module.newValueBuilder(Foo.class);
fail("Ambiguous type exception not detected for Values");
} catch (AmbiguousTypeException expected) {
}
}
Aggregations