@Test public void shouldInitRnrFormItemWithoutMovement() throws Exception { mmiaRepository = spy(mmiaRepository); Product product = new Product(); RnRForm form = new RnRForm(); RnrFormItem rnrFormItem = new RnrFormItem(); rnrFormItem.setInventory(100L); rnrFormItem.setProduct(product); form.setRnrFormItemListWrapper(newArrayList(rnrFormItem)); doReturn(newArrayList(form)).when(mmiaRepository).listInclude(any(RnRForm.Emergency.class), anyString()); StockCard stockCard = new StockCard(); product.setId(20); stockCard.setProduct(product); Lot lot = new Lot(); lot.setExpirationDate(DateUtil.parseString("Feb 2015", DateUtil.DATE_FORMAT_ONLY_MONTH_AND_YEAR)); stockCard.setLotOnHandListWrapper(newArrayList(new LotOnHand(lot, stockCard, 10L))); when(mockStockMovementRepository.queryStockMovementsByMovementDate(anyLong(), any(Date.class), any(Date.class))).thenReturn(new ArrayList<StockMovementItem>()); RnrFormItem rnrFormItemByPeriod = mmiaRepository.createRnrFormItemByPeriod(stockCard, new Date(), new Date()); assertThat(rnrFormItemByPeriod.getValidate(), is("01/02/2015")); assertThat(rnrFormItemByPeriod.getCalculatedOrderQuantity(), is(0L)); assertThat(rnrFormItemByPeriod.getInitialAmount(), is(0L)); stockCard.setLotOnHandListWrapper(Lists.<LotOnHand>newArrayList()); rnrFormItemByPeriod = mmiaRepository.createRnrFormItemByPeriod(stockCard, new Date(), new Date()); assertNull(rnrFormItemByPeriod.getValidate()); }
@Override protected RnrFormItem createRnrFormItemByPeriod(StockCard stockCard, Date startDate, Date endDate) throws LMISException { RnrFormItem rnrFormItem = this.createMMIARnrFormItemByPeriod(stockCard, startDate, endDate); rnrFormItem.setProduct(stockCard.getProduct()); Date earliestLotExpiryDate = stockCard.getEarliestLotExpiryDate(); if (earliestLotExpiryDate != null) { rnrFormItem.setValidate(DateUtil.formatDate(earliestLotExpiryDate, DateUtil.SIMPLE_DATE_FORMAT)); } return rnrFormItem; }
MMIARepository extends RnrFormRepository { @Override protected RnrFormItem createRnrFormItemByPeriod(StockCard stockCard, Date startDate, Date endDate) throws LMISException { RnrFormItem rnrFormItem = this.createMMIARnrFormItemByPeriod(stockCard, startDate, endDate); rnrFormItem.setProduct(stockCard.getProduct()); Date earliestLotExpiryDate = stockCard.getEarliestLotExpiryDate(); if (earliestLotExpiryDate != null) { rnrFormItem.setValidate(DateUtil.formatDate(earliestLotExpiryDate, DateUtil.SIMPLE_DATE_FORMAT)); } return rnrFormItem; } }
MMIARepository extends RnrFormRepository { @Override protected RnrFormItem createRnrFormItemByPeriod(StockCard stockCard, Date startDate, Date endDate) throws LMISException { RnrFormItem rnrFormItem = this.createMMIARnrFormItemByPeriod(stockCard, startDate, endDate); rnrFormItem.setProduct(stockCard.getProduct()); Date earliestLotExpiryDate = stockCard.getEarliestLotExpiryDate(); if (earliestLotExpiryDate != null) { rnrFormItem.setValidate(DateUtil.formatDate(earliestLotExpiryDate, DateUtil.SIMPLE_DATE_FORMAT)); } return rnrFormItem; } @Inject  MMIARepository(Context context); }
MMIARepository extends RnrFormRepository { @Override protected RnrFormItem createRnrFormItemByPeriod(StockCard stockCard, Date startDate, Date endDate) throws LMISException { RnrFormItem rnrFormItem = this.createMMIARnrFormItemByPeriod(stockCard, startDate, endDate); rnrFormItem.setProduct(stockCard.getProduct()); Date earliestLotExpiryDate = stockCard.getEarliestLotExpiryDate(); if (earliestLotExpiryDate != null) { rnrFormItem.setValidate(DateUtil.formatDate(earliestLotExpiryDate, DateUtil.SIMPLE_DATE_FORMAT)); } return rnrFormItem; } @Inject  MMIARepository(Context context); long getTotalPatients(RnRForm form); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards); }
MMIARepository extends RnrFormRepository { @Override protected RnrFormItem createRnrFormItemByPeriod(StockCard stockCard, Date startDate, Date endDate) throws LMISException { RnrFormItem rnrFormItem = this.createMMIARnrFormItemByPeriod(stockCard, startDate, endDate); rnrFormItem.setProduct(stockCard.getProduct()); Date earliestLotExpiryDate = stockCard.getEarliestLotExpiryDate(); if (earliestLotExpiryDate != null) { rnrFormItem.setValidate(DateUtil.formatDate(earliestLotExpiryDate, DateUtil.SIMPLE_DATE_FORMAT)); } return rnrFormItem; } @Inject  MMIARepository(Context context); long getTotalPatients(RnRForm form); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards); @InjectResource(R.string.table_trav)
    public String ATTR_TABLE_TRAV; @InjectResource(R.string.table_trav_label_new)
    public String ATTR_TABLE_TRAV_NEW; @InjectResource(R.string.table_trav_label_maintenance)
    public String ATTR_TABLE_TRAV_MAINTENANCE; @InjectResource(R.string.table_trav_label_alteration)
    public String ATTR_TABLE_TRAV_ALTERATION; @InjectResource(R.string.table_trav_label_transit)
    public String ATTR_TABLE_TRAV_TRANSIT; @InjectResource(R.string.table_trav_label_transfers)
    public String ATTR_TABLE_TRAV_TRANSFER; @InjectResource(R.string.table_dispensed)
    public String ATTR_TABLE_DISPENSED; @InjectResource(R.string.table_dispensed_label_dt)
    public String ATTR_TABLE_DISPENSED_DT; @InjectResource(R.string.table_dispensed_label_dm)
    public String ATTR_TABLE_DISPENSED_DM; @InjectResource(R.string.table_dispensed_label_therapeutic)
    public String ATTR_TABLE_DISPENSED_THERAPEUTIC; @InjectResource(R.string.table_dispensed_label_ds)
    public String ATTR_TABLE_DISPENSED_DS; @InjectResource(R.string.table_patients)
    public String ATTR_TABLE_PATIENTS; @InjectResource(R.string.table_patients_adults)
    public String ATTR_TABLE_PATIENTS_ADULTS; @InjectResource(R.string.table_patients_0to4)
    public String ATTR_TABLE_PATIENTS_0TO4; @InjectResource(R.string.table_patients_5to9)
    public String ATTR_TABLE_PATIENTS_5TO9; @InjectResource(R.string.table_patients_10to14)
    public String ATTR_TABLE_PATIENTS_10TO14; @InjectResource(R.string.table_prophylaxis)
    public String ATTR_TABLE_PROPHYLAXIS; @InjectResource(R.string.table_prophylaxis_ppe)
    public String ATTR_TABLE_PROPHYLAXIS_PPE; @InjectResource(R.string.table_prophylaxis_prep)
    public String ATTR_TABLE_PROPHYLAXIS_PREP; @InjectResource(R.string.table_prophylaxis_child)
    public String ATTR_TABLE_PROPHYLAXIS_CHILD; @InjectResource(R.string.table_prophylaxis_total)
    public String ATTR_TABLE_PROPHYLAXIS_TOTAL; @InjectResource(R.string.mmia_1stline)
    public String ATTR_REGIME_TYPE_FIRST_LINE; @InjectResource(R.string.mmia_2ndline)
    public String ATTR_REGIME_TYPE_SECOND_LINE; @InjectResource(R.string.mmia_3rdline)
    public String ATTR_REGIME_TYPE_THIRD_LINE; @InjectResource(R.string.label_new_patients)
    public String ATTR_NEW_PATIENTS; @InjectResource(R.string.label_sustaining)
    public String ATTR_SUSTAINING; @InjectResource(R.string.label_alteration)
    public String ATTR_ALTERATION; @InjectResource(R.string.label_total_month_dispense)
    public String ATTR_TOTAL_MONTH_DISPENSE; @InjectResource(R.string.label_total_patients)
    public String ATTR_TOTAL_PATIENTS; @InjectResource(R.string.label_ptv)
    public String ATTR_PTV; @InjectResource(R.string.label_ppe)
    public String ATTR_PPE; }