use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class AssociationEqualityTest method givenValuesOfTheSameTypeAndDifferentStateWhenTestingAssociationEqualityExpectNotEquals.
@Test
public void givenValuesOfTheSameTypeAndDifferentStateWhenTestingAssociationEqualityExpectNotEquals() {
UnitOfWork uow = module.newUnitOfWork();
try {
SomeWithAssociations some = buildSomeWithAssociation(uow.newEntity(AnEntity.class));
SomeWithAssociations some2 = buildSomeWithAssociation(uow.newEntity(AnEntity.class));
assertThat("Association not equal", some.anEntity(), not(equalTo(some2.anEntity())));
assertThat("Association hashcode not equal", some.anEntity().hashCode(), not(equalTo(some2.anEntity().hashCode())));
assertThat("ManyAssociation not equal", some.manyEntities(), not(equalTo(some2.manyEntities())));
assertThat("ManyAssociation hashcode not equal", some.manyEntities().hashCode(), not(equalTo(some2.manyEntities().hashCode())));
} finally {
uow.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class AssociationEqualityTest method givenValuesOfDifferentTypesAndSameStateWhenTestingAssociationEqualityExpectNotEquals.
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingAssociationEqualityExpectNotEquals() {
UnitOfWork uow = module.newUnitOfWork();
try {
AnEntity anEntity = uow.newEntity(AnEntity.class);
SomeWithAssociations some = buildSomeWithAssociation(anEntity);
OtherWithAssociations other = buildOtherWithAssociation(anEntity);
assertThat("Association not equal", some.anEntity(), not(equalTo(other.anEntity())));
assertThat("Association hashcode not equal", some.anEntity().hashCode(), not(equalTo(other.anEntity().hashCode())));
assertThat("ManyAssociation not equal", some.manyEntities(), not(equalTo(other.manyEntities())));
assertThat("ManyAssociation hashcode not equal", some.manyEntities().hashCode(), not(equalTo(other.manyEntities().hashCode())));
} finally {
uow.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class AssociationEqualityTest method givenValuesOfTheSameTypeAndSameStateWhenTestingAssociationEqualityExpectEquals.
//
// ----------------------------------:: Association equality tests ::-----------------------------------------------
//
@Test
public void givenValuesOfTheSameTypeAndSameStateWhenTestingAssociationEqualityExpectEquals() {
UnitOfWork uow = module.newUnitOfWork();
try {
AnEntity anEntity = uow.newEntity(AnEntity.class);
SomeWithAssociations some = buildSomeWithAssociation(anEntity);
SomeWithAssociations some2 = buildSomeWithAssociation(anEntity);
assertThat("Association equal", some.anEntity(), equalTo(some2.anEntity()));
assertThat("Association hashcode equal", some.anEntity().hashCode(), equalTo(some2.anEntity().hashCode()));
assertThat("ManyAssociation equal", some.manyEntities(), equalTo(some2.manyEntities()));
assertThat("ManyAssociation hashcode equal", some.manyEntities().hashCode(), equalTo(some2.manyEntities().hashCode()));
} finally {
uow.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class GenericConcernTest method testNestedUnitOfWork.
@Test
public void testNestedUnitOfWork() {
UnitOfWork uow = module.newUnitOfWork();
Some some = module.newTransient(Some.class);
some.doStuff();
uow.discard();
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class Qi4jAPITest method testGetModuleOfComposite.
@Test
public void testGetModuleOfComposite() throws Exception {
UnitOfWork unitOfWork = module.newUnitOfWork();
TestEntity testEntity = unitOfWork.newEntity(TestEntity.class);
api.moduleOf(testEntity);
unitOfWork.discard();
api.moduleOf(module.newValue(TestValue.class));
api.moduleOf(module.newTransient(TestTransient.class));
api.moduleOf(module.findService(TestService.class).get());
}
Aggregations