From: ecaiyanlinux Date: Fri, 31 Jul 2020 17:35:39 +0000 (+0200) Subject: Fix bug in A1 clients X-Git-Tag: 2.0.1~5 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F4496%2F1;p=nonrtric.git Fix bug in A1 clients Change-Id: Id397f97bcc1d527ec130a399a4b926e951ca7beb Issue-ID: NONRTRIC-267 Signed-off-by: RehanRaza Signed-off-by: ecaiyanlinux --- diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientFactory.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientFactory.java index 322958a6..3297b622 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientFactory.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientFactory.java @@ -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"); diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOnapA1Client.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOnapA1Client.java index a10decd5..37e03032 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOnapA1Client.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOnapA1Client.java @@ -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()); } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java index 2763ab9b..79a2a5ef 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java @@ -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); } diff --git a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java index 8a2f0441..a6f6187f 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java @@ -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;