use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderServiceTest method testRemoveOrderWithCustomer.
@Test
void testRemoveOrderWithCustomer() {
Order order = orderService.createOrderWithCustomer();
assertNotNull(order.getCustomer());
orderService.removeOrderWithCustomer(order);
assertFalse(dataManager.load(Order.class).id(order.getId()).optional().isPresent());
assertFalse(dataManager.load(Customer.class).id(order.getCustomer().getId()).optional().isPresent());
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderServiceTest method testFetchPlan_shared.
@Test
void testFetchPlan_shared() {
UUID orderId = order1.getId();
// tag::fetch-plan[]
Order order = dataManager.load(Order.class).id(orderId).fetchPlan("full").one();
// end::fetch-plan[]
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderServiceTest method testLazyLoadingThroughEntityManagerDoesNotWork.
@Test
void testLazyLoadingThroughEntityManagerDoesNotWork() {
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
Order order = transactionTemplate.execute(status -> entityManager.find(Order.class, order1.getId()));
try {
order.getCustomer().getName();
fail();
} catch (Exception e) {
assertTrue(e instanceof IllegalStateException);
}
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderServiceTest method testFetchPlanAndLazyLoading.
@Test
void testFetchPlanAndLazyLoading() {
UUID orderId = order1.getId();
log.info("load with fetch plan");
Order order = dataManager.load(Order.class).id(orderId).fetchPlan(FetchPlan.INSTANCE_NAME).one();
log.info("load lazily");
assertEquals("Alice", order.getCustomer().getName());
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderEventListenerTest method test.
@Test
void test() {
Order order1 = dataManager.create(Order.class);
order1.setDate(LocalDate.now());
Order savedOrder = dataManager.save(order1);
assertTrue(Integer.parseInt(savedOrder.getNumber()) > 0);
}
Aggregations