diff options
Diffstat (limited to 'components/datalake-handler')
2 files changed, 5 insertions, 4 deletions
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java index 49439e60..058d4ca9 100644 --- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java +++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java @@ -211,17 +211,17 @@ public class DbController { } //Update Db - @PutMapping("") + @PutMapping("/{id}") @ResponseBody @ApiOperation(value="Update a database.") - public PostReturnBody<DbConfig> updateDb(@RequestBody DbConfig dbConfig, BindingResult result, HttpServletResponse response) throws IOException { + public PostReturnBody<DbConfig> updateDb(@PathVariable int id, @RequestBody DbConfig dbConfig, BindingResult result, HttpServletResponse response) throws IOException { if (result.hasErrors()) { sendError(response, 400, "Error parsing DB: " + result.toString()); return null; } - Db oldDb = dbRepository.findById(dbConfig.getId()).get(); + Db oldDb = dbRepository.findById(id).get(); if (oldDb == null) { sendError(response, 404, DB_NOT_FOUND + dbConfig.getName()); return null; diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java index c46a026b..9318ee00 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java @@ -69,6 +69,7 @@ public class DbControllerTest { public DbConfig getDbConfig() { DbConfig dbConfig = new DbConfig(); + dbConfig.setId(1); dbConfig.setName("Elecsticsearch"); dbConfig.setHost("localhost"); dbConfig.setLogin("root"); @@ -112,7 +113,7 @@ public class DbControllerTest { DbController dbController = new DbController(); DbConfig dbConfig = getDbConfig(); when(mockBindingResult.hasErrors()).thenReturn(true); - PostReturnBody<DbConfig> db = dbController.updateDb(dbConfig, mockBindingResult, + PostReturnBody<DbConfig> db = dbController.updateDb(dbConfig.getId(), dbConfig, mockBindingResult, httpServletResponse); assertEquals(null, db); //when(mockBindingResult.hasErrors()).thenReturn(false); |