Search in sources :

Example 11 with Order

use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.

the class EntitiesTest method testPostConstruct.

@Test
void testPostConstruct() {
    Order order = metadata.create(Order.class);
    assertEquals(LocalDate.now(), order.getDate());
}
Also used : Order(datamodel.ex1.entity.Order) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with Order

use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.

the class OrderService method createAndSaveOrder.

Order createAndSaveOrder(String number) {
    Order order = dataManager.create(Order.class);
    order.setNum(number);
    dataManager.save(order);
    return order;
}
Also used : Order(datamodel.ex1.entity.Order)

Example 13 with Order

use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.

the class RelatedEntityLoadingTest method jpql_relatedEntityIsLoadedLazily.

@Test
void jpql_relatedEntityIsLoadedLazily() {
    authenticator.withUser("test1", () -> {
        Order order = dataManager.load(Order.class).id(orderId).one();
        assertNotNull(order.getCustomer());
        return null;
    });
}
Also used : Order(security.ex1.entity.Order) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with Order

use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.

the class RelatedEntityLoadingTest method docExamples.

@Test
void docExamples() {
    authenticator.withUser("test1", () -> {
        // tag::data-access-checks-1[]
        // order is loaded only if it satisfies JPQL policies on the Order entity
        Order order = dataManager.load(Order.class).id(orderId).one();
        // related customer is loaded regardless of JPQL policies on the Customer entity
        assert order.getCustomer() != null;
        // end::data-access-checks-1[]
        return null;
    });
    authenticator.withUser("test2", () -> {
        // tag::data-access-checks-2[]
        // order is loaded only if it satisfies constraints on the Order entity
        Order order = dataManager.load(Order.class).id(orderId).one();
        // related customer is not null only if it satisfies predicate policies on the Customer entity
        if (order.getCustomer() != null) {
        /*...*/
        }
        // end::data-access-checks-2[]
        return null;
    });
    authenticator.withUser("test1", () -> {
        // tag::data-access-checks-3[]
        // loading Order
        Order order = dataManager.load(Order.class).id(orderId).one();
        // related customer is loaded even if the user has no permission to read the Customer entity
        assert order.getCustomer() != null;
        // end::data-access-checks-3[]
        return null;
    });
}
Also used : Order(security.ex1.entity.Order) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with Order

use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.

the class RelatedEntityLoadingTest method jpql_relatedEntityIsLoadedEagerly.

@Test
void jpql_relatedEntityIsLoadedEagerly() {
    authenticator.withUser("test1", () -> {
        Order order = dataManager.load(Order.class).id(orderId).fetchPlanProperties("customer.name").one();
        assertNotNull(order.getCustomer());
        return null;
    });
}
Also used : Order(security.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