@Test public void shouldGetMasterColumnListForRnR() { List<RnrColumn> allColumns = new ArrayList<>(); when(rnrTemplateService.fetchAllRnRColumns(existingProgramId)).thenReturn(allColumns); RnrTemplateForm rnrColumns = rnrTemplateController.fetchAllProgramRnrColumnList(existingProgramId); verify(rnrTemplateService).fetchAllRnRColumns(existingProgramId); assertThat(rnrColumns.getRnrColumns(), is(allColumns)); }
@RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") public RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId) { List<RnRColumnSource> sources = new ArrayList<>(); sources.add(RnRColumnSource.USER_INPUT); sources.add(RnRColumnSource.CALCULATED); return new RnrTemplateForm(rnrTemplateService.fetchAllRnRColumns(programId), sources); }
RnrTemplateController extends BaseController { @RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") public RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId) { List<RnRColumnSource> sources = new ArrayList<>(); sources.add(RnRColumnSource.USER_INPUT); sources.add(RnRColumnSource.CALCULATED); return new RnrTemplateForm(rnrTemplateService.fetchAllRnRColumns(programId), sources); } }
RnrTemplateController extends BaseController { @RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") public RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId) { List<RnRColumnSource> sources = new ArrayList<>(); sources.add(RnRColumnSource.USER_INPUT); sources.add(RnRColumnSource.CALCULATED); return new RnrTemplateForm(rnrTemplateService.fetchAllRnRColumns(programId), sources); }  }
RnrTemplateController extends BaseController { @RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") public RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId) { List<RnRColumnSource> sources = new ArrayList<>(); sources.add(RnRColumnSource.USER_INPUT); sources.add(RnRColumnSource.CALCULATED); return new RnrTemplateForm(rnrTemplateService.fetchAllRnRColumns(programId), sources); }  @RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId); @RequestMapping(value = "/rnr/{programId}/columns", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CREATE_REQUISITION, AUTHORIZE_REQUISITION, APPROVE_REQUISITION, VIEW_REQUISITION')") List<RnrColumn> fetchColumnsForRequisition(@PathVariable("programId") Long programId); @RequestMapping(value = "/program/{programId}/rnr-template", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") ResponseEntity<OpenLmisResponse> saveRnRTemplateForProgram(@PathVariable("programId") Long programId,
                                                                    @RequestBody RnrColumnList rnrColumnList,
                                                                    HttpServletRequest request); }
RnrTemplateController extends BaseController { @RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") public RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId) { List<RnRColumnSource> sources = new ArrayList<>(); sources.add(RnRColumnSource.USER_INPUT); sources.add(RnRColumnSource.CALCULATED); return new RnrTemplateForm(rnrTemplateService.fetchAllRnRColumns(programId), sources); }  @RequestMapping(value = "/program/{programId}/rnr-template", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") RnrTemplateForm fetchAllProgramRnrColumnList(@PathVariable("programId") Long programId); @RequestMapping(value = "/rnr/{programId}/columns", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CREATE_REQUISITION, AUTHORIZE_REQUISITION, APPROVE_REQUISITION, VIEW_REQUISITION')") List<RnrColumn> fetchColumnsForRequisition(@PathVariable("programId") Long programId); @RequestMapping(value = "/program/{programId}/rnr-template", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'CONFIGURE_RNR')") ResponseEntity<OpenLmisResponse> saveRnRTemplateForProgram(@PathVariable("programId") Long programId,
                                                                    @RequestBody RnrColumnList rnrColumnList,
                                                                    HttpServletRequest request); static final String RNR_TEMPLATE_SAVE_SUCCESS; }