@Test public void shouldGetOrderWithoutUnorderedProducts() { Long orderId = 1L; Long rnrId = 1L; Order order = new Order(); Rnr rnr = new Rnr(); rnr.setId(rnrId); rnr.setProgram(make(a(defaultProgram))); RnrLineItem rnrLineItem = new RnrLineItem(); List<RnrLineItem> lineItems = new ArrayList<>(); rnrLineItem.setPacksToShip(0); lineItems.add(rnrLineItem); rnr.setFullSupplyLineItems(lineItems); rnr.setNonFullSupplyLineItems(lineItems); order.setRnr(rnr); order.setRnr(rnr); when(programService.getById(rnr.getProgram().getId())).thenReturn(rnr.getProgram()); when(orderRepository.getById(orderId)).thenReturn(order); when(requisitionService.getFullRequisitionById(rnr.getId())).thenReturn(rnr); Order expectedOrder = orderService.getOrder(orderId); verify(orderRepository).getById(orderId); verify(requisitionService).getFullRequisitionById(rnr.getId()); assertThat(order.getRnr().getFullSupplyLineItems().size(), is(0)); assertThat(order.getRnr().getNonFullSupplyLineItems().size(), is(0)); assertThat(expectedOrder, is(order)); }
public Order getOrder(Long id) { Order order = orderRepository.getById(id); if (order == null) { return null; } Rnr requisition = requisitionService.getFullRequisitionById(order.getRnr().getId()); requisition.setProgram(programService.getById(requisition.getProgram().getId())); removeUnorderedProducts(requisition); order.setRnr(requisition); return order; }
OrderService { public Order getOrder(Long id) { Order order = orderRepository.getById(id); if (order == null) { return null; } Rnr requisition = requisitionService.getFullRequisitionById(order.getRnr().getId()); requisition.setProgram(programService.getById(requisition.getProgram().getId())); removeUnorderedProducts(requisition); order.setRnr(requisition); return order; } }
OrderService { public Order getOrder(Long id) { Order order = orderRepository.getById(id); if (order == null) { return null; } Rnr requisition = requisitionService.getFullRequisitionById(order.getRnr().getId()); requisition.setProgram(programService.getById(requisition.getProgram().getId())); removeUnorderedProducts(requisition); order.setRnr(requisition); return order; }  }
OrderService { public Order getOrder(Long id) { Order order = orderRepository.getById(id); if (order == null) { return null; } Rnr requisition = requisitionService.getFullRequisitionById(order.getRnr().getId()); requisition.setProgram(programService.getById(requisition.getProgram().getId())); removeUnorderedProducts(requisition); order.setRnr(requisition); return order; }  @Autowired void setPageSize(@Value("${order.page.size}") String pageSize); @Transactional void convertToOrder(List<Rnr> rnrList, Long userId); List<Order> getOrdersForPage(int page, Long userId, String rightName); List<Order> getOrdersForPage(int page, Long userId, String right, Long supplyDepot, Long program, Long period); Order getOrder(Long id); void updateStatusAndShipmentIdForOrders(Set<String> orderNumbers, ShipmentFileInfo shipmentFileInfo); OrderFileTemplateDTO getOrderFileTemplateDTO(); @Transactional void saveOrderFileTemplate(OrderFileTemplateDTO orderFileTemplateDTO, Long userId); OrderNumberConfiguration getOrderNumberConfiguration(); @Transactional void updateOrderNumberConfiguration(OrderNumberConfiguration orderNumberConfiguration); Set<DateFormat> getAllDateFormats(); void updateOrderStatus(Order order); boolean isShippable(String orderNumber); Integer getNumberOfPages(); Integer getNumberOfPages(Long supplyDepot, Long program, Long period); Integer getPageSize(); List<Order> searchByStatusAndRight(Long userId, String rightName, List<OrderStatus> statuses, Long programId, Long facilityId); boolean hasStatus(String orderNumber, OrderStatus... statuses); Order getByOrderNumber(String orderNumber); }
OrderService { public Order getOrder(Long id) { Order order = orderRepository.getById(id); if (order == null) { return null; } Rnr requisition = requisitionService.getFullRequisitionById(order.getRnr().getId()); requisition.setProgram(programService.getById(requisition.getProgram().getId())); removeUnorderedProducts(requisition); order.setRnr(requisition); return order; }  @Autowired void setPageSize(@Value("${order.page.size}") String pageSize); @Transactional void convertToOrder(List<Rnr> rnrList, Long userId); List<Order> getOrdersForPage(int page, Long userId, String rightName); List<Order> getOrdersForPage(int page, Long userId, String right, Long supplyDepot, Long program, Long period); Order getOrder(Long id); void updateStatusAndShipmentIdForOrders(Set<String> orderNumbers, ShipmentFileInfo shipmentFileInfo); OrderFileTemplateDTO getOrderFileTemplateDTO(); @Transactional void saveOrderFileTemplate(OrderFileTemplateDTO orderFileTemplateDTO, Long userId); OrderNumberConfiguration getOrderNumberConfiguration(); @Transactional void updateOrderNumberConfiguration(OrderNumberConfiguration orderNumberConfiguration); Set<DateFormat> getAllDateFormats(); void updateOrderStatus(Order order); boolean isShippable(String orderNumber); Integer getNumberOfPages(); Integer getNumberOfPages(Long supplyDepot, Long program, Long period); Integer getPageSize(); List<Order> searchByStatusAndRight(Long userId, String rightName, List<OrderStatus> statuses, Long programId, Long facilityId); boolean hasStatus(String orderNumber, OrderStatus... statuses); Order getByOrderNumber(String orderNumber); static String SUPPLY_LINE_MISSING_COMMENT; }