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());
}
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);
}
}
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);
}
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()));
}
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);
}
Aggregations