@Test public void shouldDeleteDeactivatedItemsFromRnrForms() throws Exception { RnRForm form = new RnRFormBuilder().setComments("Submitted Form") .setStatus(RnRForm.STATUS.AUTHORIZED) .setSynced(false).setProgram(createProgram("MMIA")).build(); RnrFormItem deactivatedProductItem = new RnrFormItemBuilder().setProduct(new ProductBuilder().setCode("P1").setIsActive(false).build()).build(); form.setRnrFormItemListWrapper(newArrayList(deactivatedProductItem)); rnrFormRepository.deleteDeactivatedAndUnsupportedProductItems(Arrays.asList(form)); verify(mockRnrFormItemRepository).deleteFormItems(anyList()); }
protected void deleteDeactivatedAndUnsupportedProductItems(List<RnRForm> rnRForms) throws LMISException { for (RnRForm rnRForm : rnRForms) { String programCode = rnRForm.getProgram().getProgramCode(); List<String> programCodes = programRepository.queryProgramCodesByProgramCodeOrParentCode(programCode); List<String> supportedProductCodes = FluentIterable.from(productProgramRepository.listActiveProductProgramsByProgramCodes(programCodes)).transform(new Function<ProductProgram, String>() { @Override public String apply(ProductProgram productProgram) { return productProgram.getProductCode(); } }).toList(); rnrFormItemRepository.deleteFormItems(rnRForm.getDeactivatedAndUnsupportedProductItems(supportedProductCodes)); } }
RnrFormRepository { protected void deleteDeactivatedAndUnsupportedProductItems(List<RnRForm> rnRForms) throws LMISException { for (RnRForm rnRForm : rnRForms) { String programCode = rnRForm.getProgram().getProgramCode(); List<String> programCodes = programRepository.queryProgramCodesByProgramCodeOrParentCode(programCode); List<String> supportedProductCodes = FluentIterable.from(productProgramRepository.listActiveProductProgramsByProgramCodes(programCodes)).transform(new Function<ProductProgram, String>() { @Override public String apply(ProductProgram productProgram) { return productProgram.getProductCode(); } }).toList(); rnrFormItemRepository.deleteFormItems(rnRForm.getDeactivatedAndUnsupportedProductItems(supportedProductCodes)); } } }
RnrFormRepository { protected void deleteDeactivatedAndUnsupportedProductItems(List<RnRForm> rnRForms) throws LMISException { for (RnRForm rnRForm : rnRForms) { String programCode = rnRForm.getProgram().getProgramCode(); List<String> programCodes = programRepository.queryProgramCodesByProgramCodeOrParentCode(programCode); List<String> supportedProductCodes = FluentIterable.from(productProgramRepository.listActiveProductProgramsByProgramCodes(programCodes)).transform(new Function<ProductProgram, String>() { @Override public String apply(ProductProgram productProgram) { return productProgram.getProductCode(); } }).toList(); rnrFormItemRepository.deleteFormItems(rnRForm.getDeactivatedAndUnsupportedProductItems(supportedProductCodes)); } } @Inject  RnrFormRepository(Context context); }
RnrFormRepository { protected void deleteDeactivatedAndUnsupportedProductItems(List<RnRForm> rnRForms) throws LMISException { for (RnRForm rnRForm : rnRForms) { String programCode = rnRForm.getProgram().getProgramCode(); List<String> programCodes = programRepository.queryProgramCodesByProgramCodeOrParentCode(programCode); List<String> supportedProductCodes = FluentIterable.from(productProgramRepository.listActiveProductProgramsByProgramCodes(programCodes)).transform(new Function<ProductProgram, String>() { @Override public String apply(ProductProgram productProgram) { return productProgram.getProductCode(); } }).toList(); rnrFormItemRepository.deleteFormItems(rnRForm.getDeactivatedAndUnsupportedProductItems(supportedProductCodes)); } } @Inject  RnrFormRepository(Context context); RnRForm initNormalRnrForm(Date periodEndDate); RnRForm initEmergencyRnrForm(Date periodEndDate, List<StockCard> stockCards); void create(RnRForm rnRForm); void createRnRsWithItems(final List<RnRForm> forms); void createOrUpdateWithItems(final RnRForm form); boolean isPeriodUnique(final RnRForm form); List<RnRForm> list(); List<RnRForm> listInclude(RnRForm.Emergency includeEmergency, String programCode); List<RnRForm> listInclude(RnRForm.Emergency includeEmergency, String programCode, ReportTypeForm reportTypeForm); List<RnRForm> queryAllUnsyncedForms(); RnRForm queryUnAuthorized(); RnRForm queryRnRForm(final long id); List<RnrFormItem> generateRnrFormItems(final RnRForm form, List<StockCard> stockCards); void removeRnrForm(RnRForm form); boolean hasRequisitionData(); boolean hasOldDate(); List<RnRForm> listNotSynchronizedFromReportStartTime(String programCode); void createAndRefresh(RnRForm rnRForm); void deleteOldData(); void deleteRnrFormDirtyData(List<String> productCodeList); }
RnrFormRepository { protected void deleteDeactivatedAndUnsupportedProductItems(List<RnRForm> rnRForms) throws LMISException { for (RnRForm rnRForm : rnRForms) { String programCode = rnRForm.getProgram().getProgramCode(); List<String> programCodes = programRepository.queryProgramCodesByProgramCodeOrParentCode(programCode); List<String> supportedProductCodes = FluentIterable.from(productProgramRepository.listActiveProductProgramsByProgramCodes(programCodes)).transform(new Function<ProductProgram, String>() { @Override public String apply(ProductProgram productProgram) { return productProgram.getProductCode(); } }).toList(); rnrFormItemRepository.deleteFormItems(rnRForm.getDeactivatedAndUnsupportedProductItems(supportedProductCodes)); } } @Inject  RnrFormRepository(Context context); RnRForm initNormalRnrForm(Date periodEndDate); RnRForm initEmergencyRnrForm(Date periodEndDate, List<StockCard> stockCards); void create(RnRForm rnRForm); void createRnRsWithItems(final List<RnRForm> forms); void createOrUpdateWithItems(final RnRForm form); boolean isPeriodUnique(final RnRForm form); List<RnRForm> list(); List<RnRForm> listInclude(RnRForm.Emergency includeEmergency, String programCode); List<RnRForm> listInclude(RnRForm.Emergency includeEmergency, String programCode, ReportTypeForm reportTypeForm); List<RnRForm> queryAllUnsyncedForms(); RnRForm queryUnAuthorized(); RnRForm queryRnRForm(final long id); List<RnrFormItem> generateRnrFormItems(final RnRForm form, List<StockCard> stockCards); void removeRnrForm(RnRForm form); boolean hasRequisitionData(); boolean hasOldDate(); List<RnRForm> listNotSynchronizedFromReportStartTime(String programCode); void createAndRefresh(RnRForm rnRForm); void deleteOldData(); void deleteRnrFormDirtyData(List<String> productCodeList); @Inject
    public StockMovementRepository stockMovementRepository; }