@Test public void shouldGetSettingByKey() throws Exception { ConfigurationSetting setting = new ConfigurationSetting(); when(configurationService.getByKey("123")).thenReturn(setting); ResponseEntity<OpenLmisResponse> expectResponse = new ResponseEntity<>(new OpenLmisResponse(), HttpStatus.OK); when(OpenLmisResponse.response("settings", setting)).thenReturn(expectResponse); ResponseEntity<OpenLmisResponse> response = controller.getByKey("123"); verify(configurationService).getByKey("123"); assertThat(response, is(expectResponse)); }
@RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") public ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key) { return OpenLmisResponse.response(SETTINGS, configurationService.getByKey(key) ); }
SettingController extends BaseController { @RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") public ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key) { return OpenLmisResponse.response(SETTINGS, configurationService.getByKey(key) ); } }
SettingController extends BaseController { @RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") public ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key) { return OpenLmisResponse.response(SETTINGS, configurationService.getByKey(key) ); }  }
SettingController extends BaseController { @RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") public ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key) { return OpenLmisResponse.response(SETTINGS, configurationService.getByKey(key) ); }  @RequestMapping(value = "/settings", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SETTING')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key); @RequestMapping(value = "/saveSettings", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SETTING')") ResponseEntity<OpenLmisResponse> updateSettings(@RequestBody ConfigurationDTO settings); }
SettingController extends BaseController { @RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") public ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key) { return OpenLmisResponse.response(SETTINGS, configurationService.getByKey(key) ); }  @RequestMapping(value = "/settings", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SETTING')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "/settings/{key}", method = RequestMethod.GET, headers = "Accept=application/json") ResponseEntity<OpenLmisResponse> getByKey(@PathVariable(value = "key") String key); @RequestMapping(value = "/saveSettings", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SETTING')") ResponseEntity<OpenLmisResponse> updateSettings(@RequestBody ConfigurationDTO settings); static final String SETTINGS; }