summaryrefslogtreecommitdiffstats
path: root/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-07-06 10:32:17 +0100
committerniamhcore <niamh.core@est.tech>2021-07-15 14:45:34 +0100
commit71a61bb124a906e6327e78f45ecc9a0f7b1ec0dc (patch)
treef698e7721ca1fc142afcfcea3abb86ab718b8e14 /src/test/groovy/org/onap
parenta5d8ca42affd04c0cab589a83c8c95b0712f0874 (diff)
Implement Plugin Registration in DMI-Plugin
- Refactor ncmp/dmi package Issue-ID: CPS-405 Issue-ID: CPS-499 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: I0a7ab9bb0ca3861b171388613c44f7bc6e7f9aa9
Diffstat (limited to 'src/test/groovy/org/onap')
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/ControllerSecuritySpec.groovy (renamed from src/test/groovy/org/onap/cps/ncmp/rest/controller/ControllerSecuritySpec.groovy)2
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy (renamed from src/test/groovy/org/onap/cps/ncmp/rest/controller/DmiRestControllerSpec.groovy)5
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy (renamed from src/test/groovy/org/onap/cps/ncmp/service/DmiServiceImplSpec.groovy)2
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy56
4 files changed, 61 insertions, 4 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/rest/controller/ControllerSecuritySpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/ControllerSecuritySpec.groovy
index 6536de7a..14ab7147 100644
--- a/src/test/groovy/org/onap/cps/ncmp/rest/controller/ControllerSecuritySpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/ControllerSecuritySpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.rest.controller
+package org.onap.cps.ncmp.dmi.rest.controller
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
diff --git a/src/test/groovy/org/onap/cps/ncmp/rest/controller/DmiRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
index 2271bb46..f8b4c015 100644
--- a/src/test/groovy/org/onap/cps/ncmp/rest/controller/DmiRestControllerSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
@@ -18,11 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.rest.controller
+package org.onap.cps.ncmp.dmi.rest.controller
+
+import org.onap.cps.ncmp.dmi.service.DmiService
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
-import org.onap.cps.ncmp.service.DmiService
import org.spockframework.spring.SpringBean
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.http.HttpStatus
diff --git a/src/test/groovy/org/onap/cps/ncmp/service/DmiServiceImplSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
index 85303f4b..2124c9b4 100644
--- a/src/test/groovy/org/onap/cps/ncmp/service/DmiServiceImplSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.service
+package org.onap.cps.ncmp.dmi.service
import spock.lang.Specification
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy
new file mode 100644
index 00000000..4f929865
--- /dev/null
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.service.client
+
+import org.onap.cps.ncmp.dmi.config.CpsConfiguration
+import org.springframework.http.ResponseEntity
+import org.springframework.web.client.RestTemplate
+import spock.lang.Specification
+
+class NcmpRestClientSpec extends Specification {
+ def objectUnderTest = new NcmpRestClient(mockCpsProperties, mockRestTemplate)
+ def mockCpsProperties = Mock(CpsConfiguration.CpsProperties)
+ def mockRestTemplate = Mock(RestTemplate)
+
+ def setup() {
+ objectUnderTest.cpsProperties = mockCpsProperties
+ objectUnderTest.restTemplate = mockRestTemplate
+ }
+
+ def 'Register a cm handle.'() {
+ given: 'json data'
+ def jsonData = 'some json'
+ and: 'configuration data'
+ mockCpsProperties.baseUrl >> 'http://some-uri'
+ mockCpsProperties.dmiRegistrationUrl >> 'some-url'
+ mockCpsProperties.authUsername >> 'some-username'
+ mockCpsProperties.authPassword >> 'some-password'
+ and: 'the rest template returns a valid response entity'
+ def mockResponseEntity = Mock(ResponseEntity)
+ when: 'registerCmHandle is invoked'
+ def result = objectUnderTest.registerCmHandlesWithNcmp(jsonData)
+ then: 'the rest template is called with the correct uri and json in the body'
+ 1 * mockRestTemplate.postForEntity({ it.toString() == 'http://some-uri/some-url' },
+ { it.body.contains(jsonData) }, String.class) >> mockResponseEntity
+ and: 'the output of the method is the same as the output from the test template'
+ result == mockResponseEntity
+ }
+} \ No newline at end of file