aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseanbeirne <sean.beirne@est.tech>2023-03-30 19:16:28 +0100
committerSean Beirne <sean.beirne@est.tech>2023-04-03 12:03:13 +0000
commit32b63e325892a9d8fad881a601095971d1e84fbe (patch)
tree160fc3e622a8e710d2e92dc642f440a945f3d74e
parent120686f7b5ff0ff873335905593b1e58be0133da (diff)
500 Error Response on NCMP ID-Searches Testing
Issue-ID: CPS-1563 Signed-off-by: seanbeirne <sean.beirne@est.tech> Change-Id: Idc393e90d31b369095bc2b122537e17a4464a364
-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 88f496a188..300026d34a 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 = '{}'