Fix bug in A1 clients 96/4496/1
authorecaiyanlinux <martin.c.yan@est.tech>
Fri, 31 Jul 2020 17:35:39 +0000 (19:35 +0200)
committerecaiyanlinux <martin.c.yan@est.tech>
Sun, 2 Aug 2020 13:20:22 +0000 (15:20 +0200)
Change-Id: Id397f97bcc1d527ec130a399a4b926e951ca7beb
Issue-ID: NONRTRIC-267
Signed-off-by: RehanRaza <muhammad.rehan.raza@est.tech>
Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech>
policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientFactory.java
policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOnapA1Client.java
policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java
policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java

index 322958a..3297b62 100644 (file)
@@ -74,9 +74,10 @@ public class A1ClientFactory {
             assertNoControllerConfig(ric, version);
             return new OscA1Client(ric.getConfig(), this.appConfig.getWebClientConfig());
         } else if (version == A1ProtocolType.SDNC_OSC_STD_V1_1 || version == A1ProtocolType.SDNC_OSC_OSC_V1) {
-            return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric));
+            return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric),
+                this.appConfig.getWebClientConfig());
         } else if (version == A1ProtocolType.SDNC_ONAP) {
-            return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric));
+            return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric), this.appConfig.getWebClientConfig());
         } else {
             logger.error("Unhandled protocol: {}", version);
             throw new ServiceException("Unhandled protocol");
index a10decd..37e0303 100644 (file)
@@ -29,6 +29,7 @@ import org.immutables.gson.Gson;
 import org.immutables.value.Value;
 import org.oransc.policyagent.configuration.ControllerConfig;
 import org.oransc.policyagent.configuration.RicConfig;
+import org.oransc.policyagent.configuration.WebClientConfig;
 import org.oransc.policyagent.repository.Policy;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,8 +64,9 @@ public class SdncOnapA1Client implements A1Client {
     private final RicConfig ricConfig;
     private final AsyncRestClient restClient;
 
-    public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig) {
-        this(ricConfig, controllerConfig, new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations"));
+    public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, WebClientConfig clientConfig) {
+        this(ricConfig, controllerConfig,
+            new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
         logger.debug("SdncOnapA1Client for ric: {}, a1ControllerBaseUrl: {}", ricConfig.name(),
             controllerConfig.baseUrl());
     }
index 2763ab9..79a2a5e 100644 (file)
@@ -33,6 +33,7 @@ import org.immutables.value.Value;
 import org.json.JSONObject;
 import org.oransc.policyagent.configuration.ControllerConfig;
 import org.oransc.policyagent.configuration.RicConfig;
+import org.oransc.policyagent.configuration.WebClientConfig;
 import org.oransc.policyagent.repository.Policy;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,9 +88,10 @@ public class SdncOscA1Client implements A1Client {
      *
      * @throws IllegalArgumentException when the protocolType is wrong.
      */
-    public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig) {
+    public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
+        WebClientConfig clientConfig) {
         this(protocolType, ricConfig, controllerConfig,
-            new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations"));
+            new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
         logger.debug("SdncOscA1Client for ric: {}, a1Controller: {}", ricConfig.name(), controllerConfig);
     }
 
index 8a2f044..a6f6187 100644 (file)
@@ -96,7 +96,7 @@ class SdncOscA1ClientTest {
     @Test
     void createClientWithWrongProtocol_thenErrorIsThrown() {
         try {
-            new SdncOscA1Client(A1ProtocolType.STD_V1_1, null, null, null);
+            new SdncOscA1Client(A1ProtocolType.STD_V1_1, null, null, new AsyncRestClient("", null));
             fail("Should have thrown exception.");
         } catch (IllegalArgumentException e) {
             return;