@Test public void shouldNotPopulateAnyValueIfAmountIsBelowZero() { ViaKitsViewModel viaKitsViewModel = new ViaKitsViewModel(); Product usKit = new ProductBuilder().setCode(ViaKitsViewModel.US_KIT).build(); Product apeKit = new ProductBuilder().setCode(ViaKitsViewModel.APE_KIT).build(); List<RnrFormItem> rnrFormItems = newArrayList(new RnrFormItemBuilder().setIssued(Long.MIN_VALUE).setProduct(usKit).build(), new RnrFormItemBuilder().setIssued(Long.MIN_VALUE).setProduct(apeKit).build()); viaKitsViewModel.convertRnrKitItemsToViaKit(rnrFormItems); assertThat(viaKitsViewModel.getKitsOpenedCHW(), is("0")); assertThat(viaKitsViewModel.getKitsOpenedHF(), is("0")); }
public void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems) { kitItems = rnrKitItems; for (RnrFormItem rnrKitItem : rnrKitItems) { if (US_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedHF = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedHF = String.valueOf(rnrKitItem.getIssued()); } } else if (APE_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedCHW = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedCHW = String.valueOf(rnrKitItem.getIssued()); } } } }
ViaKitsViewModel { public void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems) { kitItems = rnrKitItems; for (RnrFormItem rnrKitItem : rnrKitItems) { if (US_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedHF = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedHF = String.valueOf(rnrKitItem.getIssued()); } } else if (APE_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedCHW = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedCHW = String.valueOf(rnrKitItem.getIssued()); } } } } }
ViaKitsViewModel { public void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems) { kitItems = rnrKitItems; for (RnrFormItem rnrKitItem : rnrKitItems) { if (US_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedHF = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedHF = String.valueOf(rnrKitItem.getIssued()); } } else if (APE_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedCHW = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedCHW = String.valueOf(rnrKitItem.getIssued()); } } } }  }
ViaKitsViewModel { public void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems) { kitItems = rnrKitItems; for (RnrFormItem rnrKitItem : rnrKitItems) { if (US_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedHF = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedHF = String.valueOf(rnrKitItem.getIssued()); } } else if (APE_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedCHW = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedCHW = String.valueOf(rnrKitItem.getIssued()); } } } }  void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems); }
ViaKitsViewModel { public void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems) { kitItems = rnrKitItems; for (RnrFormItem rnrKitItem : rnrKitItems) { if (US_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedHF = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedHF = String.valueOf(rnrKitItem.getIssued()); } } else if (APE_KIT.equals(rnrKitItem.getProduct().getCode())) { if (rnrKitItem.getReceived() > Long.MIN_VALUE) { kitsReceivedCHW = String.valueOf(rnrKitItem.getReceived()); } if (rnrKitItem.getIssued() > Long.MIN_VALUE) { kitsOpenedCHW = String.valueOf(rnrKitItem.getIssued()); } } } }  void convertRnrKitItemsToViaKit(List<RnrFormItem> rnrKitItems); static final String US_KIT; static final String APE_KIT; }