use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class TransientVisibilityTest method givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess.
@Test
public void givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.moduleLayerVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class TransientVisibilityTest method givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess.
@Test
public void givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.moduleApplicationVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class TransientVisibilityTest method givenFromEntityWhenAccessingBelowLayerVisibleExpectException.
@Test(expected = NoSuchTransientException.class)
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.belowLayerVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class TransientVisibilityTest method givenFromEntityWhenAccessingBelowModuleVisibleExpectException.
@Test(expected = NoSuchTransientException.class)
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException() {
UnitOfWork unitOfWork = module.newUnitOfWork();
try {
FromEntity entity = unitOfWork.newEntity(FromEntity.class, "123");
entity.belowModuleVisible();
} finally {
if (unitOfWork.isOpen()) {
unitOfWork.discard();
}
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class AutoCloseableUoWTest method givenGoodAutoCloseableUoWWhenTryWithResourceExpectSuccess.
@Test
public void givenGoodAutoCloseableUoWWhenTryWithResourceExpectSuccess() throws UnitOfWorkCompletionException {
try (UnitOfWork uow = module.newUnitOfWork()) {
EntityBuilder<TestEntity> builder = uow.newEntityBuilder(TestEntity.class);
builder.instance().mandatory().set("Mandatory property");
builder.newInstance();
uow.complete();
}
}
Aggregations