summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
authorRenu Kumari <renu.kumari@bell.ca>2021-10-06 13:31:43 +0000
committerGerrit Code Review <gerrit@onap.org>2021-10-06 13:31:43 +0000
commitf3798ee9857edb45243d540606ceac21df1215ab (patch)
tree95f45aeb28accdde738705f7cf52b4702a628d05 /cps-ncmp-service/src
parent98e686f3aa8ae8171e850591c1f85433b00c56cf (diff)
parentfd2e6ddde2c2260951e2dfd5e3fd7f4bd04976e1 (diff)
Merge "Changing resource identifier to a query param"
Diffstat (limited to 'cps-ncmp-service/src')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operation/DmiOperations.java13
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy12
2 files changed, 11 insertions, 14 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operation/DmiOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operation/DmiOperations.java
index 71af3d4cfe..c295e0328e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operation/DmiOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operation/DmiOperations.java
@@ -52,6 +52,8 @@ public class DmiOperations {
private static final String DMI_CM_HANDLE_PATH = "/v1/ch/{cmHandle}";
private static final String DMI_CM_HANDLE_DATASTORE_PATH = DMI_CM_HANDLE_PATH + "/data/ds";
private static final String URL_SEPARATOR = "/";
+ private static final String RESOURCE_IDENTIFIER = "resourceIdentifier";
+
/**
* Constructor for {@code DmiOperations}. This method also manipulates url properties.
@@ -199,7 +201,7 @@ public class DmiOperations {
stringBuilder.append(DMI_API_PATH);
stringBuilder.append(DMI_CM_HANDLE_DATASTORE_PATH.replace("{cmHandle}", cmHandle));
stringBuilder.append(URL_SEPARATOR + dataStoreEnum.getValue());
- stringBuilder.append(URL_SEPARATOR + resourceId);
+ stringBuilder.append("?" + RESOURCE_IDENTIFIER + "=" + resourceId);
return stringBuilder;
}
@@ -208,15 +210,10 @@ public class DmiOperations {
final Integer depthQuery) {
final var doesFieldExists = (fieldsQuery != null && !fieldsQuery.isEmpty());
if (doesFieldExists) {
- stringBuilder.append("?").append("fields=").append(fieldsQuery);
+ stringBuilder.append("&").append("fields=").append(fieldsQuery);
}
if (depthQuery != null) {
- if (doesFieldExists) {
- stringBuilder.append("&");
- } else {
- stringBuilder.append("?");
- }
- stringBuilder.append("depth=").append(depthQuery);
+ stringBuilder.append("&").append("depth=").append(depthQuery);
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy
index 6a1ce1a18b..8af778106a 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy
@@ -42,11 +42,11 @@ class DmiOperationsSpec extends Specification {
def 'call get resource data for pass-through:operational datastore from DMI.'() {
given: 'expected url'
def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' +
- '/ncmp-datastore:passthrough-operational/testResourceId?fields=testFieldsQuery&depth=10'
+ '/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child&fields=testFieldsQuery&depth=10'
when: 'get resource data is called to DMI'
objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath',
'testCmhandle',
- 'testResourceId',
+ 'parent/child',
'testFieldsQuery',
10,
'testAcceptJson',
@@ -57,11 +57,11 @@ class DmiOperationsSpec extends Specification {
def 'call get resource data for pass-through:running datastore from DMI.'() {
given: 'expected url'
def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' +
- '/ncmp-datastore:passthrough-running/testResourceId?fields=testFieldsQuery&depth=10'
+ '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child&fields=testFieldsQuery&depth=10'
when: 'get resource data is called to DMI'
objectUnderTest.getResourceDataPassThroughRunningFromDmi('testDmiBasePath',
'testCmhandle',
- 'testResourceId',
+ 'parent/child',
'testFieldsQuery',
10,
'testAcceptJson',
@@ -72,11 +72,11 @@ class DmiOperationsSpec extends Specification {
def 'call create resource data for pass-through:running datastore from DMI.'() {
given: 'expected url'
def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' +
- '/ncmp-datastore:passthrough-running/testResourceId'
+ '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child'
when: 'get resource data is called to DMI'
objectUnderTest.createResourceDataPassThroughRunningFromDmi('testDmiBasePath',
'testCmhandle',
- 'testResourceId',
+ 'parent/child',
'testJsonbody')
then: 'the put operation is executed with the correct URL'
1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders)