summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest/src/test/groovy
diff options
context:
space:
mode:
authorSourabh Sourabh <sourabh.sourabh@est.tech>2022-09-01 14:40:03 +0000
committerGerrit Code Review <gerrit@onap.org>2022-09-01 14:40:03 +0000
commit33236ba508ca3536dbacce944b19f880aa6ff944 (patch)
tree527fdbe2ada77f91b147469adeea165710ce7d17 /cps-ncmp-rest/src/test/groovy
parent673a8578e6c381589e137c92415644722b5ca354 (diff)
parentd340047f82a8301453fc3872e474090366b68472 (diff)
Merge "Get all cm handles by DMI plugin Identifier"
Diffstat (limited to 'cps-ncmp-rest/src/test/groovy')
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy19
1 files changed, 19 insertions, 0 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 6673b2172f..b5a089bba3 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
@@ -27,6 +27,7 @@ import org.onap.cps.ncmp.api.NetworkCmProxyDataService
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse
+import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
import org.onap.cps.ncmp.rest.model.CmHandlerRegistrationErrorResponse
import org.onap.cps.ncmp.rest.model.DmiPluginRegistrationErrorResponse
import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration
@@ -41,6 +42,7 @@ import org.springframework.http.MediaType
import org.springframework.test.web.servlet.MockMvc
import spock.lang.Specification
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
@WebMvcTest(NetworkCmProxyInventoryController)
@@ -158,6 +160,23 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
'update delete failed' | successResponse('cm-handle-1') | failedResponse('cm-handle-2') | failedResponse('cm-handle-3') || [] | [failedRestResponse('cm-handle-2')] | [failedRestResponse('cm-handle-3')]
}
+ def 'Get all cm handle IDs by DMI plugin identifier.'() {
+ given: 'an endpoint for returning cm handle IDs for a registered dmi plugin'
+ def getUrl = "$ncmpBasePathV1/ch/cmHandles?dmi-plugin-identifier=some-dmi-plugin-identifier"
+ and: 'a collection of cm handle IDs are returned'
+ 1 * mockNetworkCmProxyDataService.getAllCmHandleIdsByDmiPluginIdentifier('some-dmi-plugin-identifier')
+ >> ['cm-handle-id-1','cm-handle-id-2']
+ when: 'the endpoint is invoked'
+ def response = mvc.perform(
+ get(getUrl)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON_VALUE)
+ ).andReturn().response
+ then: 'the response matches the result returned by the service layer'
+ assert response.contentAsString.contains('cm-handle-id-1')
+ assert response.contentAsString.contains('cm-handle-id-2')
+ }
+
def failedRestResponse(cmHandle) {
return new CmHandlerRegistrationErrorResponse('cmHandle': cmHandle, 'errorCode': '00', 'errorText': 'Failed')
}