aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Gleeson <luke.gleeson@est.tech>2023-04-04 14:04:53 +0000
committerGerrit Code Review <gerrit@onap.org>2023-04-04 14:04:53 +0000
commiteb4efdc380180940e059724db12400d68d3f8f69 (patch)
tree5e0e6c3c60ceb04cb0246296e2890806852b6326
parent0497e296afb24523d94ce78e9202a4e28a41d7fc (diff)
parent32b63e325892a9d8fad881a601095971d1e84fbe (diff)
Merge "500 Error Response on NCMP ID-Searches Testing"
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy44
1 files changed, 43 insertions, 1 deletions
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
index 88f496a18..300026d34 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 Bell Canada
- * Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2021-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,6 +129,48 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
'populates response' | ['cmHandle1', 'cmHandle2']
}
+ def 'CmHandle search endpoint test #scenario with blank cmHandleQueryParameters.'() {
+ given: 'a query object'
+ def cmHandleQueryParameters = "{}"
+ and: 'the mapper service returns a converted object'
+ ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters
+ and: 'the service returns the desired results'
+ mockNetworkCmProxyDataService.executeCmHandleIdSearchForInventory(cmHandleQueryServiceParameters) >> serviceMockResponse
+ when: 'post request is performed & search is called with the given request parameters'
+ def response = mvc.perform(
+ post("$ncmpBasePathV1/ch/searches")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(cmHandleQueryParameters)
+ ).andReturn().response
+ then: 'response status is OK'
+ assert response.status == HttpStatus.OK.value()
+ and: 'the response data matches the service response.'
+ jsonObjectMapper.convertJsonString(response.getContentAsString(), List) == serviceMockResponse
+ where: 'the service respond with'
+ scenario | serviceMockResponse
+ 'empty response' | []
+ 'populates response' | ['cmHandle1', 'cmHandle2']
+ }
+
+ def 'CmHandle search endpoint Error Handling.'() {
+ given: 'the mapper service returns a converted object'
+ ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters
+ and: 'the service returns the desired results'
+ mockNetworkCmProxyDataService.executeCmHandleIdSearchForInventory(cmHandleQueryServiceParameters) >> []
+ when: 'post request is performed & search is called with the given request parameters'
+ def response = mvc.perform(
+ post("$ncmpBasePathV1/ch/searches")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(cmHandleQueryParameters)
+ ).andReturn().response
+ then: 'response status is BAD_REQUEST'
+ assert response.status == HttpStatus.BAD_REQUEST.value()
+ where: 'the cmHandleQueryParameters are'
+ scenario | cmHandleQueryParameters
+ 'empty string' | ""
+ 'non-json string' | "this is a test"
+ }
+
def 'DMI Registration: All cm-handles operations processed successfully.'() {
given: 'a dmi plugin registration'
def dmiRegistrationRequest = '{}'