diff options
3 files changed, 8 insertions, 4 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java index 201f1bc0..c949b774 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java @@ -26,6 +26,7 @@ import static org.apache.http.HttpHeaders.CONTENT_TYPE; import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.DELETE; import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.GET; import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.PUT; +import static org.springframework.web.util.UriUtils.encodeFragment; import com.google.gson.JsonObject; import io.vavr.collection.HashMap; @@ -202,7 +203,7 @@ public class BbsActionsTaskImpl implements BbsActionsTask { } private String buildUri(String path) { - return config.getAaiClientConfiguration().pnfUrl().replace(PNF_URI, path); + return config.getAaiClientConfiguration().pnfUrl().replace(PNF_URI, encodeFragment(path, UTF_8)); } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java index bc754bf8..f060ac7b 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java @@ -66,6 +66,7 @@ class BbsActionsTaskTest { private static final String PNF_WITH_LINK_JSON = "BbsActionsTaskTestFiles/pnfWithLogicalLink.json"; private static final String LOGICAL_LINK_JSON = "BbsActionsTaskTestFiles/oldLogicalLink.json"; private static final String LOGICAL_LINK_BODY = "BbsActionsTaskTestFiles/logicalLinkBody.json"; + private static final String LOGICAL_LINK_BODY_WITH_SPACE = "BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json"; private CbsConfiguration cbsConfiguration = mock(CbsConfiguration.class); @@ -111,7 +112,8 @@ class BbsActionsTaskTest { given(cbsConfiguration.getAaiClientConfiguration()).willReturn(aaiClientConfiguration); JsonObject additionalFields = new JsonObject(); - String linkName = "some-link"; + String linkName = "some link"; + String encodedLinkName = "some%20link"; additionalFields.addProperty(ATTACHMENT_POINT, linkName); ConsumerDmaapModel consumerDmaapModel = buildConsumerDmaapModel(additionalFields); @@ -136,9 +138,9 @@ class BbsActionsTaskTest { assertEquals(AAI_URL + PNF_URL + "/Nokia123", pnfGet.url()); assertEquals(GET, pnfGet.method()); - assertEquals(AAI_URL + LOGICAL_LINK_URL + "/" + linkName, linkPut.url()); + assertEquals(AAI_URL + LOGICAL_LINK_URL + "/" + encodedLinkName, linkPut.url()); assertEquals(PUT, linkPut.method()); - assertEquals(getBodyJson(LOGICAL_LINK_BODY), extractBodyFromRequest(linkPut)); + assertEquals(getBodyJson(LOGICAL_LINK_BODY_WITH_SPACE), extractBodyFromRequest(linkPut)); } @Test diff --git a/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json b/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json new file mode 100644 index 00000000..9cdd7010 --- /dev/null +++ b/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json @@ -0,0 +1 @@ +{"link-name":"some link","link-type":"attachment-point","relationship-list":{"relationship":[{"related-link":"/network/pnfs/pnf/Nokia123","relationship-data":[]}]}}
\ No newline at end of file |