use of dataaccess.ex1.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());
}
use of dataaccess.ex1.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);
}
use of dataaccess.ex1.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);
}
}
Aggregations