Search in sources :

Example 6 with Product

use of test5.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)

Example 7 with Product

use of test5.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 8 with Product

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

the class OrderServiceTest method setUp.

@BeforeEach
void setUp() {
    Customer customer1 = dataManager.create(Customer.class);
    customer1.setName("Alice");
    customer1.setEmail("alice@company.com");
    Product product1 = dataManager.create(Product.class);
    product1.setName("MacBook Pro");
    product1.setPrice(BigDecimal.valueOf(2500));
    order1 = dataManager.create(Order.class);
    order1.setCustomer(customer1);
    order1.setDate(LocalDate.now());
    order1.setAmount(BigDecimal.valueOf(5000));
    OrderLine orderLine1 = dataManager.create(OrderLine.class);
    orderLine1.setOrder(order1);
    orderLine1.setProduct(product1);
    orderLine1.setQuantity(2.0);
    dataManager.save(customer1, order1, orderLine1, product1);
}
Also used : Order(dataaccess.ex1.entity.Order) Customer(dataaccess.ex1.entity.Customer) OrderLine(dataaccess.ex1.entity.OrderLine) Product(dataaccess.ex1.entity.Product) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with Product

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

the class OrderServiceTest method testHardDelete.

@Test
void testHardDelete() {
    Product product1 = dataManager.create(Product.class);
    product1.setName("MacBook Pro");
    dataManager.save(product1);
    orderService.hardDelete(product1);
    assertFalse(dataManager.load(Id.of(product1)).hint(PersistenceHints.SOFT_DELETION, false).optional().isPresent());
}
Also used : Product(dataaccess.ex1.entity.Product) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with Product

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

the class ProductEntityEventListener method onProductLoading.

@EventListener
void onProductLoading(EntityLoadingEvent<Product> event) {
    Product product = event.getEntity();
    try {
        ProductPart[] productPartsArray = objectMapper.readValue(product.getParts(), ProductPart[].class);
        product.setPartsList(productPartsArray == null ? null : Arrays.asList(productPartsArray));
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Error reading JSON", e);
    }
}
Also used : Product(datamodel.ex1.entity.Product) ProductPart(datamodel.ex1.entity.ProductPart) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) EventListener(org.springframework.context.event.EventListener)

Aggregations

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