aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management')
-rw-r--r--a1-policy-management/api/api_generated.json38
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java7
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java7
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java5
-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
6 files changed, 48 insertions, 46 deletions
diff --git a/a1-policy-management/api/api_generated.json b/a1-policy-management/api/api_generated.json
index 61f38ec5..399855fc 100644
--- a/a1-policy-management/api/api_generated.json
+++ b/a1-policy-management/api/api_generated.json
@@ -5,7 +5,7 @@
"summary": "Query policy type names",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getPolicyTypesUsingGET_1",
+ "operationId": "getPolicyTypesUsingGET",
"responses": {
"200": {
"schema": {
@@ -36,7 +36,7 @@
"summary": "Returns a policy configuration",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "getPolicyUsingGET",
+ "operationId": "getPolicyUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/json_object"},
@@ -63,7 +63,7 @@
"summary": "Delete a policy",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "deletePolicyUsingDELETE",
+ "operationId": "deletePolicyUsingDELETE_1",
"responses": {
"200": {"description": "Not used"},
"401": {"description": "Unauthorized"},
@@ -92,7 +92,7 @@
"summary": "Create or update a policy",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "putPolicyUsingPUT",
+ "operationId": "putPolicyUsingPUT_1",
"responses": {
"200": {"description": "Policy updated"},
"201": {"description": "Policy created"},
@@ -166,7 +166,7 @@
"summary": "Returns status and statistics of this service",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "getStatusUsingGET",
+ "operationId": "getStatusUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/status_info_v2"},
@@ -182,7 +182,7 @@
"summary": "Query policies, only policy identities returned",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getPolicyIdsUsingGET_1",
+ "operationId": "getPolicyIdsUsingGET",
"responses": {
"200": {
"schema": {
@@ -230,7 +230,7 @@
"summary": "Returns policy type schema definitions",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getPolicySchemasUsingGET_1",
+ "operationId": "getPolicySchemasUsingGET",
"responses": {
"200": {
"schema": {
@@ -260,7 +260,7 @@
"summary": "Query policy type identities",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "getPolicyTypesUsingGET",
+ "operationId": "getPolicyTypesUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/policy_type_id_list_v2"},
@@ -523,7 +523,7 @@
"summary": "Returns policy type schema definitions",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "getPolicySchemasUsingGET",
+ "operationId": "getPolicySchemasUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/policy_schema_list_v2"},
@@ -599,7 +599,7 @@
"summary": "Returns a policy configuration",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getPolicyUsingGET_1",
+ "operationId": "getPolicyUsingGET",
"responses": {
"200": {
"schema": {"type": "object"},
@@ -623,7 +623,7 @@
"summary": "Delete a policy",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "deletePolicyUsingDELETE_1",
+ "operationId": "deletePolicyUsingDELETE",
"responses": {
"200": {"description": "Not used"},
"401": {"description": "Unauthorized"},
@@ -652,7 +652,7 @@
"summary": "Put a policy",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "putPolicyUsingPUT_1",
+ "operationId": "putPolicyUsingPUT",
"responses": {
"200": {"description": "Policy updated"},
"201": {"description": "Policy created"},
@@ -726,7 +726,7 @@
"summary": "Returns status and statistics of this service",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getStatusUsingGET_1",
+ "operationId": "getStatusUsingGET",
"responses": {
"200": {
"schema": {"type": "string"},
@@ -743,7 +743,7 @@
"deprecated": false,
"produces": ["application/json"],
"description": "Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.",
- "operationId": "getPolicyIdsUsingGET",
+ "operationId": "getPolicyIdsUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/policy_id_list_v2"},
@@ -788,7 +788,7 @@
"summary": "Query policies",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getPoliciesUsingGET_1",
+ "operationId": "getPoliciesUsingGET",
"responses": {
"200": {
"schema": {
@@ -836,7 +836,7 @@
"summary": "Returns a policy status",
"deprecated": false,
"produces": ["application/json"],
- "operationId": "getPolicyStatusUsingGET",
+ "operationId": "getPolicyStatusUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/json_object"},
@@ -953,7 +953,7 @@
"deprecated": false,
"produces": ["application/json"],
"description": "Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.",
- "operationId": "getPoliciesUsingGET",
+ "operationId": "getPoliciesUsingGET_1",
"responses": {
"200": {
"schema": {"$ref": "#/definitions/policy_info_list_v2"},
@@ -998,7 +998,7 @@
"summary": "Returns a policy status",
"deprecated": false,
"produces": ["*/*"],
- "operationId": "getPolicyStatusUsingGET_1",
+ "operationId": "getPolicyStatusUsingGET",
"responses": {
"200": {
"schema": {"type": "object"},
@@ -1050,7 +1050,7 @@
"tags": ["A1 Policy Management Version 2.0 (in progress)"]
}}
},
- "host": "localhost:41617",
+ "host": "localhost:33209",
"definitions": {
"error_information": {
"description": "Problem as defined in https://tools.ietf.org/html/rfc7807",
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
index 0fee08cf..e4d7d8d7 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
@@ -39,6 +39,7 @@ import lombok.AccessLevel;
import lombok.Getter;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig.RicConfigUpdate;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfigParser;
@@ -92,6 +93,7 @@ public class RefreshConfigTask {
private final Policies policies;
private final Services services;
private final PolicyTypes policyTypes;
+ private final AsyncRestClientFactory restClientFactory;
@Autowired
public RefreshConfigTask(ApplicationConfig appConfig, Rics rics, Policies policies, Services services,
@@ -102,6 +104,7 @@ public class RefreshConfigTask {
this.services = services;
this.policyTypes = policyTypes;
this.a1ClientFactory = a1ClientFactory;
+ this.restClientFactory = new AsyncRestClientFactory(appConfig.getWebClientConfig());
}
public void start() {
@@ -199,7 +202,7 @@ public class RefreshConfigTask {
private void removePoliciciesInRic(@Nullable Ric ric) {
if (ric != null) {
RicSynchronizationTask synch =
- new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, appConfig);
+ new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory);
synch.run(ric);
}
}
@@ -234,7 +237,7 @@ public class RefreshConfigTask {
void runRicSynchronization(Ric ric) {
RicSynchronizationTask synchronizationTask =
- new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, appConfig);
+ new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory);
synchronizationTask.run(ric);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
index 5ff6d191..cae257cd 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
@@ -24,6 +24,7 @@ import java.util.Collection;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
@@ -59,7 +60,7 @@ public class RicSupervision {
private final PolicyTypes policyTypes;
private final A1ClientFactory a1ClientFactory;
private final Services services;
- private final ApplicationConfig config;
+ private final AsyncRestClientFactory restClientFactory;
private static class SynchStartedException extends ServiceException {
private static final long serialVersionUID = 1L;
@@ -91,7 +92,7 @@ public class RicSupervision {
this.a1ClientFactory = a1ClientFactory;
this.policyTypes = policyTypes;
this.services = services;
- this.config = config;
+ this.restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig());
}
/**
@@ -210,6 +211,6 @@ public class RicSupervision {
}
RicSynchronizationTask createSynchronizationTask() {
- return new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, config);
+ return new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services, restClientFactory);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
index df0771cb..cf7ca74e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
@@ -26,7 +26,6 @@ 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.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
@@ -69,12 +68,12 @@ public class RicSynchronizationTask {
private final AsyncRestClientFactory restClientFactory;
public RicSynchronizationTask(A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, Policies policies,
- Services services, ApplicationConfig config) {
+ Services services, AsyncRestClientFactory restClientFactory) {
this.a1ClientFactory = a1ClientFactory;
this.policyTypes = policyTypes;
this.policies = policies;
this.services = services;
- this.restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig());
+ this.restClientFactory = restClientFactory;
}
public void run(Ric ric) {
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