@Test public void shouldGetAllRegimenCategories() throws Exception { List<RegimenCategory> expectedRegimenCategories = new ArrayList<>(); when(regimenService.getAllRegimenCategories()).thenReturn(expectedRegimenCategories); ResponseEntity<OpenLmisResponse> response = controller.getAllRegimenCategories(); assertThat((List<RegimenCategory>) response.getBody().getData().get(REGIMEN_CATEGORIES), is(expectedRegimenCategories)); verify(regimenService).getAllRegimenCategories(); }
@RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") public ResponseEntity<OpenLmisResponse> getAllRegimenCategories() { try { ResponseEntity<OpenLmisResponse> response; List<RegimenCategory> regimenCategories = regimenService.getAllRegimenCategories(); response = response(REGIMEN_CATEGORIES, regimenCategories); return response; } catch (DataException dataException) { return error(UNEXPECTED_EXCEPTION, HttpStatus.BAD_REQUEST); } }
RegimenController extends BaseController { @RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") public ResponseEntity<OpenLmisResponse> getAllRegimenCategories() { try { ResponseEntity<OpenLmisResponse> response; List<RegimenCategory> regimenCategories = regimenService.getAllRegimenCategories(); response = response(REGIMEN_CATEGORIES, regimenCategories); return response; } catch (DataException dataException) { return error(UNEXPECTED_EXCEPTION, HttpStatus.BAD_REQUEST); } } }
RegimenController extends BaseController { @RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") public ResponseEntity<OpenLmisResponse> getAllRegimenCategories() { try { ResponseEntity<OpenLmisResponse> response; List<RegimenCategory> regimenCategories = regimenService.getAllRegimenCategories(); response = response(REGIMEN_CATEGORIES, regimenCategories); return response; } catch (DataException dataException) { return error(UNEXPECTED_EXCEPTION, HttpStatus.BAD_REQUEST); } }  }
RegimenController extends BaseController { @RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") public ResponseEntity<OpenLmisResponse> getAllRegimenCategories() { try { ResponseEntity<OpenLmisResponse> response; List<RegimenCategory> regimenCategories = regimenService.getAllRegimenCategories(); response = response(REGIMEN_CATEGORIES, regimenCategories); return response; } catch (DataException dataException) { return error(UNEXPECTED_EXCEPTION, HttpStatus.BAD_REQUEST); } }  @Transactional @RequestMapping(value = "/programId/{programId}/regimens", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") ResponseEntity<OpenLmisResponse> save(@PathVariable Long programId, @RequestBody RegimenFormDTO regimenFormDTO, HttpServletRequest request); @RequestMapping(value = "/programId/{programId}/regimens", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") ResponseEntity<OpenLmisResponse> getByProgram(@PathVariable("programId") Long programId); @RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") ResponseEntity<OpenLmisResponse> getAllRegimenCategories(); }
RegimenController extends BaseController { @RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") public ResponseEntity<OpenLmisResponse> getAllRegimenCategories() { try { ResponseEntity<OpenLmisResponse> response; List<RegimenCategory> regimenCategories = regimenService.getAllRegimenCategories(); response = response(REGIMEN_CATEGORIES, regimenCategories); return response; } catch (DataException dataException) { return error(UNEXPECTED_EXCEPTION, HttpStatus.BAD_REQUEST); } }  @Transactional @RequestMapping(value = "/programId/{programId}/regimens", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") ResponseEntity<OpenLmisResponse> save(@PathVariable Long programId, @RequestBody RegimenFormDTO regimenFormDTO, HttpServletRequest request); @RequestMapping(value = "/programId/{programId}/regimens", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") ResponseEntity<OpenLmisResponse> getByProgram(@PathVariable("programId") Long programId); @RequestMapping(value = "/regimenCategories", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REGIMEN_TEMPLATE')") ResponseEntity<OpenLmisResponse> getAllRegimenCategories(); static final String REGIMENS_SAVED_SUCCESSFULLY; static final String REGIMENS; static final String REGIMEN_CATEGORIES; }