use of dataaccess.ex1.entity.Order in project Today-I-Learn by kha0213.
the class OrderServiceTest method 상품주문성공.
@Test
public void 상품주문성공() throws Exception {
// given
Member member = createMember();
Item book = createBook("JPA입문", 15000, 5);
int orderCount = 2;
// when
Long orderId = orderService.order(member.getId(), book.getId(), orderCount);
// then
Order getOrder = orderRepository.findOne(orderId);
// 상품주문시 상태 ORDER
assertEquals(OrderStatus.ORDER, getOrder.getStatus());
// 주문 상품 2개
assertEquals(orderCount, getOrder.getOrderItems().get(0).getCount());
// 주문 가격은 가격 * 수량
assertEquals(book.getPrice() * orderCount, getOrder.getTotalPrice());
// 주문 수량만큼 재고 마이너스
assertEquals(5 - orderCount, book.getStockQuantity());
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderStatusBean method setStatus.
@Override
public void setStatus(Order order, String status) {
Order reloadedOrder = dataManager.load(Order.class).id(order.getId()).one();
reloadedOrder.setStatus(status);
dataManager.save(reloadedOrder);
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderServiceTest method testCreateOrderWithCustomer.
@Test
void testCreateOrderWithCustomer() {
Order order = orderService.createOrderWithCustomer();
assertNotNull(order.getCustomer());
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderServiceTest method testFetchPlan_FetchPlanBuilder_DataManager.
// end::fetch-plan-builder[]
@Test
void testFetchPlan_FetchPlanBuilder_DataManager() {
// tag::fetch-plan-builder-dm[]
List<Order> orders = dataManager.load(Order.class).all().fetchPlan(fpb -> fpb.addFetchPlan(FetchPlan.BASE).add("customer")).list();
// end::fetch-plan-builder-dm[]
Order o1 = orders.get(0);
assertEquals(0, o1.getAmount().compareTo(BigDecimal.valueOf(5000)));
assertEquals("alice@company.com", o1.getCustomer().getEmail());
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderEventListener method onOrderSaving.
@EventListener
void onOrderSaving(EntitySavingEvent<Order> event) {
if (event.isNewEntity()) {
Order order = event.getEntity();
order.setNumber(generateOrderNumber());
}
}
Aggregations