diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2021-04-28 12:13:34 +0100 |
---|---|---|
committer | ToineSiebelink <toine.siebelink@est.tech> | 2021-04-28 16:44:12 +0100 |
commit | ff7ba3a74265b62b116abb2fc34767f87444a655 (patch) | |
tree | 2028f142f8e1a27e2a34d9783207d6a9cfa27571 /cps-rest/src/test/groovy | |
parent | a439dfa869d7ba55daeb97ae16735c3fd0a12985 (diff) |
- Remove redundant and misleading tests
- Some small improvemnt to tets ins same class
Issue-ID: CPS-325
Change-Id: I0d888dbd9db555508b23e37957098b7b4d518912
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-rest/src/test/groovy')
-rwxr-xr-x | cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy index 299299ce28..b7337e02a5 100755 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy @@ -174,27 +174,7 @@ class DataRestControllerSpec extends Specification { 'no descendant explicitly' | dataNodeWithLeavesNoChildren | 'false' || OMIT_DESCENDANTS | false 'with descendants' | dataNodeWithChild | 'true' || INCLUDE_ALL_DESCENDANTS | true } - - @Unroll - def 'Get data node error scenario: #scenario.'() { - given: 'the service throws an exception' - def endpoint = "$dataNodeBaseEndpoint/anchors/$anchorName/node" - mockCpsDataService.getDataNode(dataspaceName, anchorName, xpath, _) >> { throw exception } - when: 'get request is performed through REST API' - def response = - mvc.perform(get(endpoint).param("xpath", xpath)) - .andReturn().response - then: 'a success response is returned' - response.status == httpStatus.value() - where: - scenario | xpath | exception || httpStatus - 'no dataspace' | '/x-path' | new DataspaceNotFoundException('') || HttpStatus.BAD_REQUEST - 'no anchor' | '/x-path' | new AnchorNotFoundException('', '') || HttpStatus.BAD_REQUEST - 'no data' | '/x-path' | new DataNodeNotFoundException('', '', '') || HttpStatus.NOT_FOUND - 'root path' | '/' | new DataNodeNotFoundException('', '') || HttpStatus.NOT_FOUND - 'already defined' | '/x-path' | new AlreadyDefinedException('', new Throwable()) || HttpStatus.CONFLICT - } - + @Unroll def 'Update data node leaves: #scenario.'() { given: 'json data' @@ -206,16 +186,17 @@ class DataRestControllerSpec extends Specification { patch(endpoint) .contentType(MediaType.APPLICATION_JSON) .content(jsonData) - .param('xpath', xpath) + .param('xpath', inputXpath) ).andReturn().response then: 'the service method is invoked with expected parameters' 1 * mockCpsDataService.updateNodeLeaves(dataspaceName, anchorName, xpathServiceParameter, jsonData) and: 'response status indicates success' response.status == HttpStatus.OK.value() where: - scenario | xpath | xpathServiceParameter - 'root node by default' | '' | '/' - 'node by parent xpath' | '/xpath' | '/xpath' + scenario | inputXpath || xpathServiceParameter + 'root node by default' | '' || '/' + 'root node by choice' | '/' || '/' + 'some xpath by parent' | '/some/xpath' || '/some/xpath' } @Unroll @@ -229,15 +210,16 @@ class DataRestControllerSpec extends Specification { put(endpoint) .contentType(MediaType.APPLICATION_JSON) .content(jsonData) - .param('xpath', xpath)) + .param('xpath', inputXpath)) .andReturn().response then: 'the service method is invoked with expected parameters' 1 * mockCpsDataService.replaceNodeTree(dataspaceName, anchorName, xpathServiceParameter, jsonData) and: 'response status indicates success' response.status == HttpStatus.OK.value() where: - scenario | xpath | xpathServiceParameter - 'root node by default' | '' | '/' - 'node by parent xpath' | '/xpath' | '/xpath' + scenario | inputXpath || xpathServiceParameter + 'root node by default' | '' || '/' + 'root node by choice' | '/' || '/' + 'some xpath by parent' | '/some/xpath' || '/some/xpath' } } |