@Test public void shouldGetOrdersForView() throws Exception { mockStatic(RnrDTO.class); SupplyLine supplyLine = new SupplyLine(); final Order order1 = new Order(); Date createdDate = new Date(); order1.setCreatedDate(createdDate); order1.setRnr(make(a(defaultRequisition))); order1.setShipmentFileInfo(new ShipmentFileInfo("1.csv", false)); order1.setSupplyLine(supplyLine); order1.setOrderNumber("OrdHIV00000001R"); final Order order2 = new Order(); order2.setRnr(make(a(defaultRequisition, with(RequisitionBuilder.periodId, 2L), with(RequisitionBuilder.program, new Program(11L))))); order2.setShipmentFileInfo(new ShipmentFileInfo("2.csv", true)); final RnrDTO dtoForOrder1 = new RnrDTO(); dtoForOrder1.setId(1L); final RnrDTO dtoForOrder2 = new RnrDTO(); dtoForOrder2.setId(2L); when(RnrDTO.prepareForOrderView(order1.getRnr())).thenReturn(dtoForOrder1); when(RnrDTO.prepareForOrderView(order2.getRnr())).thenReturn(dtoForOrder2); List<Order> orders = new ArrayList<Order>() {{ add(order1); add(order2); }}; List<OrderDTO> orderDTOs = OrderDTO.getOrdersForView(orders); assertThat(orderDTOs.get(0).getRnr(), is(dtoForOrder1)); assertThat(orderDTOs.get(1).getRnr(), is(dtoForOrder2)); assertThat(orderDTOs.get(0).getStringCreatedDate(), is(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(createdDate))); assertThat(orderDTOs.get(0).getShipmentError(), is(false)); assertThat(orderDTOs.get(0).getSupplyLine(), is(supplyLine)); assertThat(orderDTOs.get(0).getOrderNumber(), is(order1.getOrderNumber())); }
public static List<OrderDTO> getOrdersForView(List<Order> orders) { List<OrderDTO> orderDTOs = new ArrayList<>(); for (Order order : orders) { orderDTOs.add(getOrderForView(order)); } return orderDTOs; }
OrderDTO { public static List<OrderDTO> getOrdersForView(List<Order> orders) { List<OrderDTO> orderDTOs = new ArrayList<>(); for (Order order : orders) { orderDTOs.add(getOrderForView(order)); } return orderDTOs; } }
OrderDTO { public static List<OrderDTO> getOrdersForView(List<Order> orders) { List<OrderDTO> orderDTOs = new ArrayList<>(); for (Order order : orders) { orderDTOs.add(getOrderForView(order)); } return orderDTOs; }  }
OrderDTO { public static List<OrderDTO> getOrdersForView(List<Order> orders) { List<OrderDTO> orderDTOs = new ArrayList<>(); for (Order order : orders) { orderDTOs.add(getOrderForView(order)); } return orderDTOs; }  static List<OrderDTO> getOrdersForView(List<Order> orders); }
OrderDTO { public static List<OrderDTO> getOrdersForView(List<Order> orders) { List<OrderDTO> orderDTOs = new ArrayList<>(); for (Order order : orders) { orderDTOs.add(getOrderForView(order)); } return orderDTOs; }  static List<OrderDTO> getOrdersForView(List<Order> orders);  }