@Test public void shouldSaveRnRTemplateForAProgramWithGivenColumns() throws Exception { ProgramRnrTemplate programRnrTemplate = mock(ProgramRnrTemplate.class); List<? extends Column> rnrColumns = new ArrayList<>(); doReturn(rnrColumns).when(programRnrTemplate).getColumns(); when(programRnrTemplate.getProgramId()).thenReturn(1L); when(programRnrTemplate.validateToSave()).thenReturn(new HashMap<String, OpenLmisMessage>()); service.saveRnRTemplateForProgram(programRnrTemplate); verify(repository).saveProgramRnrTemplate(programRnrTemplate); verify(programService).setTemplateConfigured(1L); }
@Transactional public Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate) { Map<String, OpenLmisMessage> errors = programTemplate.validateToSave(); if (errors.isEmpty()) { rnrRepository.saveProgramRnrTemplate(programTemplate); programService.setTemplateConfigured(programTemplate.getProgramId()); } return errors; }
RnrTemplateService { @Transactional public Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate) { Map<String, OpenLmisMessage> errors = programTemplate.validateToSave(); if (errors.isEmpty()) { rnrRepository.saveProgramRnrTemplate(programTemplate); programService.setTemplateConfigured(programTemplate.getProgramId()); } return errors; } }
RnrTemplateService { @Transactional public Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate) { Map<String, OpenLmisMessage> errors = programTemplate.validateToSave(); if (errors.isEmpty()) { rnrRepository.saveProgramRnrTemplate(programTemplate); programService.setTemplateConfigured(programTemplate.getProgramId()); } return errors; }  }
RnrTemplateService { @Transactional public Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate) { Map<String, OpenLmisMessage> errors = programTemplate.validateToSave(); if (errors.isEmpty()) { rnrRepository.saveProgramRnrTemplate(programTemplate); programService.setTemplateConfigured(programTemplate.getProgramId()); } return errors; }  List<RnrColumn> fetchAllRnRColumns(Long programId); @Transactional Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate); List<RnrColumn> fetchColumnsForRequisition(Long programId); ProgramRnrTemplate fetchProgramTemplate(Long programId); ProgramRnrTemplate fetchProgramTemplateForRequisition(Long programId); }
RnrTemplateService { @Transactional public Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate) { Map<String, OpenLmisMessage> errors = programTemplate.validateToSave(); if (errors.isEmpty()) { rnrRepository.saveProgramRnrTemplate(programTemplate); programService.setTemplateConfigured(programTemplate.getProgramId()); } return errors; }  List<RnrColumn> fetchAllRnRColumns(Long programId); @Transactional Map<String, OpenLmisMessage> saveRnRTemplateForProgram(ProgramRnrTemplate programTemplate); List<RnrColumn> fetchColumnsForRequisition(Long programId); ProgramRnrTemplate fetchProgramTemplate(Long programId); ProgramRnrTemplate fetchProgramTemplateForRequisition(Long programId);  }