aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test/java
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2020-10-12 09:59:34 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2020-10-12 10:00:10 +0200
commit4e948fe8cfed4cb6a9d48f3588962aab9bbb4e3d (patch)
tree0ef3c27307f4dd5fe98806a0b32c385f1d199c8d /a1-policy-management/src/test/java
parent672d820b5807e6b2f9378359e8de817622d0d31c (diff)
Improvent of usage of AsynchRestClient
Change-Id: I34ce159abacde85cfe7631402491e457d30c7097 Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'a1-policy-management/src/test/java')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java33
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java4
2 files changed, 18 insertions, 19 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java
index 90292d30..ca5a6192 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java
@@ -43,6 +43,7 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
@@ -137,8 +138,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(new ArrayList<>(Arrays.asList(POLICY_1_ID)));
setUpGetPolicyTypeIdentitiesToReturn(new ArrayList<>(Arrays.asList(POLICY_TYPE_1_NAME)));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
supervisorUnderTest.checkAllRics();
@@ -152,8 +152,7 @@ class RicSupervisionTest {
RIC_1.setState(RicState.UNAVAILABLE);
rics.put(RIC_1);
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
doReturn(synchronizationTaskMock).when(supervisorUnderTest).createSynchronizationTask();
@@ -171,8 +170,7 @@ class RicSupervisionTest {
RIC_1.setState(RicState.SYNCHRONIZING);
rics.put(RIC_1);
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
supervisorUnderTest.checkAllRics();
@@ -189,8 +187,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(new Exception("Failed"));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
supervisorUnderTest.checkAllRics();
verify(supervisorUnderTest).checkAllRics();
@@ -209,8 +206,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(new ArrayList<>(Arrays.asList(POLICY_1_ID)));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
doReturn(synchronizationTaskMock).when(supervisorUnderTest).createSynchronizationTask();
@@ -233,8 +229,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(new ArrayList<>(Arrays.asList(POLICY_1_ID, "Another_policy")));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
doReturn(synchronizationTaskMock).when(supervisorUnderTest).createSynchronizationTask();
@@ -256,8 +251,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(Collections.emptyList());
setUpGetPolicyTypeIdentitiesToReturn(new Exception("Failed"));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
supervisorUnderTest.checkAllRics();
verify(supervisorUnderTest).checkAllRics();
@@ -276,8 +270,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(Collections.emptyList());
setUpGetPolicyTypeIdentitiesToReturn(new ArrayList<>(Arrays.asList(POLICY_TYPE_1_NAME, "another_policy_type")));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
doReturn(synchronizationTaskMock).when(supervisorUnderTest).createSynchronizationTask();
@@ -305,8 +298,7 @@ class RicSupervisionTest {
setUpGetPolicyIdentitiesToReturn(Collections.emptyList());
setUpGetPolicyTypeIdentitiesToReturn(new ArrayList<>(Arrays.asList(POLICY_TYPE_1_NAME, "another_policy_type")));
- RicSupervision supervisorUnderTest =
- spy(new RicSupervision(rics, policies, a1ClientFactory, types, null, null));
+ RicSupervision supervisorUnderTest = spy(createRicSupervision());
doReturn(synchronizationTaskMock).when(supervisorUnderTest).createSynchronizationTask();
@@ -335,4 +327,9 @@ class RicSupervisionTest {
when(a1ClientMock.getPolicyTypeIdentities()).thenReturn(Mono.error((Exception) returnValue));
}
}
+
+ private RicSupervision createRicSupervision() {
+ ApplicationConfig config = new ApplicationConfig();
+ return new RicSupervision(rics, policies, a1ClientFactory, types, null, config);
+ }
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
index 0a7fc850..0ac8fdb0 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
@@ -49,6 +49,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
@@ -121,7 +122,8 @@ class RicSynchronizationTaskTest {
private RicSynchronizationTask createTask() {
ApplicationConfig config = new ApplicationConfig();
- return new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services, config);
+ AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig());
+ return new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services, restClientFactory);
};
@Test