summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-08-27 15:01:27 +0100
committertragait <rahul.tyagi@est.tech>2021-08-27 15:54:12 +0100
commit11e9f72aa953516053d867e09a0e95c77d7d1a88 (patch)
tree479abde74710469550e9c486a0d834b7c0b416ab /src
parent528022a0f33225f3eab6930ff27c3ab8d1638568 (diff)
fix getforentity in onap DMI plugin
Issue-ID: CPS-573 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: Idb2186e6f3275530513bbd5e788c98b4ceda9d10
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java4
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy7
-rw-r--r--src/test/resources/ModuleSchema.json2
4 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java b/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java
index 1794dedf..5945168b 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java
@@ -20,6 +20,7 @@
package org.onap.cps.ncmp.dmi.model;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@@ -30,5 +31,6 @@ import lombok.Setter;
@Setter
public class ModuleSchemas {
+ @JsonProperty("ietf-netconf-monitoring:schemas")
private ModuleSchemaList schemas;
}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
index fe13a38d..bbc39da5 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
@@ -23,6 +23,7 @@ package org.onap.cps.ncmp.dmi.service.client;
import org.onap.cps.ncmp.dmi.config.DmiConfiguration.SdncProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@@ -60,7 +61,8 @@ public class SdncRestconfClient {
final String sdncRestconfUrl = sdncBaseUrl.concat(getResourceUrl);
httpHeaders.setBasicAuth(sdncProperties.getAuthUsername(), sdncProperties.getAuthPassword());
final var httpEntity = new HttpEntity<>(httpHeaders);
- return restTemplate.getForEntity(sdncRestconfUrl, String.class, httpEntity);
+ return restTemplate.exchange(sdncRestconfUrl,
+ HttpMethod.GET, httpEntity, String.class);
}
/**
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
index 9a7ed180..b550480d 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
@@ -23,6 +23,7 @@ package org.onap.cps.ncmp.dmi.service.client
import org.onap.cps.ncmp.dmi.config.DmiConfiguration
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
+import org.springframework.http.HttpMethod
import org.springframework.http.ResponseEntity
import org.springframework.web.client.RestTemplate
import spock.lang.Specification
@@ -40,7 +41,8 @@ class SdncRestconfClientSpec extends Specification {
setupTestConfigurationData()
and: 'the rest template returns a valid response entity'
def mockResponseEntity = Mock(ResponseEntity)
- mockRestTemplate.getForEntity({ it.toString() == 'http://some-uri/getResourceUrl' }, String.class, _ as HttpEntity) >> mockResponseEntity
+ mockRestTemplate.exchange({ it.toString() == 'http://some-uri/getResourceUrl' },
+ HttpMethod.GET, _ as HttpEntity, String.class) >> mockResponseEntity
when: 'GET operation is invoked'
def result = objectUnderTest.getOperation(getResourceUrl)
then: 'the output of the method is equal to the output from the test template'
@@ -72,7 +74,8 @@ class SdncRestconfClientSpec extends Specification {
setupTestConfigurationData()
and: 'the rest template returns a valid response entity'
def mockResponseEntity = Mock(ResponseEntity)
- mockRestTemplate.getForEntity({ it.toString() == 'http://some-uri/getResourceUrl' }, String.class, _ as HttpEntity) >> mockResponseEntity
+ mockRestTemplate.exchange({ it.toString() == 'http://some-uri/getResourceUrl' },
+ HttpMethod.GET, _ as HttpEntity, String.class) >> mockResponseEntity
when: 'GET operation is invoked'
def result = objectUnderTest.getOperation(getResourceUrl, new HttpHeaders())
then: 'the output of the method is equal to the output from the test template'
diff --git a/src/test/resources/ModuleSchema.json b/src/test/resources/ModuleSchema.json
index 07a0a037..50c67154 100644
--- a/src/test/resources/ModuleSchema.json
+++ b/src/test/resources/ModuleSchema.json
@@ -1,5 +1,5 @@
{
- "schemas": {
+ "ietf-netconf-monitoring:schemas": {
"schema": [
{
"identifier": "example-identifier",