### Question:
OrderServiceImpl implements OrderService { @Override public Order createOrder(Order order) { order.setOrderTime(System.currentTimeMillis()); order.setTotalPrice(order.getItems().stream().mapToInt(e -> e.getPrice() * e.getQuantity()).sum()); return orderRepository.save(order); } @Autowired  OrderServiceImpl(OrderRepository orderRepository); @Override Order createOrder(Order order);  }### Answer:
@Test public void whenCreateOrder_returnCreatedOrder() { List<ItemQuantity> itemQuantities = new ArrayList<>(); itemQuantities.add(generateItemQuantity("Menu item 1", 11, 2)); itemQuantities.add(generateItemQuantity("Menu item 2", 12, 3)); Order order = generateOrder(restaurantId, itemQuantities, "Special", userInfo); when(orderRepository.save(order)).thenReturn(order); Order savedOrder = orderService.createOrder(order); assertThat(savedOrder.getTotalPrice()).isEqualTo(2 * 11 + 3 * 12); assertThat(savedOrder.getOrderTime()).isGreaterThan(0); }