Search in sources :

Example 1 with Product

use of datamodel.ex1.entity.Product in project odata-client by davidmoten.

the class CustomRequestTest method testCustomRequestGet.

@Test
public void testCustomRequestGet() {
    Test5Service client = // 
    Test5Service.test().expectRequest(// 
    "/Products/1").withResponse(// 
    "/response-product-1.json").withRequestHeaders(RequestHeader.ACCEPT_JSON, // 
    RequestHeader.ODATA_VERSION).build();
    Product p = client._custom().get("https://testing.com/Products/1", Product.class, HttpRequestOptions.EMPTY);
    System.out.println(p);
    assertEquals(1, (int) p.getID().get());
}
Also used : Product(test5.entity.Product) Test5Service(test5.container.Test5Service) Test(org.junit.Test)

Example 2 with Product

use of datamodel.ex1.entity.Product in project jmix-docs by Haulmont.

the class ProductEntityEventListener method onProductSaving.

@EventListener
void onProductSaving(EntitySavingEvent<Product> event) {
    Product product = event.getEntity();
    try {
        String json = objectMapper.writeValueAsString(product.getPartsList());
        product.setParts(json);
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Error writing JSON", e);
    }
}
Also used : Product(datamodel.ex1.entity.Product) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) EventListener(org.springframework.context.event.EventListener)

Example 3 with Product

use of datamodel.ex1.entity.Product in project jmix-docs by Haulmont.

the class SliderScreen method onInit.

@Subscribe
public void onInit(InitEvent event) {
    // InstanceContainer initialization. It is usually done automatically if the screen is
    // inherited from StandardEditor and is used as an entity editor.
    Product product = metadata.create(Product.class);
    productDc.setItem(product);
}
Also used : Product(ui.ex1.entity.Product)

Example 4 with Product

use of datamodel.ex1.entity.Product in project jmix-docs by Haulmont.

the class OrderLineEventListenerTest method test.

@Test
void test() {
    Product product1 = dataManager.create(Product.class);
    product1.setName("MacBook Pro");
    product1.setPrice(BigDecimal.valueOf(2500));
    Product product2 = dataManager.create(Product.class);
    product2.setName("iPad");
    product2.setPrice(BigDecimal.valueOf(1000));
    Order order1 = dataManager.create(Order.class);
    order1.setDate(LocalDate.now());
    dataManager.save(order1, product1, product2);
    OrderLine orderLine1 = dataManager.create(OrderLine.class);
    orderLine1.setOrder(order1);
    orderLine1.setProduct(product1);
    orderLine1.setQuantity(2.0);
    dataManager.save(orderLine1);
    assertEquals(0, BigDecimal.valueOf(5000).compareTo(dataManager.load(Id.of(order1)).one().getAmount()));
    OrderLine orderLine2 = dataManager.create(OrderLine.class);
    orderLine2.setOrder(order1);
    orderLine2.setProduct(product2);
    orderLine2.setQuantity(3.0);
    dataManager.save(orderLine2);
    assertEquals(0, BigDecimal.valueOf(8000).compareTo(dataManager.load(Id.of(order1)).one().getAmount()));
}
Also used : Order(dataaccess.ex1.entity.Order) OrderLine(dataaccess.ex1.entity.OrderLine) Product(dataaccess.ex1.entity.Product) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with Product

use of datamodel.ex1.entity.Product in project jmix-docs by Haulmont.

the class CurrencyFieldScreen method onInit.

@Subscribe
public void onInit(InitEvent event) {
    // InstanceContainer initialization. It is usually done automatically if the screen is
    // inherited from StandardEditor and is used as an entity editor.
    Product product = metadata.create(Product.class);
    productDc.setItem(product);
}
Also used : Product(ui.ex1.entity.Product) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

Product (dataaccess.ex1.entity.Product)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Order (dataaccess.ex1.entity.Order)2 OrderLine (dataaccess.ex1.entity.OrderLine)2 Product (datamodel.ex1.entity.Product)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 EventListener (org.springframework.context.event.EventListener)2 Product (ui.ex1.entity.Product)2 Customer (dataaccess.ex1.entity.Customer)1 ProductPart (datamodel.ex1.entity.ProductPart)1 Subscribe (io.jmix.ui.screen.Subscribe)1 Test (org.junit.Test)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test5Service (test5.container.Test5Service)1 Product (test5.entity.Product)1