Support of the status_notification_uri in A1Policy creation

Issue-ID: CCSDK-3911
Change-Id: I3ada7a16db879a06f3b446025cf1fd794d67ac22
Signed-off-by: nitincg <nitin2.jain@capgemini.com>
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
index 3797dc8..e442ca7 100644
--- a/.readthedocs.yaml
+++ b/.readthedocs.yaml
@@ -9,10 +9,11 @@
   - htmlzip
 
 build:
-  image: latest
+  os: ubuntu-20.04
+  tools:
+    python: "3.8"
 
 python:
-  version: 3.7
   install:
     - requirements: docs/requirements-docs.txt
 
diff --git a/a1-policy-management/pom.xml b/a1-policy-management/pom.xml
index b6bdea6..c1f6395 100644
--- a/a1-policy-management/pom.xml
+++ b/a1-policy-management/pom.xml
@@ -213,6 +213,16 @@
             <artifactId>everit-json-schema</artifactId>
             <version>1.14.0</version>
         </dependency>
+        <dependency>
+           <groupId>org.codehaus.httpcache4j.uribuilder</groupId>
+           <artifactId>uribuilder</artifactId>
+           <version>2.0.0</version>
+       </dependency>
+       <dependency>
+           <groupId>org.apache.httpcomponents</groupId>
+           <artifactId>httpclient</artifactId>
+           <version>4.5.13</version>
+       </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -492,4 +502,4 @@
             </plugin>
         </plugins>
     </reporting>
-</project>
\ No newline at end of file
+</project>
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
index 62115b5..f2a79cd 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
@@ -32,7 +32,7 @@
 
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
-
+import org.apache.http.client.utils.URIBuilder;
 /**
  * Client for accessing OSC A1 REST API
  */
@@ -49,7 +49,7 @@
 
         @Override
         public String createPutPolicyUri(String type, String policyId, String notificationDestinationUri) {
-            return createPolicyUri(type, policyId);
+	    return createPolicyUri(type, policyId, notificationDestinationUri);
         }
 
         /**
@@ -62,7 +62,7 @@
 
         @Override
         public String createDeleteUri(String type, String policyId) {
-            return createPolicyUri(type, policyId);
+	    return createPolicyUri(type, policyId, null);
         }
 
         /**
@@ -70,7 +70,7 @@
          */
         @Override
         public String createGetPolicyStatusUri(String type, String policyId) {
-            return createPolicyUri(type, policyId) + "/status";
+	    return createPolicyUri(type, policyId, null) + "/status";
         }
 
         /**
@@ -99,9 +99,22 @@
         /**
          * ​/a1-p​/policytypes​/{policy_type_id}​/policies​/{policy_instance_id}
          */
-        private String createPolicyUri(String type, String id) {
-            return createPolicyTypeUri(type) + "/policies/" + id;
-        }
+	private String createPolicyUri(String type, String id, String notificationDestination) {
+               String url = "";
+               URIBuilder ub = null;
+               try {
+                    ub = new URIBuilder(createPolicyTypeUri(type) + "/policies/" + id);
+                    if(notificationDestination != null) {
+                       ub.addParameter("notificationDestination", notificationDestination);
+                    }
+                    url = ub.toString();
+               }
+               catch(Exception e) {
+                    String exceptionString = e.toString();
+                    logger.error("Unexpected error in policy URI creation for policy type: {}, exception: {}", type, exceptionString);
+               }
+               return url;
+         }
 
         /**
          * /a1-p/policytypes/{policy_type_id}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java
index e6c8dfe..753b8d4 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java
@@ -264,18 +264,18 @@
                 .block();
 
         assertEquals("OK", returned);
-        AdapterRequest expectedInputParams = new AdapterRequest(expUrl, POLICY_JSON_VALID);
+        AdapterRequest expectedInputParams = new AdapterRequest(expUrl , POLICY_JSON_VALID);
         String expInput = A1AdapterJsonHelper.createInputJsonString(expectedInputParams);
 
-        verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+        verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL , expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
 
     }
 
     @Test
     @DisplayName("test put Policy OSC")
     void putPolicy_OSC() {
-        String expUrl = RIC_1_URL + "/a1-p/policytypes/type1/policies/policy1";
-        putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl);
+        String expUrl = RIC_1_URL + "/a1-p/policytypes/type1/policies/policy1?notificationDestination\u003dhttps%3A%2F%2Ftest.com";
+	putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl);
     }
 
     @Test
@@ -307,7 +307,7 @@
         whenAsyncPostThenReturn(Mono.just(resp));
 
         Mono<String> returnedMono = clientUnderTest
-                .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID));
+                .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL +  "?notificationDestination=https%3A%2F%2Ftest.com", POLICY_1_ID, policyJson, POLICY_TYPE_1_ID));
         StepVerifier.create(returnedMono) //
                 .expectSubscription() //
                 .expectErrorMatches(t -> t instanceof WebClientResponseException) //
@@ -377,7 +377,7 @@
                 asyncRestClientMock);
         whenPostReturnOkResponse();
 
-        Policy policy = A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID);
+        Policy policy = A1ClientHelper.createPolicy(RIC_1_URL + "?notificationDestination=https%3A%2F%2Ftest.com", POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID);
 
         String response = clientUnderTest.getPolicyStatus(policy).block();
         assertEquals("OK", response);
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java
index 2f2cce0..68214fc 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java
@@ -150,7 +150,7 @@
         clientUnderTest
                 .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
                 .block();
-        verify(asyncRestClientMock).put(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID,
+        verify(asyncRestClientMock).put(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID + "?notificationDestination=https%3A%2F%2Ftest.com",
                 POLICY_JSON_VALID);
     }