aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-04-08 12:44:44 +0000
committerGerrit Code Review <gerrit@onap.org>2021-04-08 12:44:44 +0000
commitab7baa0563069bc403c840b39f22a9e7e900fb72 (patch)
tree52eff5bfd43dc43cd9c699e76bd904a48cc4f810
parentac6773591fcfc1e0d5f23038b3c37e9612ca9a9e (diff)
parent97a9001fe632b0eaed48d324dc8d6c2c3c630f8c (diff)
Merge "PMS Persistent storage of policies and type definitions - A1 Istanbul"
-rw-r--r--a1-policy-management/Dockerfile3
-rw-r--r--a1-policy-management/api/pms-api.json4
-rw-r--r--a1-policy-management/api/pms-api.yaml4
-rw-r--r--a1-policy-management/config/application.yaml2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java10
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java9
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java9
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java10
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java54
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java7
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java54
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java7
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java24
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java32
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/MultiMap.java65
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java184
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policy.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyType.java14
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyTypes.java78
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java10
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java33
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java6
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java57
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java96
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java3
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java3
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java15
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java11
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java15
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java21
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java14
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java10
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java17
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java9
-rw-r--r--docs/offeredapis/swagger/pms-api.json4
-rw-r--r--docs/offeredapis/swagger/pms-api.yaml4
44 files changed, 611 insertions, 391 deletions
diff --git a/a1-policy-management/Dockerfile b/a1-policy-management/Dockerfile
index 52ba3fd7..7c732c14 100644
--- a/a1-policy-management/Dockerfile
+++ b/a1-policy-management/Dockerfile
@@ -35,6 +35,9 @@ ARG JAR
WORKDIR /opt/app/policy-agent
RUN mkdir -p /var/log/policy-agent
RUN mkdir -p /opt/app/policy-agent/etc/cert/
+RUN mkdir -p /var/policy-management-service
+RUN chmod -R 777 /var/policy-management-service
+
RUN groupadd -r onap && useradd -ms /bin/bash a1pms -g onap
RUN chown -R a1pms:onap /var/log/policy-agent
diff --git a/a1-policy-management/api/pms-api.json b/a1-policy-management/api/pms-api.json
index 9514f7ed..5b432820 100644
--- a/a1-policy-management/api/pms-api.json
+++ b/a1-policy-management/api/pms-api.json
@@ -440,11 +440,11 @@
"tags": ["A1 Policy Management V1.0"]
},
"delete": {
- "summary": "Delete a service",
+ "summary": "Unregisters a service",
"operationId": "deleteService",
"responses": {
"204": {
- "description": "Service deleted",
+ "description": "Service unregisterred",
"content": {"*/*": {"schema": {"$ref": "#/components/schemas/void"}}}
},
"404": {
diff --git a/a1-policy-management/api/pms-api.yaml b/a1-policy-management/api/pms-api.yaml
index d16fbe5f..cdf91ee8 100644
--- a/a1-policy-management/api/pms-api.yaml
+++ b/a1-policy-management/api/pms-api.yaml
@@ -159,7 +159,7 @@ paths:
delete:
tags:
- A1 Policy Management V1.0
- summary: Delete a service
+ summary: Unregisters a service
operationId: deleteService
parameters:
- name: name
@@ -172,7 +172,7 @@ paths:
type: string
responses:
204:
- description: Service deleted
+ description: Service unregisterred
content:
'*/*':
schema:
diff --git a/a1-policy-management/config/application.yaml b/a1-policy-management/config/application.yaml
index 150dca47..3294fbe2 100644
--- a/a1-policy-management/config/application.yaml
+++ b/a1-policy-management/config/application.yaml
@@ -69,4 +69,6 @@ app:
# The HTTP proxy (if configured) will only be used for accessing NearRT RIC:s
http.proxy-host:
http.proxy-port: 0
+ # path where the service can store data
+ vardata-directory: /var/policy-management-service
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java
index 54a5edaa..4b5c2f09 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java
@@ -25,10 +25,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.catalina.connector.Connector;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
@@ -36,20 +35,14 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
-class BeanFactory {
- private final ApplicationConfig applicationConfig = new ApplicationConfig();
+public class BeanFactory {
@Value("${server.http-port}")
private int httpPort = 0;
@Bean
- public Policies getPolicies() {
- return new Policies();
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return new PolicyTypes();
+ public ApplicationConfig getApplicationConfig() {
+ return new ApplicationConfig();
}
@Bean
@@ -58,18 +51,13 @@ class BeanFactory {
}
@Bean
- public ApplicationConfig getApplicationConfig() {
- return this.applicationConfig;
- }
-
- @Bean
- Services getServices() {
+ public Services getServices() {
return new Services();
}
@Bean
- A1ClientFactory getA1ClientFactory() {
- return new A1ClientFactory(this.applicationConfig);
+ public A1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig applicationConfig) {
+ return new A1ClientFactory(applicationConfig);
}
@Bean
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
index 448b7b61..c3f00407 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
@@ -168,14 +168,14 @@ public class CcsdkA1AdapterClient implements A1Client {
@Override
public Mono<String> putPolicy(Policy policy) {
- String ricUrl =
- getUriBuilder().createPutPolicyUri(policy.type().id(), policy.id(), policy.statusNotificationUri());
- return post("putA1Policy", ricUrl, Optional.of(policy.json()));
+ String ricUrl = getUriBuilder().createPutPolicyUri(policy.getType().getId(), policy.getId(),
+ policy.getStatusNotificationUri());
+ return post("putA1Policy", ricUrl, Optional.of(policy.getJson()));
}
@Override
public Mono<String> deletePolicy(Policy policy) {
- return deletePolicyById(policy.type().id(), policy.id());
+ return deletePolicyById(policy.getType().getId(), policy.getId());
}
@Override
@@ -210,7 +210,7 @@ public class CcsdkA1AdapterClient implements A1Client {
@Override
public Mono<String> getPolicyStatus(Policy policy) {
- String ricUrl = getUriBuilder().createGetPolicyStatusUri(policy.type().id(), policy.id());
+ String ricUrl = getUriBuilder().createGetPolicyStatusUri(policy.getType().getId(), policy.getId());
return post("getA1PolicyStatus", ricUrl, Optional.empty());
}
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 402a73b4..7ded8ac9 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
@@ -165,13 +165,14 @@ public class OscA1Client implements A1Client {
@Override
public Mono<String> putPolicy(Policy policy) {
- String policyUri = this.uri.createPutPolicyUri(policy.type().id(), policy.id(), policy.statusNotificationUri());
- return restClient.put(policyUri, policy.json());
+ String policyUri = this.uri.createPutPolicyUri(policy.getType().getId(), policy.getId(),
+ policy.getStatusNotificationUri());
+ return restClient.put(policyUri, policy.getJson());
}
@Override
public Mono<String> deletePolicy(Policy policy) {
- return deletePolicyById(policy.type().id(), policy.id());
+ return deletePolicyById(policy.getType().getId(), policy.getId());
}
@Override
@@ -188,7 +189,7 @@ public class OscA1Client implements A1Client {
@Override
public Mono<String> getPolicyStatus(Policy policy) {
- String statusUri = uri.createGetPolicyStatusUri(policy.type().id(), policy.id());
+ String statusUri = uri.createGetPolicyStatusUri(policy.getType().getId(), policy.getId());
return restClient.get(statusUri);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
index ba18afea..130f5500 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
@@ -113,8 +113,9 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Mono<String> putPolicy(Policy policy) {
- return restClient.put(uri.createPutPolicyUri(policy.type().id(), policy.id(), policy.statusNotificationUri()),
- policy.json());
+ return restClient.put(
+ uri.createPutPolicyUri(policy.getType().getId(), policy.getId(), policy.getStatusNotificationUri()),
+ policy.getJson());
}
@Override
@@ -129,7 +130,7 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Mono<String> deletePolicy(Policy policy) {
- return deletePolicyById(policy.id());
+ return deletePolicyById(policy.getId());
}
@Override
@@ -146,7 +147,7 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Mono<String> getPolicyStatus(Policy policy) {
- return restClient.get(uri.createGetPolicyStatusUri(policy.type().id(), policy.id()));
+ return restClient.get(uri.createGetPolicyStatusUri(policy.getType().getId(), policy.getId()));
}
private Flux<String> getPolicyIds() {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
index 471b3c4d..d79b2e72 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
@@ -169,14 +169,14 @@ public class StdA1ClientVersion2 implements A1Client {
@Override
public Mono<String> putPolicy(Policy policy) {
- String policyUri =
- this.uriBuiler.createPutPolicyUri(policy.type().id(), policy.id(), policy.statusNotificationUri());
- return restClient.put(policyUri, policy.json());
+ String policyUri = this.uriBuiler.createPutPolicyUri(policy.getType().getId(), policy.getId(),
+ policy.getStatusNotificationUri());
+ return restClient.put(policyUri, policy.getJson());
}
@Override
public Mono<String> deletePolicy(Policy policy) {
- return deletePolicyById(policy.type().id(), policy.id());
+ return deletePolicyById(policy.getType().getId(), policy.getId());
}
@Override
@@ -193,7 +193,7 @@ public class StdA1ClientVersion2 implements A1Client {
@Override
public Mono<String> getPolicyStatus(Policy policy) {
- String statusUri = uriBuiler.createGetPolicyStatusUri(policy.type().id(), policy.id());
+ String statusUri = uriBuiler.createGetPolicyStatusUri(policy.getType().getId(), policy.getId());
return restClient.get(statusUri);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java
index 6449e48b..5bfe677e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java
@@ -32,18 +32,20 @@ import lombok.Getter;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig.HttpProxyConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import reactor.core.publisher.Flux;
@EnableConfigurationProperties
-@ConfigurationProperties()
public class ApplicationConfig {
@NotEmpty
@Getter
@Value("${app.filepath}")
private String localConfigurationFilePath;
+ @Getter
+ @Value("${app.vardata-directory:null}")
+ private String vardataDirectory;
+
@Value("${server.ssl.key-store-type}")
private String sslKeyStoreType = "";
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
index 1f5f7ca9..c2f6a48a 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
@@ -44,7 +44,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ErrorResponse;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -135,7 +134,7 @@ public class PolicyController {
description = "The identity of the policy type to get the definition for.") //
@RequestParam(name = "id", required = true) String id) throws EntityNotFoundException {
PolicyType type = policyTypes.getType(id);
- return new ResponseEntity<>(type.schema(), HttpStatus.OK);
+ return new ResponseEntity<>(type.getSchema(), HttpStatus.OK);
}
@GetMapping("/policy_types")
@@ -175,7 +174,7 @@ public class PolicyController {
@Parameter(name = "id", required = true, description = "The identity of the policy instance.") //
@RequestParam(name = "id", required = true) String id) throws EntityNotFoundException {
Policy p = policies.getPolicy(id);
- return new ResponseEntity<>(p.json(), HttpStatus.OK);
+ return new ResponseEntity<>(p.getJson(), HttpStatus.OK);
}
@DeleteMapping("/policy")
@@ -197,11 +196,11 @@ public class PolicyController {
@Parameter(name = "id", required = true, description = "The identity of the policy instance.") //
@RequestParam(name = "id", required = true) String id) throws EntityNotFoundException {
Policy policy = policies.getPolicy(id);
- keepServiceAlive(policy.ownerServiceId());
- Ric ric = policy.ric();
+ keepServiceAlive(policy.getOwnerServiceId());
+ Ric ric = policy.getRic();
return ric.getLock().lock(LockType.SHARED) //
.flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.getRic())) //
.doOnNext(notUsed -> policies.remove(policy)) //
.flatMap(client -> client.deletePolicy(policy)) //
.doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
@@ -252,7 +251,7 @@ public class PolicyController {
if (ric == null || type == null) {
return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id(instanceId) //
.json(jsonString) //
.type(type) //
@@ -263,7 +262,7 @@ public class PolicyController {
.statusNotificationUri("") //
.build();
- final boolean isCreate = this.policies.get(policy.id()) == null;
+ final boolean isCreate = this.policies.get(policy.getId()) == null;
return ric.getLock().lock(LockType.SHARED) //
.flatMap(notUsed -> assertRicStateIdle(ric)) //
@@ -298,11 +297,11 @@ public class PolicyController {
private Mono<Object> validateModifiedPolicy(Policy policy) {
// Check that ric is not updated
- Policy current = this.policies.get(policy.id());
- if (current != null && !current.ric().id().equals(policy.ric().id())) {
- RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC name: " + current.ric().id() + //
- ", new name: " + policy.ric().id(), HttpStatus.CONFLICT);
+ Policy current = this.policies.get(policy.getId());
+ if (current != null && !current.getRic().id().equals(policy.getRic().id())) {
+ RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.getId() + //
+ ", RIC name: " + current.getRic().id() + //
+ ", new name: " + policy.getRic().id(), HttpStatus.CONFLICT);
logger.debug("Request rejected, {}", e.getMessage());
return Mono.error(e);
}
@@ -310,10 +309,10 @@ public class PolicyController {
}
private Mono<Object> checkSupportedType(Ric ric, PolicyType type) {
- if (!ric.isSupportingType(type.id())) {
+ if (!ric.isSupportingType(type.getId())) {
logger.debug("Request rejected, type not supported, RIC: {}", ric);
- RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(),
- HttpStatus.NOT_FOUND);
+ RejectionException e = new RejectionException(
+ "Type: " + type.getId() + " not supported by RIC: " + ric.id(), HttpStatus.NOT_FOUND);
return Mono.error(e);
}
return Mono.just("OK");
@@ -405,7 +404,7 @@ public class PolicyController {
throws EntityNotFoundException {
Policy policy = policies.getPolicy(id);
- return a1ClientFactory.createA1Client(policy.ric()) //
+ return a1ClientFactory.createA1Client(policy.getRic()) //
.flatMap(client -> client.getPolicyStatus(policy)) //
.flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK)))
.onErrorResume(this::handleException);
@@ -428,7 +427,8 @@ public class PolicyController {
}
List<Policy> filtered = new ArrayList<>();
for (Policy p : collection) {
- if (include(type, p.type().id()) && include(ric, p.ric().id()) && include(service, p.ownerServiceId())) {
+ if (include(type, p.getType().getId()) && include(ric, p.getRic().id())
+ && include(service, p.getOwnerServiceId())) {
filtered.add(p);
}
}
@@ -451,12 +451,12 @@ public class PolicyController {
List<PolicyInfo> v = new ArrayList<>(policies.size());
for (Policy p : policies) {
PolicyInfo policyInfo = new PolicyInfo();
- policyInfo.id = p.id();
- policyInfo.json = fromJson(p.json());
- policyInfo.ric = p.ric().id();
- policyInfo.type = p.type().id();
- policyInfo.service = p.ownerServiceId();
- policyInfo.lastModified = p.lastModified().toString();
+ policyInfo.id = p.getId();
+ policyInfo.json = fromJson(p.getJson());
+ policyInfo.ric = p.getRic().id();
+ policyInfo.type = p.getType().getId();
+ policyInfo.service = p.getOwnerServiceId();
+ policyInfo.lastModified = p.getLastModified().toString();
if (!policyInfo.validate()) {
logger.error("BUG, all fields must be set");
}
@@ -478,7 +478,7 @@ public class PolicyController {
result.append(",");
}
first = false;
- result.append(t.schema());
+ result.append(t.getSchema());
}
result.append("]");
return result.toString();
@@ -487,7 +487,7 @@ public class PolicyController {
private String toPolicyTypeIdsJson(Collection<PolicyType> types) {
List<String> v = new ArrayList<>(types.size());
for (PolicyType t : types) {
- v.add(t.id());
+ v.add(t.getId());
}
return gson.toJson(v);
}
@@ -495,7 +495,7 @@ public class PolicyController {
private String toPolicyIdsJson(Collection<Policy> policies) {
List<String> v = new ArrayList<>(policies.size());
for (Policy p : policies) {
- v.add(p.id());
+ v.add(p.getId());
}
return gson.toJson(v);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
index b4b7dca4..4e42550c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
@@ -141,12 +141,11 @@ public class ServiceController {
}
}
- @Operation(summary = "Delete a service")
+ @Operation(summary = "Unregisters a service")
@ApiResponses(value = { //
- @ApiResponse(responseCode = "204", description = "Service deleted"),
- @ApiResponse(responseCode = "204", description = "Not used",
+ @ApiResponse(responseCode = "204", description = "Service unregisterred", //
content = @Content(schema = @Schema(implementation = VoidResponse.class))),
- @ApiResponse(responseCode = "404", description = "Service not found",
+ @ApiResponse(responseCode = "404", description = "Service not found", //
content = @Content(schema = @Schema(implementation = String.class)))})
@DeleteMapping("/services")
public ResponseEntity<String> deleteService(//
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
index 1f0e1603..ab9b6692 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
@@ -42,7 +42,6 @@ import lombok.Getter;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -115,7 +114,7 @@ public class PolicyController {
public ResponseEntity<Object> getPolicyType( //
@PathVariable("policytype_id") String policyTypeId) throws EntityNotFoundException {
PolicyType type = policyTypes.getType(policyTypeId);
- PolicyTypeInfo info = new PolicyTypeInfo(type.schema());
+ PolicyTypeInfo info = new PolicyTypeInfo(type.getSchema());
return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK);
}
@@ -177,12 +176,12 @@ public class PolicyController {
public Mono<ResponseEntity<Object>> deletePolicy( //
@PathVariable(Consts.POLICY_ID_PARAM) String policyId) throws EntityNotFoundException {
Policy policy = policies.getPolicy(policyId);
- keepServiceAlive(policy.ownerServiceId());
- Ric ric = policy.ric();
+ keepServiceAlive(policy.getOwnerServiceId());
+ Ric ric = policy.getRic();
return ric.getLock().lock(LockType.SHARED) //
.flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.getRic())) //
.doOnNext(notUsed -> policies.remove(policy)) //
.flatMap(client -> client.deletePolicy(policy)) //
.doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
@@ -219,7 +218,7 @@ public class PolicyController {
if (ric == null || type == null) {
throw new EntityNotFoundException("Near-RT RIC or policy type not found");
}
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id(policyInfo.policyId) //
.json(jsonString) //
.type(type) //
@@ -230,7 +229,7 @@ public class PolicyController {
.statusNotificationUri(policyInfo.statusNotificationUri == null ? "" : policyInfo.statusNotificationUri) //
.build();
- final boolean isCreate = this.policies.get(policy.id()) == null;
+ final boolean isCreate = this.policies.get(policy.getId()) == null;
return ric.getLock().lock(LockType.SHARED) //
.flatMap(notUsed -> assertRicStateIdle(ric)) //
@@ -259,11 +258,11 @@ public class PolicyController {
private Mono<Object> validateModifiedPolicy(Policy policy) {
// Check that ric is not updated
- Policy current = this.policies.get(policy.id());
- if (current != null && !current.ric().id().equals(policy.ric().id())) {
- RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC ID: " + current.ric().id() + //
- ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT);
+ Policy current = this.policies.get(policy.getId());
+ if (current != null && !current.getRic().id().equals(policy.getRic().id())) {
+ RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.getId() + //
+ ", RIC ID: " + current.getRic().id() + //
+ ", new ID: " + policy.getRic().id(), HttpStatus.CONFLICT);
logger.debug("Request rejected, {}", e.getMessage());
return Mono.error(e);
}
@@ -271,10 +270,10 @@ public class PolicyController {
}
private Mono<Object> checkSupportedType(Ric ric, PolicyType type) {
- if (!ric.isSupportingType(type.id())) {
+ if (!ric.isSupportingType(type.getId())) {
logger.debug("Request rejected, type not supported, RIC: {}", ric);
- RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(),
- HttpStatus.NOT_FOUND);
+ RejectionException e = new RejectionException(
+ "Type: " + type.getId() + " not supported by RIC: " + ric.id(), HttpStatus.NOT_FOUND);
return Mono.error(e);
}
return Mono.just("{}");
@@ -376,7 +375,7 @@ public class PolicyController {
@PathVariable(Consts.POLICY_ID_PARAM) String policyId) throws EntityNotFoundException {
Policy policy = policies.getPolicy(policyId);
- return a1ClientFactory.createA1Client(policy.ric()) //
+ return a1ClientFactory.createA1Client(policy.getRic()) //
.flatMap(client -> client.getPolicyStatus(policy).onErrorResume(e -> Mono.just("{}"))) //
.flatMap(status -> createPolicyStatus(policy, status)) //
.onErrorResume(this::handleException);
@@ -384,7 +383,7 @@ public class PolicyController {
}
private Mono<ResponseEntity<Object>> createPolicyStatus(Policy policy, String statusFromNearRic) {
- PolicyStatusInfo info = new PolicyStatusInfo(policy.lastModified(), fromJson(statusFromNearRic));
+ PolicyStatusInfo info = new PolicyStatusInfo(policy.getLastModified(), fromJson(statusFromNearRic));
String str = gson.toJson(info);
return Mono.just(new ResponseEntity<>(str, HttpStatus.OK));
}
@@ -406,7 +405,8 @@ public class PolicyController {
}
List<Policy> filtered = new ArrayList<>();
for (Policy p : collection) {
- if (include(type, p.type().id()) && include(ric, p.ric().id()) && include(service, p.ownerServiceId())) {
+ if (include(type, p.getType().getId()) && include(ric, p.getRic().id())
+ && include(service, p.getOwnerServiceId())) {
filtered.add(p);
}
}
@@ -427,14 +427,14 @@ public class PolicyController {
private PolicyInfo toPolicyInfo(Policy p) {
PolicyInfo policyInfo = new PolicyInfo();
- policyInfo.policyId = p.id();
- policyInfo.policyData = fromJson(p.json());
- policyInfo.ricId = p.ric().id();
- policyInfo.policyTypeId = p.type().id();
- policyInfo.serviceId = p.ownerServiceId();
+ policyInfo.policyId = p.getId();
+ policyInfo.policyData = fromJson(p.getJson());
+ policyInfo.ricId = p.getRic().id();
+ policyInfo.policyTypeId = p.getType().getId();
+ policyInfo.serviceId = p.getOwnerServiceId();
policyInfo.isTransient = p.isTransient();
- if (!p.statusNotificationUri().isEmpty()) {
- policyInfo.statusNotificationUri = p.statusNotificationUri();
+ if (!p.getStatusNotificationUri().isEmpty()) {
+ policyInfo.statusNotificationUri = p.getStatusNotificationUri();
}
if (!policyInfo.validate()) {
logger.error("BUG, all mandatory fields must be set");
@@ -459,7 +459,7 @@ public class PolicyController {
private String toPolicyTypeIdsJson(Collection<PolicyType> types) {
List<String> v = new ArrayList<>(types.size());
for (PolicyType t : types) {
- v.add(t.id());
+ v.add(t.getId());
}
PolicyTypeIdList ids = new PolicyTypeIdList(v);
return gson.toJson(ids);
@@ -468,7 +468,7 @@ public class PolicyController {
private String toPolicyIdsJson(Collection<Policy> policies) {
List<String> v = new ArrayList<>(policies.size());
for (Policy p : policies) {
- v.add(p.id());
+ v.add(p.getId());
}
return gson.toJson(new PolicyIdList(v));
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
index d3ff999a..a1106192 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
@@ -150,17 +150,16 @@ public class ServiceController {
}
}
+ @DeleteMapping(Consts.V2_API_ROOT + "/services/{service_id:.+}")
@Operation(summary = "Unregister a service")
@ApiResponses(value = { //
@ApiResponse(responseCode = "204", description = "Service unregistered"),
- @ApiResponse(responseCode = "200", description = "Not used",
+ @ApiResponse(responseCode = "200", description = "Not used", //
content = @Content(schema = @Schema(implementation = VoidResponse.class))),
- @ApiResponse(responseCode = "404", description = "Service not found",
+ @ApiResponse(responseCode = "404", description = "Service not found", //
content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class)))
})
-
- @DeleteMapping(Consts.V2_API_ROOT + "/services/{service_id:.+}")
public ResponseEntity<Object> deleteService(//
@PathVariable("service_id") String serviceId) {
try {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java
index 56765232..bc67e663 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java
@@ -25,13 +25,10 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
-import com.google.gson.TypeAdapterFactory;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
-import java.util.Optional;
-import java.util.ServiceLoader;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
@@ -115,7 +112,6 @@ public class DmaapMessageConsumer {
public DmaapMessageConsumer(ApplicationConfig applicationConfig) {
this.applicationConfig = applicationConfig;
GsonBuilder gsonBuilder = new GsonBuilder();
- ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
this.gson = gsonBuilder.create();
this.restClientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig());
}
@@ -199,12 +195,12 @@ public class DmaapMessageConsumer {
protected Mono<String> sendErrorResponse(String response) {
logger.debug("sendErrorResponse {}", response);
- DmaapRequestMessage fakeRequest = ImmutableDmaapRequestMessage.builder() //
+ DmaapRequestMessage fakeRequest = DmaapRequestMessage.builder() //
.apiVersion("") //
.correlationId("") //
.operation(DmaapRequestMessage.Operation.PUT) //
.originatorId("") //
- .payload(Optional.empty()) //
+ .payload(null) //
.requestId("") //
.target("") //
.timestamp("") //
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java
index c77087a5..d0354174 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java
@@ -24,8 +24,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
-import java.util.Optional;
-
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
import org.onap.ccsdk.oran.a1policymanagementservice.dmaap.DmaapRequestMessage.Operation;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
@@ -89,8 +87,8 @@ public class DmaapMessageHandler {
}
private Mono<ResponseEntity<String>> invokePolicyManagementService(DmaapRequestMessage dmaapRequestMessage) {
- DmaapRequestMessage.Operation operation = dmaapRequestMessage.operation();
- String uri = dmaapRequestMessage.url();
+ DmaapRequestMessage.Operation operation = dmaapRequestMessage.getOperation();
+ String uri = dmaapRequestMessage.getUrl();
if (operation == Operation.DELETE) {
return pmsClient.deleteForEntity(uri);
@@ -106,9 +104,9 @@ public class DmaapMessageHandler {
}
private String payload(DmaapRequestMessage message) {
- Optional<JsonObject> payload = message.payload();
- if (payload.isPresent()) {
- return gson.toJson(payload.get());
+ JsonObject payload = message.getPayload();
+ if (payload != null) {
+ return gson.toJson(payload);
} else {
logger.warn("Expected payload in message from DMAAP: {}", message);
return "";
@@ -127,14 +125,16 @@ public class DmaapMessageHandler {
private Mono<String> createDmaapResponseMessage(DmaapRequestMessage dmaapRequestMessage, String response,
HttpStatus status) {
- DmaapResponseMessage dmaapResponseMessage = ImmutableDmaapResponseMessage.builder() //
+ DmaapResponseMessage dmaapResponseMessage = DmaapResponseMessage.builder() //
.status(status.toString()) //
.message(response == null ? "" : response) //
.type("response") //
- .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) //
- .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) //
- .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) //
- .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) //
+ .correlationId(
+ dmaapRequestMessage.getCorrelationId() == null ? "" : dmaapRequestMessage.getCorrelationId()) //
+ .originatorId(
+ dmaapRequestMessage.getOriginatorId() == null ? "" : dmaapRequestMessage.getOriginatorId()) //
+ .requestId(dmaapRequestMessage.getRequestId() == null ? "" : dmaapRequestMessage.getRequestId()) //
+ .timestamp(dmaapRequestMessage.getTimestamp() == null ? "" : dmaapRequestMessage.getTimestamp()) //
.build();
String str = gson.toJson(dmaapResponseMessage);
return Mono.just(str);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java
index f41c51c5..10dc981e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapRequestMessage.java
@@ -22,34 +22,34 @@ package org.onap.ccsdk.oran.a1policymanagementservice.dmaap;
import com.google.gson.JsonObject;
-import java.util.Optional;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-
-@Value.Immutable
-@Gson.TypeAdapters
-public interface DmaapRequestMessage {
+@Getter
+@Builder
+@EqualsAndHashCode
+public class DmaapRequestMessage {
public enum Operation {
PUT, GET, DELETE, POST
}
- String correlationId();
+ String correlationId;
- String target();
+ String target;
- String timestamp();
+ String timestamp;
- String apiVersion();
+ String apiVersion;
- String originatorId();
+ String originatorId;
- String requestId();
+ String requestId;
- Operation operation();
+ Operation operation;
- String url();
+ String url;
- Optional<JsonObject> payload();
+ JsonObject payload;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java
index 04024742..64778551 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapResponseMessage.java
@@ -20,24 +20,26 @@
package org.onap.ccsdk.oran.a1policymanagementservice.dmaap;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
-@Value.Immutable
-@Gson.TypeAdapters
-public interface DmaapResponseMessage {
+@Getter
+@Builder
+@EqualsAndHashCode
+public class DmaapResponseMessage {
- String type();
+ String type;
- String correlationId();
+ String correlationId;
- String timestamp();
+ String timestamp;
- String originatorId();
+ String originatorId;
- String requestId();
+ String requestId;
- String status();
+ String status;
- String message();
+ String message;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/MultiMap.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/MultiMap.java
new file mode 100644
index 00000000..ff09ba3a
--- /dev/null
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/MultiMap.java
@@ -0,0 +1,65 @@
+/*-
+ * ========================LICENSE_START=================================
+ * ONAP : ccsdk oran
+ * ======================================================================
+ * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * ======================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
+
+package org.onap.ccsdk.oran.a1policymanagementservice.repository;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+/**
+ * A map, where each key can be bound to may values (where each value has an own
+ * ID)
+ */
+public class MultiMap<T> {
+
+ private final Map<String, Map<String, T>> map = new HashMap<>();
+
+ public void put(String key, String id, T value) {
+ this.map.computeIfAbsent(key, k -> new HashMap<>()).put(id, value);
+ }
+
+ public T remove(String key, String id) {
+ Map<String, T> innerMap = this.map.get(key);
+ if (innerMap != null) {
+ T removedElement = innerMap.remove(id);
+ if (innerMap.isEmpty()) {
+ this.map.remove(key);
+ }
+ return removedElement;
+ }
+ return null;
+ }
+
+ public Collection<T> get(String key) {
+ Map<String, T> innerMap = this.map.get(key);
+ if (innerMap == null) {
+ return Collections.emptyList();
+ }
+ return new Vector<>(innerMap.values());
+ }
+
+ public void clear() {
+ this.map.clear();
+ }
+
+}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java
index 882d3368..a24c5bd0 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policies.java
@@ -20,48 +20,72 @@
package org.onap.ccsdk.oran.a1policymanagementservice.repository;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.invoke.MethodHandles;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.Instant;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
-import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
+import lombok.Builder;
+import lombok.Getter;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.util.FileSystemUtils;
+
+@Configuration
public class Policies {
- private Map<String, Policy> policiesId = new HashMap<>();
- private Map<String, Map<String, Policy>> policiesRic = new HashMap<>();
- private Map<String, Map<String, Policy>> policiesService = new HashMap<>();
- private Map<String, Map<String, Policy>> policiesType = new HashMap<>();
- public synchronized void put(Policy policy) {
- policiesId.put(policy.id(), policy);
- multiMapPut(policiesRic, policy.ric().id(), policy);
- multiMapPut(policiesService, policy.ownerServiceId(), policy);
- multiMapPut(policiesType, policy.type().id(), policy);
+ @Getter
+ @Builder
+ private static class PersistentPolicyInfo {
+ private String id;
+ private String json;
+ private String ownerServiceId;
+ private String ricId;
+ private String typeId;
+ private String statusNotificationUri;
+ private boolean isTransient;
+ private String lastModified;
}
- private void multiMapPut(Map<String, Map<String, Policy>> multiMap, String key, Policy value) {
- multiMap.computeIfAbsent(key, k -> new HashMap<>()).put(value.id(), value);
- }
+ private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private Map<String, Policy> policiesId = new HashMap<>();
+ private MultiMap<Policy> policiesRic = new MultiMap<>();
+ private MultiMap<Policy> policiesService = new MultiMap<>();
+ private MultiMap<Policy> policiesType = new MultiMap<>();
- private void multiMapRemove(Map<String, Map<String, Policy>> multiMap, String key, Policy value) {
- Map<String, Policy> map = multiMap.get(key);
- if (map != null) {
- map.remove(value.id());
- if (map.isEmpty()) {
- multiMap.remove(key);
- }
- }
+ private final ApplicationConfig appConfig;
+ private static Gson gson = new GsonBuilder().create();
+
+ public Policies(@Autowired ApplicationConfig appConfig) {
+ this.appConfig = appConfig;
}
- private Collection<Policy> multiMapGet(Map<String, Map<String, Policy>> multiMap, String key) {
- Map<String, Policy> map = multiMap.get(key);
- if (map == null) {
- return Collections.emptyList();
+ public synchronized void put(Policy policy) {
+ policiesId.put(policy.getId(), policy);
+ policiesRic.put(policy.getRic().id(), policy.getId(), policy);
+ policiesService.put(policy.getOwnerServiceId(), policy.getId(), policy);
+ policiesType.put(policy.getType().getId(), policy.getId(), policy);
+ if (this.appConfig.getVardataDirectory() != null && !policy.isTransient()) {
+ store(policy);
}
- return new Vector<>(map.values());
}
public synchronized boolean containsPolicy(String id) {
@@ -85,15 +109,15 @@ public class Policies {
}
public synchronized Collection<Policy> getForService(String service) {
- return multiMapGet(policiesService, service);
+ return policiesService.get(service);
}
public synchronized Collection<Policy> getForRic(String ric) {
- return multiMapGet(policiesRic, ric);
+ return policiesRic.get(ric);
}
public synchronized Collection<Policy> getForType(String type) {
- return multiMapGet(policiesType, type);
+ return policiesType.get(type);
}
public synchronized Policy removeId(String id) {
@@ -105,10 +129,17 @@ public class Policies {
}
public synchronized void remove(Policy policy) {
- policiesId.remove(policy.id());
- multiMapRemove(policiesRic, policy.ric().id(), policy);
- multiMapRemove(policiesService, policy.ownerServiceId(), policy);
- multiMapRemove(policiesType, policy.type().id(), policy);
+ if (!policy.isTransient()) {
+ try {
+ Files.delete(getPath(policy));
+ } catch (IOException | ServiceException e) {
+ logger.debug("Could not delete policy from database: {}", e.getMessage());
+ }
+ }
+ policiesId.remove(policy.getId());
+ policiesRic.remove(policy.getRic().id(), policy.getId());
+ policiesService.remove(policy.getOwnerServiceId(), policy.getId());
+ policiesType.remove(policy.getType().getId(), policy.getId());
}
public synchronized void removePoliciesForRic(String ricId) {
@@ -127,5 +158,90 @@ public class Policies {
Set<String> keys = policiesId.keySet();
removeId(keys.iterator().next());
}
+ try {
+ if (this.appConfig.getVardataDirectory() != null) {
+ FileSystemUtils.deleteRecursively(getDatabasePath());
+ }
+ } catch (IOException | ServiceException e) {
+ logger.warn("Could not delete policy database : {}", e.getMessage());
+ }
+ }
+
+ public void store(Policy policy) {
+ try {
+ Files.createDirectories(getDatabasePath(policy.getRic()));
+ try (PrintStream out = new PrintStream(new FileOutputStream(getFile(policy)))) {
+ out.print(gson.toJson(toStorageObject(policy)));
+ }
+ } catch (Exception e) {
+ logger.warn("Could not store policy: {} {}", policy.getId(), e.getMessage());
+ }
+ }
+
+ private File getFile(Policy policy) throws ServiceException {
+ return getPath(policy).toFile();
+ }
+
+ private Path getPath(Policy policy) throws ServiceException {
+ return Path.of(getDatabaseDirectory(policy.getRic()), policy.getId() + ".json");
+ }
+
+ public void restoreFromDatabase(Ric ric, PolicyTypes types) {
+
+ try {
+ Files.createDirectories(getDatabasePath(ric));
+ for (File file : getDatabasePath(ric).toFile().listFiles()) {
+ String json = Files.readString(file.toPath());
+ PersistentPolicyInfo policyStorage = gson.fromJson(json, PersistentPolicyInfo.class);
+ this.put(toPolicy(policyStorage, ric, types));
+ }
+ } catch (ServiceException | IOException e) {
+ logger.warn("Could not restore policy database for RIC: {}, reason : {}", ric.id(), e.getMessage());
+ }
+ }
+
+ private PersistentPolicyInfo toStorageObject(Policy p) {
+ return PersistentPolicyInfo.builder() //
+ .id(p.getId()) //
+ .json(p.getJson()) //
+ .ownerServiceId(p.getOwnerServiceId()) //
+ .ricId(p.getRic().id()) //
+ .statusNotificationUri(p.getStatusNotificationUri()) //
+ .typeId(p.getType().getId()) //
+ .isTransient(p.isTransient()) //
+ .lastModified(p.getLastModified().toString()) //
+ .build();
+ }
+
+ Policy toPolicy(PersistentPolicyInfo p, Ric ric, PolicyTypes types) throws EntityNotFoundException {
+ return Policy.builder() //
+ .id(p.getId()) //
+ .isTransient(p.isTransient()) //
+ .json(p.getJson()) //
+ .lastModified(Instant.parse(p.lastModified)) //
+ .ownerServiceId(p.getOwnerServiceId()) //
+ .ric(ric) //
+ .statusNotificationUri(p.getStatusNotificationUri()) //
+ .type(types.getType(p.getTypeId())) //
+ .build();
+ }
+
+ private Path getDatabasePath(Ric ric) throws ServiceException {
+ return Path.of(getDatabaseDirectory(ric));
+ }
+
+ private String getDatabaseDirectory(Ric ric) throws ServiceException {
+ return getDatabaseDirectory() + "/" + ric.id();
+ }
+
+ private String getDatabaseDirectory() throws ServiceException {
+ if (appConfig.getVardataDirectory() == null) {
+ throw new ServiceException("No database storage provided");
+ }
+ return appConfig.getVardataDirectory() + "/database/policyInstances";
+ }
+
+ private Path getDatabasePath() throws ServiceException {
+ return Path.of(getDatabaseDirectory());
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policy.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policy.java
index efafa684..bdf16320 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policy.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Policy.java
@@ -22,25 +22,25 @@ package org.onap.ccsdk.oran.a1policymanagementservice.repository;
import java.time.Instant;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.Getter;
-@Value.Immutable
-@Gson.TypeAdapters
-public interface Policy {
- public String id();
+@Getter
+@Builder
+public class Policy {
+ private String id;
- public String json();
+ private String json;
- public String ownerServiceId();
+ private String ownerServiceId;
- public Ric ric();
+ private Ric ric;
- public PolicyType type();
+ private PolicyType type;
- public Instant lastModified();
+ private Instant lastModified;
- public boolean isTransient();
+ private boolean isTransient;
- public String statusNotificationUri();
+ private String statusNotificationUri;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyType.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyType.java
index f2c6254e..9fbae6dd 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyType.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyType.java
@@ -20,13 +20,13 @@
package org.onap.ccsdk.oran.a1policymanagementservice.repository;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.Getter;
-@Value.Immutable
-@Gson.TypeAdapters
-public interface PolicyType {
- public String id();
+@Getter
+@Builder
+public class PolicyType {
+ private String id;
- public String schema();
+ private String schema;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyTypes.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyTypes.java
index 7bf03782..76f0e216 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyTypes.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/PolicyTypes.java
@@ -20,15 +20,41 @@
package org.onap.ccsdk.oran.a1policymanagementservice.repository;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.invoke.MethodHandles;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.util.FileSystemUtils;
+@Configuration
public class PolicyTypes {
+ private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private Map<String, PolicyType> types = new HashMap<>();
+ private final ApplicationConfig appConfig;
+ private static Gson gson = new GsonBuilder().create();
+
+ public PolicyTypes(@Autowired ApplicationConfig appConfig) {
+ this.appConfig = appConfig;
+ restoreFromDatabase();
+ }
public synchronized PolicyType getType(String name) throws EntityNotFoundException {
PolicyType t = types.get(name);
@@ -43,7 +69,8 @@ public class PolicyTypes {
}
public synchronized void put(PolicyType type) {
- types.put(type.id(), type);
+ types.put(type.getId(), type);
+ store(type);
}
public synchronized boolean contains(String policyType) {
@@ -60,5 +87,54 @@ public class PolicyTypes {
public synchronized void clear() {
this.types.clear();
+ try {
+ FileSystemUtils.deleteRecursively(getDatabasePath());
+ } catch (IOException | ServiceException e) {
+ logger.warn("Could not delete policy type database : {}", e.getMessage());
+ }
+ }
+
+ public void store(PolicyType type) {
+ try {
+ Files.createDirectories(getDatabasePath());
+ try (PrintStream out = new PrintStream(new FileOutputStream(getFile(type)))) {
+ out.print(gson.toJson(type));
+ }
+ } catch (ServiceException e) {
+ logger.debug("Could not store policy type: {} {}", type.getId(), e.getMessage());
+ } catch (IOException e) {
+ logger.warn("Could not store policy type: {} {}", type.getId(), e.getMessage());
+ }
+ }
+
+ private File getFile(PolicyType type) throws ServiceException {
+ return Path.of(getDatabaseDirectory(), type.getId() + ".json").toFile();
+ }
+
+ void restoreFromDatabase() {
+ try {
+ Files.createDirectories(getDatabasePath());
+ for (File file : getDatabasePath().toFile().listFiles()) {
+ String json = Files.readString(file.toPath());
+ PolicyType type = gson.fromJson(json, PolicyType.class);
+ this.types.put(type.getId(), type);
+ }
+
+ } catch (IOException e) {
+ logger.warn("Could not restore policy type database : {}", e.getMessage());
+ } catch (ServiceException e) {
+ logger.debug("Could not restore policy type database : {}", e.getMessage());
+ }
+ }
+
+ private String getDatabaseDirectory() throws ServiceException {
+ if (appConfig.getVardataDirectory() == null) {
+ throw new ServiceException("No policy type storage provided");
+ }
+ return appConfig.getVardataDirectory() + "/database/policyTypes";
+ }
+
+ private Path getDatabasePath() throws ServiceException {
+ return Path.of(getDatabaseDirectory());
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
index c7f471eb..9c4b2750 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
@@ -110,7 +110,7 @@ public class Ric {
* @param type the policy type to support.
*/
public synchronized void addSupportedPolicyType(PolicyType type) {
- supportedPolicyTypes.put(type.id(), type);
+ supportedPolicyTypes.put(type.getId(), type);
}
/**
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 29d2e4eb..771dea52 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
@@ -226,6 +226,9 @@ public class RefreshConfigTask {
private void addRic(RicConfig config) {
Ric ric = new Ric(config);
this.rics.put(ric);
+ if (this.appConfig.getVardataDirectory() != null) {
+ this.policies.restoreFromDatabase(ric, this.policyTypes);
+ }
runRicSynchronization(ric);
}
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 b38a36b2..19222377 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.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.ServiceCallbacks;
-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;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -177,7 +176,7 @@ public class RicSynchronizationTask {
}
private Mono<PolicyType> createPolicyType(String policyTypeId, String schema) {
- PolicyType pt = ImmutablePolicyType.builder().id(policyTypeId).schema(schema).build();
+ PolicyType pt = PolicyType.builder().id(policyTypeId).schema(schema).build();
policyTypes.put(pt);
return Mono.just(pt);
}
@@ -189,7 +188,7 @@ public class RicSynchronizationTask {
}
private Flux<Policy> putPolicy(Policy policy, Ric ric, A1Client a1Client) {
- logger.debug("Recreating policy: {}, for ric: {}", policy.id(), ric.getConfig().ricId());
+ logger.debug("Recreating policy: {}, for ric: {}", policy.getId(), ric.getConfig().ricId());
return a1Client.putPolicy(policy) //
.flatMapMany(notUsed -> Flux.just(policy));
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
index 4c063e2d..d605b69e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
@@ -91,15 +91,15 @@ public class ServiceSupervision {
@SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
private Flux<Policy> deletePolicy(Policy policy) {
- Lock lock = policy.ric().getLock();
+ Lock lock = policy.getRic().getLock();
return lock.lock(LockType.SHARED) //
.doOnNext(notUsed -> policies.remove(policy)) //
.flatMap(notUsed -> deletePolicyInRic(policy))
.doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}",
- policy.id(), policy.ownerServiceId())) //
+ policy.getId(), policy.getOwnerServiceId())) //
.doOnNext(notUsed -> lock.unlockBlocking()) //
.doOnError(throwable -> lock.unlockBlocking()) //
- .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(),
+ .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.getId(),
throwable.getMessage())) //
.flatMapMany(notUsed -> Flux.just(policy)) //
.onErrorResume(throwable -> Flux.empty());
@@ -110,14 +110,14 @@ public class ServiceSupervision {
}
private Mono<Policy> deletePolicyInRic(Policy policy) {
- return a1ClientFactory.createA1Client(policy.ric()) //
+ return a1ClientFactory.createA1Client(policy.getRic()) //
.flatMap(client -> client.deletePolicy(policy) //
.onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) //
.map(nothing -> policy));
}
private Mono<String> handleDeleteFromRicFailure(Policy policy, Throwable e) {
- logger.warn("Could not delete policy: {} from ric: {}. Cause: {}", policy.id(), policy.ric().id(),
+ logger.warn("Could not delete policy: {} from ric: {}. Cause: {}", policy.getId(), policy.getRic().id(),
e.getMessage());
return Mono.empty();
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java
index e6834e77..b0076405 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java
@@ -34,8 +34,6 @@ import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -59,8 +57,10 @@ import org.springframework.util.StringUtils;
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
-@SuppressWarnings("java:S3577") // Class name should start or end with Test. This is not a test class per se, but a mock
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target"})
+@SuppressWarnings("java:S3577") // Class name should start or end with Test. This is not a test class per se,
+ // but a mock
// of the server.
class MockPolicyManagementService {
private static final Logger logger = LoggerFactory.getLogger(MockPolicyManagementService.class);
@@ -91,9 +91,8 @@ class MockPolicyManagementService {
@TestConfiguration
static class TestBeanFactory {
+ private final ApplicationConfig applicationConfig = new MockApplicationConfig();
private final Rics rics = new Rics();
- private final Policies policies = new Policies();
- private final PolicyTypes policyTypes = new PolicyTypes();
@Bean
public ApplicationConfig getApplicationConfig() {
@@ -101,20 +100,10 @@ class MockPolicyManagementService {
}
@Bean
- public MockA1ClientFactory getA1ClientFactory() {
- PolicyTypes ricTypes = new PolicyTypes();
+ public MockA1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig appConfig) {
+ PolicyTypes ricTypes = new PolicyTypes(applicationConfig);
loadTypes(ricTypes);
- return new MockA1ClientFactory(ricTypes);
- }
-
- @Bean
- public Policies getPolicies() {
- return this.policies;
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return this.policyTypes;
+ return new MockA1ClientFactory(appConfig, ricTypes);
}
@Bean
@@ -136,13 +125,13 @@ class MockPolicyManagementService {
try {
String schema = readFile(file);
String typeName = title(schema);
- PolicyType type = ImmutablePolicyType.builder().id(typeName).schema(schema).build();
+ PolicyType type = PolicyType.builder().id(typeName).schema(schema).build();
policyTypes.put(type);
} catch (Exception e) {
logger.error("Could not load json schema ", e);
}
}
- policyTypes.put(ImmutablePolicyType.builder().id("").schema("{}").build());
+ policyTypes.put(PolicyType.builder().id("").schema("{}").build());
}
}
@@ -186,7 +175,7 @@ class MockPolicyManagementService {
Ric ric = rics.get("ric1");
String json = getConfigJsonFromFile();
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id("typelessPolicy") //
.json(json) //
.ownerServiceId("MockPolicyManagementService") //
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java
index 65dc8b5a..dbfc7d90 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java
@@ -48,6 +48,8 @@ class LogAspectTest {
private LogAspect sampleAspect = new LogAspect();
+ LoggingUtils utils;
+
@Test
void testExecutetimeTime_shouldLogTime() throws Throwable {
when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java
index 100e95e2..eb007138 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java
@@ -27,8 +27,6 @@ import java.util.Vector;
import org.json.JSONObject;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
@@ -57,7 +55,7 @@ public class A1ClientHelper {
protected static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) {
String callbackUrl = "https://test.com";
- return ImmutablePolicy.builder() //
+ return Policy.builder() //
.id(policyId) //
.json(json) //
.ownerServiceId("service") //
@@ -70,7 +68,7 @@ public class A1ClientHelper {
}
protected static PolicyType createPolicyType(String name) {
- return ImmutablePolicyType.builder().id(name).schema("schema").build();
+ return PolicyType.builder().id(name).schema("schema").build();
}
protected static String getCreateSchema(String policyType, String policyTypeId) {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
index b5164889..bc22c14d 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
@@ -40,9 +40,9 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+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;
@@ -51,8 +51,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableWebC
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-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;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -91,7 +89,8 @@ import reactor.util.annotation.Nullable;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target"})
class ApplicationTest {
private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
@@ -126,6 +125,7 @@ class ApplicationTest {
public String getLocalConfigurationFilePath() {
return ""; // No config file loaded for the test
}
+
}
/**
@@ -133,10 +133,6 @@ class ApplicationTest {
*/
@TestConfiguration
static class TestBeanFactory {
- private final PolicyTypes policyTypes = new PolicyTypes();
- private final Services services = new Services();
- private final Policies policies = new Policies();
- MockA1ClientFactory a1ClientFactory = null;
@Bean
public ApplicationConfig getApplicationConfig() {
@@ -144,32 +140,15 @@ class ApplicationTest {
}
@Bean
- MockA1ClientFactory getA1ClientFactory() {
- if (a1ClientFactory == null) {
- this.a1ClientFactory = new MockA1ClientFactory(this.policyTypes);
- }
- return this.a1ClientFactory;
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return this.policyTypes;
+ MockA1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig appConfig, @Autowired PolicyTypes types) {
+ return new MockA1ClientFactory(appConfig, types);
}
@Bean
- Policies getPolicies() {
- return this.policies;
- }
-
- @Bean
- Services getServices() {
- return this.services;
- }
-
- @Bean
- public ServiceSupervision getServiceSupervision() {
+ public ServiceSupervision getServiceSupervision(@Autowired Services services,
+ @Autowired A1ClientFactory a1ClientFactory, @Autowired Policies policies) {
Duration checkInterval = Duration.ofMillis(1);
- return new ServiceSupervision(this.services, this.policies, this.getA1ClientFactory(), checkInterval);
+ return new ServiceSupervision(services, policies, a1ClientFactory, checkInterval);
}
@Bean
@@ -182,7 +161,7 @@ class ApplicationTest {
@LocalServerPort
private int port;
- @BeforeEach
+ @AfterEach
void reset() {
rics.clear();
policies.clear();
@@ -233,7 +212,7 @@ class ApplicationTest {
@Test
void testSynchronization() throws Exception {
// Two polictypes will be put in the NearRT RICs
- PolicyTypes nearRtRicPolicyTypes = new PolicyTypes();
+ PolicyTypes nearRtRicPolicyTypes = new PolicyTypes(this.applicationConfig);
nearRtRicPolicyTypes.put(createPolicyType("typeName"));
nearRtRicPolicyTypes.put(createPolicyType("typeName2"));
this.a1ClientFactory.setPolicyTypes(nearRtRicPolicyTypes);
@@ -259,7 +238,7 @@ class ApplicationTest {
Policies ricPolicies = getA1Client(ric1Name).getPolicies();
assertThat(ricPolicies.size()).isEqualTo(1);
Policy ricPolicy = ricPolicies.get(policyId);
- assertThat(ricPolicy.json()).isEqualTo(policy.json());
+ assertThat(ricPolicy.getJson()).isEqualTo(policy.getJson());
// Both types should be in the Policy Management Service's storage after the
// synch
@@ -320,9 +299,9 @@ class ApplicationTest {
Policy policy = policies.getPolicy(policyInstanceId);
assertThat(policy).isNotNull();
- assertThat(policy.id()).isEqualTo(policyInstanceId);
- assertThat(policy.ownerServiceId()).isEqualTo(serviceName);
- assertThat(policy.ric().id()).isEqualTo("ric1");
+ assertThat(policy.getId()).isEqualTo(policyInstanceId);
+ assertThat(policy.getOwnerServiceId()).isEqualTo(serviceName);
+ assertThat(policy.getRic().id()).isEqualTo("ric1");
assertThat(policy.isTransient()).isTrue();
// Put a non transient policy
@@ -428,7 +407,7 @@ class ApplicationTest {
Policy policy = addPolicy("id", "typeName", "service1", "ric1");
{
String rsp = restClient().get(url).block();
- assertThat(rsp).isEqualTo(policy.json());
+ assertThat(rsp).isEqualTo(policy.getJson());
}
{
policies.remove(policy);
@@ -660,7 +639,7 @@ class ApplicationTest {
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id(id) //
.json(jsonString()) //
.ownerServiceId(service) //
@@ -755,7 +734,7 @@ class ApplicationTest {
}
private PolicyType createPolicyType(String policyTypeName) {
- return ImmutablePolicyType.builder() //
+ return PolicyType.builder() //
.id(policyTypeName) //
.schema("{\"title\":\"" + policyTypeName + "\"}") //
.build();
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
index 68255953..84ac596f 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
@@ -44,9 +44,9 @@ import java.util.List;
import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+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;
@@ -56,8 +56,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.ServiceCallbackInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-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;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -98,7 +96,10 @@ import reactor.util.annotation.Nullable;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target/testdata", //
+ "app.filepath=" //
+})
class ApplicationTest {
private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
@@ -131,68 +132,34 @@ class ApplicationTest {
private static Gson gson = new GsonBuilder().create();
- public static class MockApplicationConfig extends ApplicationConfig {
- @Override
- public String getLocalConfigurationFilePath() {
- return ""; // No config file loaded for the test
- }
- }
-
/**
* Overrides the BeanFactory.
*/
@TestConfiguration
static class TestBeanFactory {
- private final PolicyTypes policyTypes = new PolicyTypes();
- private final Services services = new Services();
- private final Policies policies = new Policies();
- MockA1ClientFactory a1ClientFactory = null;
-
- @Bean
- public ApplicationConfig getApplicationConfig() {
- return new MockApplicationConfig();
- }
-
- @Bean
- MockA1ClientFactory getA1ClientFactory() {
- if (a1ClientFactory == null) {
- this.a1ClientFactory = new MockA1ClientFactory(this.policyTypes);
- }
- return this.a1ClientFactory;
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return this.policyTypes;
- }
-
- @Bean
- Policies getPolicies() {
- return this.policies;
- }
@Bean
- Services getServices() {
- return this.services;
+ A1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig appConfig, @Autowired PolicyTypes types) {
+ return new MockA1ClientFactory(appConfig, types);
}
@Bean
- public ServiceSupervision getServiceSupervision() {
+ public ServiceSupervision getServiceSupervision(@Autowired Services services,
+ @Autowired A1ClientFactory a1ClientFactory, @Autowired Policies policies) {
Duration checkInterval = Duration.ofMillis(1);
- return new ServiceSupervision(this.services, this.policies, this.getA1ClientFactory(), checkInterval);
+ return new ServiceSupervision(services, policies, a1ClientFactory, checkInterval);
}
@Bean
public ServletWebServerFactory servletContainer() {
return new TomcatServletWebServerFactory();
}
-
}
@LocalServerPort
private int port;
- @BeforeEach
+ @AfterEach
void reset() {
rics.clear();
policies.clear();
@@ -229,6 +196,31 @@ class ApplicationTest {
}
@Test
+ void testPersistence() throws ServiceException {
+ Ric ric = this.addRic("ric1");
+ PolicyType type = this.addPolicyType("type1", ric.id());
+ PolicyTypes types = new PolicyTypes(this.applicationConfig);
+ assertThat(types.size()).isEqualTo(1);
+
+ addPolicy("id", type.getId(), "service", ric.id());
+ addPolicy("id2", type.getId(), "service", ric.id());
+
+ {
+ Policies policies = new Policies(this.applicationConfig);
+ policies.restoreFromDatabase(ric, types);
+ assertThat(policies.size()).isEqualTo(2);
+ }
+
+ {
+ restClient().delete("/policies/id2").block();
+ Policies policies = new Policies(this.applicationConfig);
+ policies.restoreFromDatabase(ric, types);
+ assertThat(policies.size()).isEqualTo(1);
+ }
+
+ }
+
+ @Test
void testGetRics() throws Exception {
addRic("ric1");
this.addPolicyType("type1", "ric1");
@@ -260,7 +252,7 @@ class ApplicationTest {
@Test
void testSynchronization() throws Exception {
// Two polictypes will be put in the NearRT RICs
- PolicyTypes nearRtRicPolicyTypes = new PolicyTypes();
+ PolicyTypes nearRtRicPolicyTypes = new PolicyTypes(this.applicationConfig);
nearRtRicPolicyTypes.put(createPolicyType("typeName"));
nearRtRicPolicyTypes.put(createPolicyType("typeName2"));
this.a1ClientFactory.setPolicyTypes(nearRtRicPolicyTypes);
@@ -286,7 +278,7 @@ class ApplicationTest {
Policies ricPolicies = getA1Client(ric1Name).getPolicies();
assertThat(ricPolicies.size()).isEqualTo(1);
Policy ricPolicy = ricPolicies.get(policyId);
- assertThat(ricPolicy.json()).isEqualTo(policy.json());
+ assertThat(ricPolicy.getJson()).isEqualTo(policy.getJson());
// Both types should be in the Policy Management Service's storage after the
// synch
@@ -357,9 +349,9 @@ class ApplicationTest {
Policy policy = policies.getPolicy(policyInstanceId);
assertThat(policy).isNotNull();
- assertThat(policy.id()).isEqualTo(policyInstanceId);
- assertThat(policy.ownerServiceId()).isEqualTo(serviceName);
- assertThat(policy.ric().id()).isEqualTo(ricId);
+ assertThat(policy.getId()).isEqualTo(policyInstanceId);
+ assertThat(policy.getOwnerServiceId()).isEqualTo(serviceName);
+ assertThat(policy.getRic().id()).isEqualTo(ricId);
assertThat(policy.isTransient()).isTrue();
// Put a non transient policy
@@ -460,7 +452,7 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
PolicyInfo info = gson.fromJson(rsp, PolicyInfo.class);
String policyStr = gson.toJson(info.policyData);
- assertThat(policyStr).isEqualTo(policy.json());
+ assertThat(policyStr).isEqualTo(policy.getJson());
}
{
policies.remove(policy);
@@ -711,7 +703,7 @@ class ApplicationTest {
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id(id) //
.json(jsonString()) //
.ownerServiceId(service) //
@@ -861,7 +853,7 @@ class ApplicationTest {
}
private PolicyType createPolicyType(String policyTypeName) {
- return ImmutablePolicyType.builder() //
+ return PolicyType.builder() //
.id(policyTypeName) //
.schema("{\"title\":\"" + policyTypeName + "\"}") //
.build();
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java
index ded864f7..3a4aae86 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java
@@ -27,7 +27,6 @@ import java.time.Instant;
import java.util.concurrent.atomic.AtomicInteger;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
@@ -112,7 +111,7 @@ class ConcurrencyTestRunnable implements Runnable {
private Policy createPolicyObject(String id) {
Ric ric = this.rics.get("ric");
PolicyType type = this.types.get("type1");
- return ImmutablePolicy.builder() //
+ return Policy.builder() //
.id(id) //
.json("{}") //
.type(type) //
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
index 482c94fb..6192c932 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
@@ -59,7 +59,8 @@ import reactor.test.StepVerifier;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target"})
class ConfigurationControllerTest {
@Autowired
ApplicationContext context;
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java
index 72ca84a5..3b810ad6 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java
@@ -22,7 +22,6 @@ package org.onap.ccsdk.oran.a1policymanagementservice.dmaap;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
@@ -37,6 +36,7 @@ import com.google.gson.JsonObject;
import java.util.ArrayList;
+import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -99,7 +99,7 @@ class DmaapMessageConsumerTest {
String s = messageConsumerUnderTest.createTask().blockLast();
assertEquals("responseFromHandler", s);
verify(messageConsumerUnderTest, times(2)).delay();
- verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(dmaapRequestMessage());
+ verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(any());
}
@Test
@@ -123,7 +123,7 @@ class DmaapMessageConsumerTest {
verify(messageConsumerUnderTest, times(2)).getFromMessageRouter(anyString());
verify(messageConsumerUnderTest, times(0)).sendErrorResponse(anyString());
verify(messageConsumerUnderTest, times(1)).delay();
- verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(dmaapRequestMessage());
+ verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(any());
assertEquals("response1", s);
}
@@ -164,14 +164,17 @@ class DmaapMessageConsumerTest {
DmaapRequestMessage parsedMessage =
messageConsumerUnderTest.parseReceivedMessage(jsonArrayOfObject).blockLast();
assertNotNull(parsedMessage);
- assertTrue(parsedMessage.payload().isPresent());
+ assertNotNull(parsedMessage.getPayload());
+
+ Assert.assertEquals(dmaapRequestMessage(), parsedMessage);
}
{
String jsonArrayOfString = jsonArray(quote(json));
DmaapRequestMessage parsedMessage =
messageConsumerUnderTest.parseReceivedMessage(jsonArrayOfString).blockLast();
assertNotNull(parsedMessage);
- assertTrue(parsedMessage.payload().isPresent());
+ assertNotNull(parsedMessage.getPayload());
+ Assert.assertEquals(dmaapRequestMessage(), parsedMessage);
}
}
@@ -190,7 +193,7 @@ class DmaapMessageConsumerTest {
}
private DmaapRequestMessage dmaapRequestMessage() {
- return ImmutableDmaapRequestMessage.builder() //
+ return DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
.correlationId("correlationId") //
.operation(Operation.PUT) //
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java
index df84ae05..285f3c4a 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java
@@ -38,7 +38,6 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.nio.charset.Charset;
-import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -76,10 +75,8 @@ class DmaapMessageHandlerTest {
}
DmaapRequestMessage dmaapRequestMessage(Operation operation) {
- Optional<JsonObject> payload =
- ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson())
- : Optional.empty());
- return ImmutableDmaapRequestMessage.builder() //
+ JsonObject payload = ((operation == Operation.PUT || operation == Operation.POST) ? payloadAsJson() : null);
+ return DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
.correlationId("correlationId") //
.operation(operation) //
@@ -224,12 +221,12 @@ class DmaapMessageHandlerTest {
@Test
void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception {
- DmaapRequestMessage message = ImmutableDmaapRequestMessage.builder() //
+ DmaapRequestMessage message = DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
.correlationId("correlationId") //
.operation(DmaapRequestMessage.Operation.PUT) //
.originatorId("originatorId") //
- .payload(Optional.empty()) //
+ .payload(null) //
.requestId("requestId") //
.target("target") //
.timestamp("timestamp") //
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
index e789de62..045b1107 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
@@ -65,10 +65,9 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.Configuration
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableConfigParserResult;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
@@ -116,14 +115,14 @@ class RefreshConfigTaskTest {
}
private RefreshConfigTask createTestObject(boolean configFileExists) {
- return createTestObject(configFileExists, new Rics(), new Policies(), true);
+ return createTestObject(configFileExists, new Rics(), new Policies(appConfig), true);
}
private RefreshConfigTask createTestObject(boolean configFileExists, Rics rics, Policies policies,
boolean stubConfigFileExists) {
RefreshConfigTask obj = spy(new RefreshConfigTask(configurationFileMock, appConfig, rics, policies,
- new Services(), new PolicyTypes(), new A1ClientFactory(appConfig)));
+ new Services(), new PolicyTypes(appConfig), new A1ClientFactory(appConfig)));
if (stubConfigFileExists) {
when(configurationFileMock.readFile()).thenReturn(Optional.empty());
}
@@ -203,7 +202,7 @@ class RefreshConfigTaskTest {
@Test
void whenPeriodicConfigRefreshSuccess_thenNewConfigIsCreatedAndRepositoryUpdated() throws Exception {
Rics rics = new Rics();
- Policies policies = new Policies();
+ Policies policies = new Policies(appConfig);
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, rics, policies, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
@@ -251,7 +250,7 @@ class RefreshConfigTaskTest {
@Test
void whenPeriodicConfigRefreshInvalidJson_thenErrorIsLogged() throws Exception {
Rics rics = new Rics();
- Policies policies = new Policies();
+ Policies policies = new Policies(appConfig);
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, rics, policies, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
@@ -289,11 +288,11 @@ class RefreshConfigTaskTest {
}
private Policy getPolicy(Ric ric) {
- ImmutablePolicyType type = ImmutablePolicyType.builder() //
+ PolicyType type = PolicyType.builder() //
.id("type") //
.schema("{}") //
.build();
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id("id") //
.type(type) //
.lastModified(Instant.now()) //
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 4e72bbf6..525eeff7 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
@@ -45,8 +45,6 @@ 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;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -60,7 +58,7 @@ import reactor.core.publisher.Mono;
@ExtendWith(MockitoExtension.class)
class RicSupervisionTest {
private static final String POLICY_TYPE_1_NAME = "type1";
- private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
+ private static final PolicyType POLICY_TYPE_1 = PolicyType.builder() //
.id(POLICY_TYPE_1_NAME) //
.schema("") //
.build();
@@ -73,7 +71,7 @@ class RicSupervisionTest {
.build());
private static final String POLICY_1_ID = "policyId1";
- private static final Policy POLICY_1 = ImmutablePolicy.builder() //
+ private static final Policy POLICY_1 = Policy.builder() //
.id(POLICY_1_ID) //
.json("") //
.ownerServiceId("service") //
@@ -84,7 +82,7 @@ class RicSupervisionTest {
.statusNotificationUri("statusNotificationUri") //
.build();
- private static final Policy POLICY_2 = ImmutablePolicy.builder() //
+ private static final Policy POLICY_2 = Policy.builder() //
.id("policyId2") //
.json("") //
.ownerServiceId("service") //
@@ -104,14 +102,17 @@ class RicSupervisionTest {
@Mock
private RicSynchronizationTask synchronizationTaskMock;
- private final PolicyTypes types = new PolicyTypes();
- private Policies policies = new Policies();
+ private final ApplicationConfig appConfig = new ApplicationConfig();
+
+ private PolicyTypes types;
+ private Policies policies;
private Rics rics = new Rics();
@BeforeEach
void init() {
- types.clear();
- policies.clear();
+ types = new PolicyTypes(appConfig);
+ policies = new Policies(appConfig);
+
rics.clear();
RIC_1.setState(RicState.UNAVAILABLE);
RIC_1.clearSupportedPolicyTypes();
@@ -287,7 +288,7 @@ class RicSupervisionTest {
@Test
void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
- PolicyType policyType2 = ImmutablePolicyType.builder() //
+ PolicyType policyType2 = PolicyType.builder() //
.id("policyType2") //
.schema("") //
.build();
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 ea4ca97b..2902d45b 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,8 +49,6 @@ 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.ImmutableRicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -68,7 +66,7 @@ import reactor.core.publisher.Mono;
@ExtendWith(MockitoExtension.class)
class RicSynchronizationTaskTest {
private static final String POLICY_TYPE_1_NAME = "type1";
- private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
+ private static final PolicyType POLICY_TYPE_1 = PolicyType.builder() //
.id(POLICY_TYPE_1_NAME) //
.schema("") //
.build();
@@ -82,7 +80,7 @@ class RicSynchronizationTaskTest {
.build());
private static Policy createPolicy(String policyId, boolean isTransient) {
- return ImmutablePolicy.builder() //
+ return Policy.builder() //
.id(policyId) //
.json("") //
.ownerServiceId("service") //
@@ -111,10 +109,12 @@ class RicSynchronizationTaskTest {
private Services services;
private Rics rics;
+ private final ApplicationConfig appConfig = new ApplicationConfig();
+
@BeforeEach
void init() {
- policyTypes = new PolicyTypes();
- policies = new Policies();
+ policyTypes = new PolicyTypes(appConfig);
+ policies = new Policies(appConfig);
services = new Services();
rics = new Rics();
RIC_1.setState(RicState.UNAVAILABLE);
@@ -196,7 +196,7 @@ class RicSynchronizationTaskTest {
verifyNoMoreInteractions(a1ClientMock);
assertThat(policyTypes.size()).isEqualTo(1);
- assertThat(policyTypes.getType(POLICY_TYPE_1_NAME).schema()).isEqualTo(typeSchema);
+ assertThat(policyTypes.getType(POLICY_TYPE_1_NAME).getSchema()).isEqualTo(typeSchema);
assertThat(policies.size()).isZero();
assertThat(RIC_1.getState()).isEqualTo(RicState.AVAILABLE);
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java
index c8476221..4c0e96f5 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java
@@ -43,10 +43,9 @@ 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.configuration.RicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -78,11 +77,11 @@ class ServiceSupervisionTest {
.controllerName("") //
.build();
private Ric ric = new Ric(ricConfig);
- private PolicyType policyType = ImmutablePolicyType.builder() //
+ private PolicyType policyType = PolicyType.builder() //
.id("policyTypeName") //
.schema("schema") //
.build();
- private Policy policy = ImmutablePolicy.builder() //
+ private Policy policy = Policy.builder() //
.id(POLICY_ID) //
.json("json") //
.ownerServiceId(SERVICE_NAME) //
@@ -182,7 +181,8 @@ class ServiceSupervisionTest {
service = new Service(SERVICE_NAME, keepAliveInterval, "callbackUrl");
services.put(service);
- policies = new Policies();
+ ApplicationConfig appConfig = new ApplicationConfig();
+ policies = new Policies(appConfig);
policies.put(policy);
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java
index 482fa395..22ac2437 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java
@@ -20,12 +20,16 @@
package org.onap.ccsdk.oran.a1policymanagementservice.utils;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Vector;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -38,20 +42,23 @@ import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoSink;
public class MockA1Client implements A1Client {
- Policies policies = new Policies();
+ Policies policies;
private final PolicyTypes policyTypes;
private final Duration asynchDelay;
- public MockA1Client(PolicyTypes policyTypes, Duration asynchDelay) {
+ public MockA1Client(String ricId, ApplicationConfig appConfig, PolicyTypes policyTypes, Duration asynchDelay) {
this.policyTypes = policyTypes;
this.asynchDelay = asynchDelay;
+ ApplicationConfig cfg = spy(appConfig);
+ when(cfg.getVardataDirectory()).thenReturn(null);
+ this.policies = new Policies(cfg);
}
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
List<String> result = new Vector<>();
for (PolicyType p : this.policyTypes.getAll()) {
- result.add(p.id());
+ result.add(p.getId());
}
return mono(result);
}
@@ -60,7 +67,7 @@ public class MockA1Client implements A1Client {
public Mono<List<String>> getPolicyIdentities() {
Vector<String> result = new Vector<>();
for (Policy policy : policies.getAll()) {
- result.add(policy.id());
+ result.add(policy.getId());
}
return mono(result);
@@ -69,7 +76,7 @@ public class MockA1Client implements A1Client {
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
try {
- return mono(this.policyTypes.getType(policyTypeId).schema());
+ return mono(this.policyTypes.getType(policyTypeId).getSchema());
} catch (Exception e) {
return Mono.error(e);
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java
index d474daa6..05df70ac 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java
@@ -20,7 +20,6 @@
package org.onap.ccsdk.oran.a1policymanagementservice.utils;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import java.lang.invoke.MethodHandles;
@@ -42,10 +41,12 @@ public class MockA1ClientFactory extends A1ClientFactory {
private final Map<String, MockA1Client> clients = new HashMap<>();
private PolicyTypes policyTypes;
private Duration asynchDelay = Duration.ofSeconds(0);
+ private final ApplicationConfig appConfig;
- public MockA1ClientFactory(PolicyTypes policyTypes) {
- super(mock(ApplicationConfig.class));
+ public MockA1ClientFactory(ApplicationConfig config, PolicyTypes policyTypes) {
+ super(config);
this.policyTypes = policyTypes;
+ this.appConfig = config;
}
@Override
@@ -56,7 +57,7 @@ public class MockA1ClientFactory extends A1ClientFactory {
public MockA1Client getOrCreateA1Client(String ricId) {
if (!clients.containsKey(ricId)) {
logger.debug("Creating client for RIC: {}", ricId);
- MockA1Client client = spy(new MockA1Client(policyTypes, asynchDelay));
+ MockA1Client client = spy(new MockA1Client(ricId, appConfig, policyTypes, asynchDelay));
clients.put(ricId, client);
}
return clients.get(ricId);
diff --git a/docs/offeredapis/swagger/pms-api.json b/docs/offeredapis/swagger/pms-api.json
index 9514f7ed..5b432820 100644
--- a/docs/offeredapis/swagger/pms-api.json
+++ b/docs/offeredapis/swagger/pms-api.json
@@ -440,11 +440,11 @@
"tags": ["A1 Policy Management V1.0"]
},
"delete": {
- "summary": "Delete a service",
+ "summary": "Unregisters a service",
"operationId": "deleteService",
"responses": {
"204": {
- "description": "Service deleted",
+ "description": "Service unregisterred",
"content": {"*/*": {"schema": {"$ref": "#/components/schemas/void"}}}
},
"404": {
diff --git a/docs/offeredapis/swagger/pms-api.yaml b/docs/offeredapis/swagger/pms-api.yaml
index d16fbe5f..cdf91ee8 100644
--- a/docs/offeredapis/swagger/pms-api.yaml
+++ b/docs/offeredapis/swagger/pms-api.yaml
@@ -159,7 +159,7 @@ paths:
delete:
tags:
- A1 Policy Management V1.0
- summary: Delete a service
+ summary: Unregisters a service
operationId: deleteService
parameters:
- name: name
@@ -172,7 +172,7 @@ paths:
type: string
responses:
204:
- description: Service deleted
+ description: Service unregisterred
content:
'*/*':
schema: