@Test public void shouldSaveBudgetFileLineItem() throws Exception { configuration.setHeaderInFile(true); when(listReader.getRowNumber()).thenReturn(2, 3); String budgetFileName = "BudgetFileName"; when(budgetFile.getName()).thenReturn(budgetFileName); BudgetFileInfo budgetFileInfo = new BudgetFileInfo(); budgetFileInfo.setId(1L); whenNew(BudgetFileInfo.class).withArguments(budgetFileName, false).thenReturn(budgetFileInfo); mockStatic(BudgetLineItemDTO.class); BudgetLineItemDTO lineItemDTO = mock(BudgetLineItemDTO.class); when(lineItemDTO.getFacilityCode()).thenReturn("F10"); when(lineItemDTO.getProgramCode()).thenReturn("HIV"); when(BudgetLineItemDTO.populate(csvRow, ediFileTemplate.getColumns())).thenReturn(lineItemDTO); Facility facility = new Facility(); facility.setCode("F10"); when(facilityService.getByCode(facility)).thenReturn(facility); Program program = new Program(); when(programService.getByCode("HIV")).thenReturn(program); BudgetLineItem budgetLineItem = mock(BudgetLineItem.class); ProcessingPeriod processingPeriod = mock(ProcessingPeriod.class); when(processingScheduleService.getPeriodForDate(facility, program, budgetLineItem.getPeriodDate())).thenReturn(processingPeriod); when(transformer.transform(lineItemDTO, dateFormat, 1)).thenReturn(budgetLineItem); budgetFileProcessor.process(message); verify(transformer).transform(lineItemDTO, dateFormat, 1); verify(budgetLineItem).setBudgetFileId(budgetFileInfo.getId()); verify(budgetLineItemService).save(budgetLineItem); verify(BudgetLineItemDTO.populate(csvRow, ediFileTemplate.getColumns())); }
public void process(Message message) throws Exception { File budgetFile = (File) message.getPayload(); logger.debug("processing Budget File " + budgetFile.getName()); BudgetFileInfo budgetFileInfo = saveBudgetFile(budgetFile, false); Boolean processingError = getSpringProxy().processBudgetFile(budgetFile, budgetFileInfo); budgetFileInfo.setProcessingError(processingError); budgetFilePostProcessHandler.process(budgetFileInfo, budgetFile); }
BudgetFileProcessor { public void process(Message message) throws Exception { File budgetFile = (File) message.getPayload(); logger.debug("processing Budget File " + budgetFile.getName()); BudgetFileInfo budgetFileInfo = saveBudgetFile(budgetFile, false); Boolean processingError = getSpringProxy().processBudgetFile(budgetFile, budgetFileInfo); budgetFileInfo.setProcessingError(processingError); budgetFilePostProcessHandler.process(budgetFileInfo, budgetFile); } }
BudgetFileProcessor { public void process(Message message) throws Exception { File budgetFile = (File) message.getPayload(); logger.debug("processing Budget File " + budgetFile.getName()); BudgetFileInfo budgetFileInfo = saveBudgetFile(budgetFile, false); Boolean processingError = getSpringProxy().processBudgetFile(budgetFile, budgetFileInfo); budgetFileInfo.setProcessingError(processingError); budgetFilePostProcessHandler.process(budgetFileInfo, budgetFile); }  }
BudgetFileProcessor { public void process(Message message) throws Exception { File budgetFile = (File) message.getPayload(); logger.debug("processing Budget File " + budgetFile.getName()); BudgetFileInfo budgetFileInfo = saveBudgetFile(budgetFile, false); Boolean processingError = getSpringProxy().processBudgetFile(budgetFile, budgetFileInfo); budgetFileInfo.setProcessingError(processingError); budgetFilePostProcessHandler.process(budgetFileInfo, budgetFile); }  void process(Message message); @Transactional Boolean processBudgetFile(File budgetFile, BudgetFileInfo budgetFileInfo); }
BudgetFileProcessor { public void process(Message message) throws Exception { File budgetFile = (File) message.getPayload(); logger.debug("processing Budget File " + budgetFile.getName()); BudgetFileInfo budgetFileInfo = saveBudgetFile(budgetFile, false); Boolean processingError = getSpringProxy().processBudgetFile(budgetFile, budgetFileInfo); budgetFileInfo.setProcessingError(processingError); budgetFilePostProcessHandler.process(budgetFileInfo, budgetFile); }  void process(Message message); @Transactional Boolean processBudgetFile(File budgetFile, BudgetFileInfo budgetFileInfo);  }