Skip to content
Permalink
Browse files

Merge pull request #47 from OpenWiseSolutions/feature/OHFJIRA-55-impr…

…ovement

OHFJIRA-55 - DB config params endpoint improvements
  • Loading branch information
hanusto committed Apr 11, 2017
2 parents 9d86dc6 + eb17ab6 commit e0a40de8aa5d0ec0c7d53dd9df86daabccdd7241
@@ -91,17 +91,20 @@ public DbConfigurationParamRpc getByCode(@PathVariable final String code) throws
* @throws ValidationIntegrationException if input object has wrong values
* @throws NoDataFoundException entity not found for update
*/
@RequestMapping(method = RequestMethod.PUT, produces = {"application/xml", "application/json"})
// .+ is workaround how to match everything after / as code of config parameters, otherwise last .* is removed as
// file extension
@RequestMapping(value = "/{code:.+}", method = RequestMethod.PUT, produces = {"application/xml", "application/json"})
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public void update(@RequestBody final DbConfigurationParamRpc paramRpc) throws ValidationIntegrationException,
public void update(@PathVariable final String code, @RequestBody final DbConfigurationParamRpc paramRpc) throws
ValidationIntegrationException,
NoDataFoundException {

Assert.notNull(paramRpc, "paramRpc can not be null");
Assert.notNull(paramRpc.getId(), "This method is only for update existing paramRpc.");
Assert.isNull(paramRpc.getCode(), "code of paramRpc must be null, object is referenced by path attribute");

// get entity to update it
DbConfigurationParam dbParam = getParam(paramRpc.getId());
DbConfigurationParam dbParam = getParam(code);
paramRpc.updateEntity(dbParam);

// save entity
@@ -96,16 +96,14 @@ public void testFindAll() throws Exception {

@Test
public void testUpdate() throws Exception {
final URIBuilder uriBuilder = createGetUrl(ROOT_URI);
final URIBuilder uriBuilder = createGetUrl(ROOT_URI + "/" + param.getCode());

JsonObject request = createJson()
.add("id", param.getId())
.add("code", param.getCode())
.add("currentValue", "222")
.add("defaultValue", "10")
.build();

// performs PUT: /api/config-params
// performs PUT: /api/config-params/ohf.async.concurrentConsumers
mockMvc.perform(put(toUrl(uriBuilder))
.content(request.toString())
.contentType(MediaType.APPLICATION_JSON)
@@ -124,11 +122,9 @@ public void testUpdate() throws Exception {

@Test
public void testUpdate_wrongValueType() throws Exception {
final URIBuilder uriBuilder = createGetUrl(ROOT_URI);
final URIBuilder uriBuilder = createGetUrl(ROOT_URI + "/" + param.getCode());

JsonObject request = createJson()
.add("id", param.getId())
.add("code", param.getCode())
.add("currentValue", "abc")
.build();

0 comments on commit e0a40de

Please sign in to comment.
You can’t perform that action at this time.