Search in sources :

Example 6 with Order

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());
}
Also used : Order(dataaccess.ex1.entity.Order) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with Order

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[]
}
Also used : Order(dataaccess.ex1.entity.Order) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with Order

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);
    }
}
Also used : Order(dataaccess.ex1.entity.Order) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Order

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());
}
Also used : Order(dataaccess.ex1.entity.Order) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with Order

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);
}
Also used : Order(dataaccess.ex1.entity.Order) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 Test (org.junit.jupiter.api.Test)17 Order (dataaccess.ex1.entity.Order)12 Order (security.ex1.entity.Order)6 OrderLine (dataaccess.ex1.entity.OrderLine)4 Subscribe (io.jmix.ui.screen.Subscribe)4 BigDecimal (java.math.BigDecimal)4 Order (maps.ex1.entity.Order)4 Order (bpm.ex1.entity.Order)3 UUID (java.util.UUID)3 EventListener (org.springframework.context.event.EventListener)3 Order (charts.ex1.entity.Order)2 Item (com.test.toyproject1.entity.Item)2 Member (com.test.toyproject1.entity.Member)2 Order (com.test.toyproject1.entity.Order)2 Customer (dataaccess.ex1.entity.Customer)2 Product (dataaccess.ex1.entity.Product)2 Order (datamodel.ex1.entity.Order)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2