use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class EntityVisibilityTest method givenFromEntityWhenAccessingAboveLayerVisibleExpectException.
@Test(expected = EntityTypeNotFoundException.class)
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.aboveLayerVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ImmutableAssociationTest method givenEntityWithImmutableAssociationWhenChangingValueThenThrowException.
@Test(expected = IllegalStateException.class)
public void givenEntityWithImmutableAssociationWhenChangingValueThenThrowException() throws Exception {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity father = builder.instance();
father = builder.newInstance();
builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity child = builder.instance();
child = builder.newInstance();
child.father().set(father);
unitOfWork.complete();
} finally {
unitOfWork.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ImmutableAssociationTest method givenEntityWithImmutableManyAssociationWhenChangingValueThenThrowException.
@Test(expected = IllegalStateException.class)
public void givenEntityWithImmutableManyAssociationWhenChangingValueThenThrowException() throws Exception {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity person1 = builder.instance();
person1 = builder.newInstance();
builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity person2 = builder.instance();
person2 = builder.newInstance();
person1.colleagues().add(0, person2);
unitOfWork.complete();
} finally {
unitOfWork.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ImmutableAssociationTest method givenEntityWithImmutableManyAssociationWhenBuildingThenNoException.
@Test
public void givenEntityWithImmutableManyAssociationWhenBuildingThenNoException() throws Exception {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity person1 = builder.instance();
person1 = builder.newInstance();
builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity person2 = builder.instance();
person2.colleagues().add(0, person1);
person2 = builder.newInstance();
} finally {
unitOfWork.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ImmutableAssociationTest method givenEntityWithImmutableAssociationWhenBuildingThenNoException.
@Test
public void givenEntityWithImmutableAssociationWhenBuildingThenNoException() throws Exception {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
PersonEntity father = unitOfWork.newEntity(PersonEntity.class);
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder(PersonEntity.class);
PersonEntity instance = builder.instance();
instance.father().set(father);
PersonEntity child = builder.newInstance();
} finally {
unitOfWork.discard();
}
}
Aggregations