use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ObjectVisibilityTest method givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess.
@Test
public void givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.besideLayerVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ObjectVisibilityTest method givenFromEntityWhenAccessingAboveLayerVisibleExpectException.
@Test(expected = NoSuchObjectException.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 ObjectVisibilityTest method givenFromEntityWhenAccessingBesideModuleVisibleExpectException.
@Test(expected = NoSuchObjectException.class)
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.besideModuleVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ObjectVisibilityTest method givenFromEntityWhenAccessingAboveApplicationVisibleExpectException.
@Test(expected = NoSuchObjectException.class)
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.aboveApplicationVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ImmutablePropertyTest method testImmutableEntityProperty.
@Test
public final void testImmutableEntityProperty() {
UnitOfWork uow = module.newUnitOfWork();
try {
EntityBuilder<LocationEntity> builder = uow.newEntityBuilder(LocationEntity.class);
builder.instance().name().set("Rickard");
Location location = builder.newInstance();
try {
location.name().set("Niclas");
Assert.fail("Should be immutable");
} catch (IllegalStateException e) {
// Ok
}
} finally {
uow.discard();
}
}
Aggregations