@Test public void shouldCopyLineItemsFromPOD() throws Exception { Long modifiedBy = 1L; OrderPODLineItem P1LineItem = spy(new OrderPODLineItem()); P1LineItem.setId(1L); OrderPODLineItem P2LineItem = spy(new OrderPODLineItem()); P2LineItem.setId(2L); OrderPOD existingPOD = new OrderPOD(); existingPOD.setPodLineItems(asList(P1LineItem, P2LineItem)); OrderPODLineItem P3LineItem = new OrderPODLineItem(); P3LineItem.setId(3L); OrderPODLineItem newP1LineItem = new OrderPODLineItem(); newP1LineItem.setId(1L); OrderPODLineItem newP2LineItem = new OrderPODLineItem(); newP2LineItem.setId(2L); OrderPOD newOrderPOD = new OrderPOD(); newOrderPOD.setModifiedBy(modifiedBy); newOrderPOD.setPodLineItems(asList(newP1LineItem, newP2LineItem, P3LineItem)); existingPOD.copy(newOrderPOD); verify(P1LineItem).copy(newP1LineItem); verify(P2LineItem).copy(newP2LineItem); assertThat(existingPOD.getPodLineItems().size(), is(2)); assertThat(existingPOD.getModifiedBy(), is(modifiedBy)); }
public void copy(OrderPOD orderPOD) throws ParseException { this.modifiedBy = orderPOD.getModifiedBy(); this.receivedDate = trimHoursFromDate(orderPOD.getReceivedDate()); this.receivedBy = orderPOD.getReceivedBy(); this.deliveredBy = orderPOD.getDeliveredBy(); for (final OrderPODLineItem newLineItem : orderPOD.podLineItems) { newLineItem.setModifiedBy(orderPOD.getModifiedBy()); OrderPODLineItem existingLineItem = (OrderPODLineItem) find(this.podLineItems, new Predicate() { @Override public boolean evaluate(Object o) { return ((OrderPODLineItem) o).getId().equals(newLineItem.getId()); } }); if (existingLineItem != null) existingLineItem.copy(newLineItem); } }
OrderPOD extends BaseModel { public void copy(OrderPOD orderPOD) throws ParseException { this.modifiedBy = orderPOD.getModifiedBy(); this.receivedDate = trimHoursFromDate(orderPOD.getReceivedDate()); this.receivedBy = orderPOD.getReceivedBy(); this.deliveredBy = orderPOD.getDeliveredBy(); for (final OrderPODLineItem newLineItem : orderPOD.podLineItems) { newLineItem.setModifiedBy(orderPOD.getModifiedBy()); OrderPODLineItem existingLineItem = (OrderPODLineItem) find(this.podLineItems, new Predicate() { @Override public boolean evaluate(Object o) { return ((OrderPODLineItem) o).getId().equals(newLineItem.getId()); } }); if (existingLineItem != null) existingLineItem.copy(newLineItem); } } }
OrderPOD extends BaseModel { public void copy(OrderPOD orderPOD) throws ParseException { this.modifiedBy = orderPOD.getModifiedBy(); this.receivedDate = trimHoursFromDate(orderPOD.getReceivedDate()); this.receivedBy = orderPOD.getReceivedBy(); this.deliveredBy = orderPOD.getDeliveredBy(); for (final OrderPODLineItem newLineItem : orderPOD.podLineItems) { newLineItem.setModifiedBy(orderPOD.getModifiedBy()); OrderPODLineItem existingLineItem = (OrderPODLineItem) find(this.podLineItems, new Predicate() { @Override public boolean evaluate(Object o) { return ((OrderPODLineItem) o).getId().equals(newLineItem.getId()); } }); if (existingLineItem != null) existingLineItem.copy(newLineItem); } } OrderPOD(Long id);  OrderPOD(Long orderId, String orderNumber, Long userId); }
OrderPOD extends BaseModel { public void copy(OrderPOD orderPOD) throws ParseException { this.modifiedBy = orderPOD.getModifiedBy(); this.receivedDate = trimHoursFromDate(orderPOD.getReceivedDate()); this.receivedBy = orderPOD.getReceivedBy(); this.deliveredBy = orderPOD.getDeliveredBy(); for (final OrderPODLineItem newLineItem : orderPOD.podLineItems) { newLineItem.setModifiedBy(orderPOD.getModifiedBy()); OrderPODLineItem existingLineItem = (OrderPODLineItem) find(this.podLineItems, new Predicate() { @Override public boolean evaluate(Object o) { return ((OrderPODLineItem) o).getId().equals(newLineItem.getId()); } }); if (existingLineItem != null) existingLineItem.copy(newLineItem); } } OrderPOD(Long id);  OrderPOD(Long orderId, String orderNumber, Long userId); void validate(); void fillPOD(Rnr requisition); void fillPODLineItems(List<? extends LineItem> lineItems); void copy(OrderPOD orderPOD); @JsonIgnore String getStringReceivedDate(); Date trimHoursFromDate(Date receivedDate); }
OrderPOD extends BaseModel { public void copy(OrderPOD orderPOD) throws ParseException { this.modifiedBy = orderPOD.getModifiedBy(); this.receivedDate = trimHoursFromDate(orderPOD.getReceivedDate()); this.receivedBy = orderPOD.getReceivedBy(); this.deliveredBy = orderPOD.getDeliveredBy(); for (final OrderPODLineItem newLineItem : orderPOD.podLineItems) { newLineItem.setModifiedBy(orderPOD.getModifiedBy()); OrderPODLineItem existingLineItem = (OrderPODLineItem) find(this.podLineItems, new Predicate() { @Override public boolean evaluate(Object o) { return ((OrderPODLineItem) o).getId().equals(newLineItem.getId()); } }); if (existingLineItem != null) existingLineItem.copy(newLineItem); } } OrderPOD(Long id);  OrderPOD(Long orderId, String orderNumber, Long userId); void validate(); void fillPOD(Rnr requisition); void fillPODLineItems(List<? extends LineItem> lineItems); void copy(OrderPOD orderPOD); @JsonIgnore String getStringReceivedDate(); Date trimHoursFromDate(Date receivedDate);  }