aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--a1-policy-management/api/pms-api-v3.yaml2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java1
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java9
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java30
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java19
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java13
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3.java9
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3.java31
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java19
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3.java21
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/StatusControllerV3.java18
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/AuthorizationService.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/PolicyService.java74
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java9
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java59
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/v3/TestHelper.java21
19 files changed, 188 insertions, 160 deletions
diff --git a/a1-policy-management/api/pms-api-v3.yaml b/a1-policy-management/api/pms-api-v3.yaml
index 971324ee..44038e73 100644
--- a/a1-policy-management/api/pms-api-v3.yaml
+++ b/a1-policy-management/api/pms-api-v3.yaml
@@ -436,7 +436,7 @@ paths:
description: "Returns a list of A1 policies matching given search criteria.\
\ <br>If several query parameters are defined, the policies matching all conditions\
\ are returned."
- operationId: getPolicyIds
+ operationId: getAllPolicies
parameters:
- description: Select policies of a given policy type identity.
explode: true
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java
index 714fd2e4..1791222f 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/Application.java
@@ -25,7 +25,6 @@ import java.lang.invoke.MethodHandles;
import org.onap.ccsdk.oran.a1policymanagementservice.tasks.RefreshConfigTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
index b5c10bf6..01891e99 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
@@ -43,12 +43,9 @@ public class A1ClientFactory {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final ApplicationConfig appConfig;
-
private final AsyncRestClientFactory restClientFactory;
public A1ClientFactory(ApplicationConfig appConfig, SecurityContext securityContext) {
- this.appConfig = appConfig;
this.restClientFactory = new AsyncRestClientFactory(appConfig.getWebClientConfig(), securityContext);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
index 45305f84..f5f0f7e7 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
@@ -84,7 +84,7 @@ public class ApplicationConfigParser {
Map<String, ControllerConfig> controllerConfigs = parseControllerConfigs(pmsConfigJson);
List<RicConfig> ricConfigs = parseRics(pmsConfigJson, controllerConfigs);
- checkConfigurationConsistency(ricConfigs, controllerConfigs);
+ checkConfigurationConsistency(ricConfigs);
return ConfigParserResult.builder() //
.ricConfigs(ricConfigs) //
@@ -123,8 +123,7 @@ public class ApplicationConfigParser {
return CharStreams.toString(new InputStreamReader(in, StandardCharsets.UTF_8));
}
- private void checkConfigurationConsistency(List<RicConfig> ricConfigs,
- Map<String, ControllerConfig> controllerConfigs) throws ServiceException {
+ private void checkConfigurationConsistency(List<RicConfig> ricConfigs) throws ServiceException {
Set<String> ricUrls = new HashSet<>();
Set<String> ricNames = new HashSet<>();
for (RicConfig ric : ricConfigs) {
@@ -218,8 +217,4 @@ public class ApplicationConfigParser {
private JsonArray getAsJsonArray(JsonObject obj, String memberName) throws ServiceException {
return get(obj, memberName).getAsJsonArray();
}
-
- private static String getAsString(JsonObject obj, String memberName) throws ServiceException {
- return get(obj, memberName).getAsString();
- }
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java
index 4b0d6b58..51ac59bc 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java
@@ -39,7 +39,7 @@ import reactor.core.publisher.Mono;
import java.io.IOException;
import java.util.Optional;
-@RestController("ConfigurationControllerV2")
+@RestController("configurationControllerV2")
@Tag( //
name = ConfigurationController.API_NAME, //
description = ConfigurationController.API_DESCRIPTION //
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 630be491..9299ffeb 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
@@ -36,6 +36,7 @@ import java.util.List;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v2.A1PolicyManagementApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.AuthorizationCheck;
@@ -51,7 +52,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.PolicyStatusInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -62,7 +62,8 @@ import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-@RestController("PolicyControllerV2")
+@RestController("policyControllerV2")
+@RequiredArgsConstructor
@Tag(//
name = PolicyController.API_NAME, //
description = PolicyController.API_DESCRIPTION //
@@ -71,7 +72,6 @@ public class PolicyController implements A1PolicyManagementApi {
public static final String API_NAME = "A1 Policy Management";
public static final String API_DESCRIPTION = "";
-
public static class RejectionException extends Exception {
private static final long serialVersionUID = 1L;
@@ -84,24 +84,16 @@ public class PolicyController implements A1PolicyManagementApi {
}
}
- @Autowired
- private Rics rics;
- @Autowired
- private PolicyTypes policyTypes;
- @Autowired
- private Policies policies;
- @Autowired
- private A1ClientFactory a1ClientFactory;
- @Autowired
- private Services services;
- @Autowired
- private ObjectMapper objectMapper;
- @Autowired
- private AuthorizationCheck authorization;
+ private final Rics rics;
+ private final PolicyTypes policyTypes;
+ private final Policies policies;
+ private final A1ClientFactory a1ClientFactory;
+ private final Services services;
+ private final ObjectMapper objectMapper;
+ private final AuthorizationCheck authorization;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static Gson gson = new GsonBuilder() //
- .create(); //
+ private static final Gson gson = new GsonBuilder().create();
@Override
public Mono<ResponseEntity<PolicyTypeDefinition>> getPolicyTypeDefinition(String policyTypeId, ServerWebExchange exchange)
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
index 8907774b..f7872a38 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v2.NearRtRicRepositoryApi;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.InvalidRequestException;
@@ -32,7 +33,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.RicInfoList;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -42,7 +42,8 @@ import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.List;
-@RestController("RicRepositoryControllerV2")
+@RestController("ricRepositoryControllerV2")
+@RequiredArgsConstructor
@Tag( //
name = RicRepositoryController.API_NAME, //
description = RicRepositoryController.API_DESCRIPTION //
@@ -52,17 +53,11 @@ public class RicRepositoryController implements NearRtRicRepositoryApi {
public static final String API_NAME = "NearRT-RIC Repository";
public static final String API_DESCRIPTION = "";
- @Autowired
- private Rics rics;
+ private final Rics rics;
+ final PolicyTypes types;
+ final ObjectMapper objectMapper;
- @Autowired
- PolicyTypes types;
-
- @Autowired
- ObjectMapper objectMapper;
-
- private static Gson gson = new GsonBuilder() //
- .create(); //
+ private static final Gson gson = new GsonBuilder().create();
private static final String GET_RIC_BRIEF = "Returns info for one Near-RT RIC";
private static final String GET_RIC_DETAILS =
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 1b885781..4da11a9d 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
@@ -21,6 +21,7 @@
package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v2.ServiceRegistryAndSupervisionApi;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.ServiceRegistrationInfo;
@@ -32,7 +33,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.repository.Service;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -48,7 +48,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-@RestController("ServiceControllerV2")
+@RestController("serviceControllerV2")
+@RequiredArgsConstructor
@Tag( //
name = ServiceController.API_NAME, //
description = ServiceController.API_DESCRIPTION //
@@ -64,13 +65,7 @@ public class ServiceController implements ServiceRegistryAndSupervisionApi {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- @Autowired
- private PolicyController policyController;
-
- ServiceController(Services services, Policies policies) {
- this.services = services;
- this.policies = policies;
- }
+ private final PolicyController policyController;
private static final String GET_SERVICE_DETAILS =
"Either information about a registered service with given identity or all registered services are returned.";
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
index 4ec3652d..b2cb69ce 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-@RestController("StatusControllerV2")
+@RestController("statusControllerV2")
@Tag( name = StatusController.API_NAME,
description = StatusController.API_DESCRIPTION
)
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3.java
index 42e777b8..40f84647 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ConfigurationControllerV3.java
@@ -19,17 +19,18 @@
package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v3;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v3.ConfigurationApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ConfigurationController;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-@RestController("ConfigurationControllerV3")
+@RestController("configurationControllerV3")
+@RequiredArgsConstructor
@Tag( //
name = ConfigurationControllerV3.API_NAME, //
description = ConfigurationControllerV3.API_DESCRIPTION //
@@ -39,9 +40,7 @@ public class ConfigurationControllerV3 implements ConfigurationApi {
public static final String API_NAME = "Management of configuration";
public static final String API_DESCRIPTION = "API used to create or fetch the application configuration";
-
- @Autowired
- private ConfigurationController configurationController;
+ private final ConfigurationController configurationController;
@Override
public Mono<ResponseEntity<String>> getConfiguration(ServerWebExchange exchange) throws Exception {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3.java
index 4d9f3277..08aa7c7b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3.java
@@ -21,6 +21,7 @@
package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v3;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v3.A1PolicyManagementApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicyController;
@@ -29,15 +30,14 @@ import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyObjectInfor
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyTypeInformation;
import org.onap.ccsdk.oran.a1policymanagementservice.service.v3.ErrorHandlingService;
import org.onap.ccsdk.oran.a1policymanagementservice.service.v3.PolicyService;
-import org.onap.ccsdk.oran.a1policymanagementservice.util.v3.Helper;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-@RestController("PolicyControllerV3")
+@RestController("policyControllerV3")
+@RequiredArgsConstructor
@Tag(//
name = PolicyController.API_NAME, //
description = PolicyController.API_DESCRIPTION //
@@ -46,54 +46,49 @@ import reactor.core.publisher.Mono;
public class PolicyControllerV3 implements A1PolicyManagementApi {
public static final String API_NAME = "A1 Policy Management";
public static final String API_DESCRIPTION = "API to create,update and get policies or policy definitions";
- @Autowired
- private PolicyService policyService;
- @Autowired
- private Helper helper;
-
- @Autowired
- private ErrorHandlingService errorHandlingService;
+ private final PolicyService policyService;
+ private final ErrorHandlingService errorHandlingService;
@Override
public Mono<ResponseEntity<PolicyObjectInformation>> createPolicy(Mono<PolicyObjectInformation> policyObjectInformation, ServerWebExchange exchange) {
return policyObjectInformation.flatMap(policyObjectInfo -> policyService.createPolicyService(policyObjectInfo, exchange)
- .doOnError(error -> errorHandlingService.handleError(error)));
+ .doOnError(errorHandlingService::handleError));
}
@Override
public Mono<ResponseEntity<Void>> deletePolicy(String policyId, String accept, ServerWebExchange exchange) throws Exception {
return policyService.deletePolicyService(policyId, exchange)
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
public Mono<ResponseEntity<Object>> getPolicy(String policyId, String accept, ServerWebExchange exchange) throws Exception {
return policyService.getPolicyService(policyId, exchange)
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
- public Mono<ResponseEntity<Flux<PolicyInformation>>> getPolicyIds(String policyTypeId, String nearRtRicId, String serviceId, String typeName, String accept, ServerWebExchange exchange) throws Exception {
+ public Mono<ResponseEntity<Flux<PolicyInformation>>> getAllPolicies(String policyTypeId, String nearRtRicId, String serviceId, String typeName, String accept, ServerWebExchange exchange) throws Exception {
return policyService.getPolicyIdsService(policyTypeId, nearRtRicId, serviceId, typeName, exchange)
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
public Mono<ResponseEntity<Object>> getPolicyTypeDefinition(String policyTypeId, String accept, ServerWebExchange exchange) throws Exception {
return policyService.getPolicyTypeDefinitionService(policyTypeId)
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
public Mono<ResponseEntity<Flux<PolicyTypeInformation>>> getPolicyTypes(String nearRtRicId, String typeName, String compatibleWithVersion, String accept, ServerWebExchange exchange) throws Exception {
return policyService.getPolicyTypesService(nearRtRicId, typeName, compatibleWithVersion, exchange)
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
public Mono<ResponseEntity<Object>> putPolicy(String policyId, Mono<Object> body, ServerWebExchange exchange) throws Exception {
return body.flatMap(payload -> policyService.putPolicyService(policyId, payload, exchange))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java
index 6254a15e..89d47d7f 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/RicRepositoryControllerV3.java
@@ -21,6 +21,7 @@
package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v3;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v3.NearRtRicRepositoryApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
import org.onap.ccsdk.oran.a1policymanagementservice.mappers.v3.RicRepositoryMapper;
@@ -28,14 +29,14 @@ import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.RicRepositor
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.RicInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.RicInfoList;
import org.onap.ccsdk.oran.a1policymanagementservice.service.v3.ErrorHandlingService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-@RestController("RicRepositoryControllerV3")
+@RestController("ricRepositoryControllerV3")
+@RequiredArgsConstructor
@Tag(
name = RicRepositoryControllerV3.API_NAME,
description = RicRepositoryControllerV3.API_DESCRIPTION
@@ -45,26 +46,24 @@ public class RicRepositoryControllerV3 implements NearRtRicRepositoryApi {
public static final String API_NAME = "NearRT-RIC Repository V3";
public static final String API_DESCRIPTION = "API used to get the NearRT-RIC for the managed element";
- @Autowired
- private RicRepositoryController ricRepositoryController;
- @Autowired
- private RicRepositoryMapper ricRepositoryMapper;
+ private final RicRepositoryController ricRepositoryController;
- @Autowired
- ErrorHandlingService errorHandlingService;
+ private final RicRepositoryMapper ricRepositoryMapper;
+
+ private final ErrorHandlingService errorHandlingService;
@Override
public Mono<ResponseEntity<RicInfo>> getRic(String managedElementId, String ricId, String accept, ServerWebExchange exchange) throws Exception {
return ricRepositoryController.getRic(managedElementId, ricId, exchange)
.map(responseEntity -> new ResponseEntity<>(ricRepositoryMapper.toRicInfoV3(responseEntity.getBody()), responseEntity.getStatusCode()))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
public Mono<ResponseEntity<RicInfoList>> getRics(String policyTypeId, String accept, ServerWebExchange exchange) throws Exception {
return ricRepositoryController.getRics(policyTypeId, exchange)
.map(responseEntity -> new ResponseEntity<>(ricRepositoryMapper.toRicInfoListV3(responseEntity.getBody()), responseEntity.getStatusCode()))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3.java
index a0ffeed3..d29e37a6 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/ServiceControllerV3.java
@@ -21,6 +21,7 @@
package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v3;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v3.ServiceRegistryAndSupervisionApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ServiceController;
@@ -28,14 +29,14 @@ import org.onap.ccsdk.oran.a1policymanagementservice.mappers.v3.ServiceControlle
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.ServiceRegistrationInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.ServiceStatusList;
import org.onap.ccsdk.oran.a1policymanagementservice.service.v3.ErrorHandlingService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-@RestController("ServiceControllerV3")
+@RestController("serviceControllerV3")
+@RequiredArgsConstructor
@Tag( //
name = ServiceControllerV3.API_NAME, //
description = ServiceControllerV3.API_DESCRIPTION //
@@ -46,14 +47,11 @@ public class ServiceControllerV3 implements ServiceRegistryAndSupervisionApi {
public static final String API_NAME = "Service Registry and Supervision";
public static final String API_DESCRIPTION = "API used to keep the service Alive with in the timeout period";
- @Autowired
- private ServiceController serviceController;
+ private final ServiceController serviceController;
- @Autowired
- private ServiceControllerMapper serviceControllerMapper;
+ private final ServiceControllerMapper serviceControllerMapper;
- @Autowired
- ErrorHandlingService errorHandlingService;
+ private final ErrorHandlingService errorHandlingService;
@Override
public Mono<ResponseEntity<Object>> deleteService(String serviceId, String accept, ServerWebExchange exchange) throws Exception {
@@ -65,7 +63,7 @@ public class ServiceControllerV3 implements ServiceRegistryAndSupervisionApi {
return serviceController.getServices(serviceId, exchange)
.map(responseEntity -> new ResponseEntity<>(serviceControllerMapper.toServiceStatusListV3(
responseEntity.getBody()), responseEntity.getStatusCode()))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
@Override
@@ -75,8 +73,7 @@ public class ServiceControllerV3 implements ServiceRegistryAndSupervisionApi {
@Override
public Mono<ResponseEntity<Object>> putService(Mono<ServiceRegistrationInfo> serviceRegistrationInfo, ServerWebExchange exchange) throws Exception {
- return serviceController.putService(serviceRegistrationInfo.map(serviceRegistrationInfoV2 ->
- serviceControllerMapper.toServiceRegistrationInfoV2(serviceRegistrationInfoV2)), exchange)
- .doOnError(error -> errorHandlingService.handleError(error));
+ return serviceController.putService(serviceRegistrationInfo.map(serviceControllerMapper::toServiceRegistrationInfoV2), exchange)
+ .doOnError(errorHandlingService::handleError);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/StatusControllerV3.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/StatusControllerV3.java
index dbbb2fc0..5ef32901 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/StatusControllerV3.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/StatusControllerV3.java
@@ -21,21 +21,21 @@
package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v3;
import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.api.v3.HealthCheckApi;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
-import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.RicRepositoryController;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.StatusController;
import org.onap.ccsdk.oran.a1policymanagementservice.mappers.v3.StatusControllerMapper;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.StatusInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.service.v3.ErrorHandlingService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-@RestController("StatusControllerV3")
+@RestController("statusControllerV3")
+@RequiredArgsConstructor
@Tag( //
name = StatusControllerV3.API_NAME, //
description = StatusControllerV3.API_DESCRIPTION //
@@ -46,20 +46,18 @@ public class StatusControllerV3 implements HealthCheckApi {
public static final String API_NAME = "Health Check";
public static final String API_DESCRIPTION = "API used to get the health status and statistics of this service";
- @Autowired
- private StatusController statusController;
- @Autowired
- private StatusControllerMapper statusControllerMapper;
+ private final StatusController statusController;
- @Autowired
- ErrorHandlingService errorHandlingService;
+ private final StatusControllerMapper statusControllerMapper;
+
+ private final ErrorHandlingService errorHandlingService;
@Override
public Mono<ResponseEntity<StatusInfo>> getStatus(ServerWebExchange exchange) throws Exception {
return statusController.getStatus(exchange)
.map(statusInfoResponseEntity -> new ResponseEntity<>(statusControllerMapper.toStatusInfoV3
(statusInfoResponseEntity.getBody()), statusInfoResponseEntity.getStatusCode()))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/AuthorizationService.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/AuthorizationService.java
index ac4320a1..af6f0abe 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/AuthorizationService.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/AuthorizationService.java
@@ -21,19 +21,19 @@
package org.onap.ccsdk.oran.a1policymanagementservice.service.v3;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.AuthorizationCheck;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.PolicyAuthorizationRequest.Input.AccessType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@Service
+@RequiredArgsConstructor
public class AuthorizationService {
- @Autowired
- private AuthorizationCheck authorization;
+ private final AuthorizationCheck authorization;
public Mono<Policy> authCheck (ServerWebExchange serverWebExchange, Policy policy, AccessType accessType){
return authorization.doAccessControl(serverWebExchange.getRequest().getHeaders().toSingleValueMap(),
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/PolicyService.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/PolicyService.java
index a892bfa3..868a336f 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/PolicyService.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/service/v3/PolicyService.java
@@ -21,6 +21,7 @@
package org.onap.ccsdk.oran.a1policymanagementservice.service.v3;
import com.google.gson.Gson;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.PolicyAuthorizationRequest.Input.AccessType;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts;
@@ -33,7 +34,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.repository.*;
import org.onap.ccsdk.oran.a1policymanagementservice.util.v3.Helper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -47,32 +47,18 @@ import java.util.Collection;
import java.util.Map;
@Service
+@RequiredArgsConstructor
public class PolicyService {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- @Autowired
- private Helper helper;
-
- @Autowired
- private Rics rics;
-
- @Autowired
- private PolicyTypes policyTypes;
-
- @Autowired
- private Policies policies;
-
- @Autowired
- private AuthorizationService authorizationService;
-
- @Autowired
- private A1ClientFactory a1ClientFactory;
-
- @Autowired
- private ErrorHandlingService errorHandlingService;
-
- @Autowired
- private Gson gson;
+ private final Helper helper;
+ private final Rics rics;
+ private final PolicyTypes policyTypes;
+ private final Policies policies;
+ private final AuthorizationService authorizationService;
+ private final A1ClientFactory a1ClientFactory;
+ private final ErrorHandlingService errorHandlingService;
+ private final Gson gson;
public Mono<ResponseEntity<PolicyObjectInformation>> createPolicyService
(PolicyObjectInformation policyObjectInfo, ServerWebExchange serverWebExchange) {
@@ -83,15 +69,15 @@ public class PolicyService {
PolicyType policyType = policyTypes.getType(policyObjectInfo.getPolicyTypeId());
Policy policy = helper.buildPolicy(policyObjectInfo, policyType, ric, helper.policyIdGeneration(policyObjectInfo));
return helper.isPolicyAlreadyCreated(policy,policies)
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(policyBuilt -> authorizationService.authCheck(serverWebExchange, policy, AccessType.WRITE)
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(policyNotUsed -> ric.getLock().lock(Lock.LockType.SHARED, "createPolicy"))
.flatMap(grant -> postPolicy(policy, grant))
.map(locationHeaderValue ->
new ResponseEntity<PolicyObjectInformation>(policyObjectInfo,helper.createHttpHeaders(
"location",helper.buildURI(policy.getId(), serverWebExchange)), HttpStatus.CREATED))
- .doOnError(error -> errorHandlingService.handleError(error)));
+ .doOnError(errorHandlingService::handleError));
} catch (Exception ex) {
return Mono.error(ex);
}
@@ -100,15 +86,15 @@ public class PolicyService {
private Mono<String> postPolicy(Policy policy, Lock.Grant grant) {
return helper.checkRicStateIdle(policy.getRic())
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(ric -> helper.checkSupportedType(ric, policy.getType()))
- .doOnError(error -> errorHandlingService.handleError(error))
- .flatMap(ric -> a1ClientFactory.createA1Client(ric))
+ .doOnError(errorHandlingService::handleError)
+ .flatMap(a1ClientFactory::createA1Client)
.flatMap(a1Client -> a1Client.putPolicy(policy))
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.doOnNext(policyString -> policies.put(policy))
.doFinally(releaseLock -> grant.unlockBlocking())
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
public Mono<ResponseEntity<Object>> putPolicyService(String policyId, Object body, ServerWebExchange exchange) {
@@ -119,12 +105,12 @@ public class PolicyService {
Policy updatedPolicy = helper.buildPolicy(pos, existingPolicy.getType(), existingPolicy.getRic(), policyId);
Ric ric = existingPolicy.getRic();
return authorizationService.authCheck(exchange, updatedPolicy, AccessType.WRITE)
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(policy -> ric.getLock().lock(Lock.LockType.SHARED, "updatePolicy"))
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(grant -> postPolicy(updatedPolicy, grant))
.map(header -> new ResponseEntity<Object>(policies.get(updatedPolicy.getId()).getJson(), HttpStatus.OK))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
} catch(Exception ex) {
return Mono.error(ex);
}
@@ -178,7 +164,7 @@ public class PolicyService {
Policy policy = policies.getPolicy(policyId);
return authorizationService.authCheck(serverWebExchange, policy, AccessType.READ)
.map(x -> new ResponseEntity<Object>(policy.getJson(), HttpStatus.OK))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
public Mono<ResponseEntity<Object>> getPolicyTypeDefinitionService(String policyTypeId)
@@ -193,24 +179,24 @@ public class PolicyService {
throws EntityNotFoundException {
Policy singlePolicy = policies.getPolicy(policyId);
return authorizationService.authCheck(serverWebExchange, singlePolicy, AccessType.WRITE)
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(policy -> policy.getRic().getLock().lock(Lock.LockType.SHARED, "deletePolicy"))
.flatMap(grant -> deletePolicy(singlePolicy, grant))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
private Mono<ResponseEntity<Void>> deletePolicy(Policy policy, Lock.Grant grant) {
return helper.checkRicStateIdle(policy.getRic())
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.flatMap(ric -> helper.checkSupportedType(ric, policy.getType()))
- .doOnError(error -> errorHandlingService.handleError(error))
- .flatMap(ric -> a1ClientFactory.createA1Client(ric))
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
+ .flatMap(a1ClientFactory::createA1Client)
+ .doOnError(errorHandlingService::handleError)
.flatMap(a1Client -> a1Client.deletePolicy(policy))
- .doOnError(error -> errorHandlingService.handleError(error))
+ .doOnError(errorHandlingService::handleError)
.doOnNext(policyString -> policies.remove(policy))
.doFinally(releaseLock -> grant.unlockBlocking())
.map(successResponse -> new ResponseEntity<Void>(HttpStatus.NO_CONTENT))
- .doOnError(error -> errorHandlingService.handleError(error));
+ .doOnError(errorHandlingService::handleError);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java
index 638d9504..0cb91353 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/util/v3/Helper.java
@@ -22,6 +22,7 @@ package org.onap.ccsdk.oran.a1policymanagementservice.util.v3;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import lombok.RequiredArgsConstructor;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyInformation;
import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyObjectInformation;
@@ -29,7 +30,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.models.v3.PolicyTypeInforma
import org.onap.ccsdk.oran.a1policymanagementservice.repository.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@@ -45,14 +45,15 @@ import java.util.UUID;
import java.util.stream.Collectors;
@Component
+@RequiredArgsConstructor
public class Helper {
- @Autowired
- private Services services;
+ private final Services services;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static Gson gson = new GsonBuilder().create();
+ private static final Gson gson = new GsonBuilder().create();
+
public void keepServiceAlive(String name) {
Service s = this.services.get(name);
if (s != null) {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java
index e81a936d..211a9a39 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v3/PolicyControllerV3Test.java
@@ -254,4 +254,63 @@ class PolicyControllerV3Test {
testHelper.testSuccessResponse(responseMonoGet, HttpStatus.OK, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
}
+
+ @Test
+ @DisplayName("test get all Policies")
+ void testGetAllPolicies() throws Exception {
+ String nonRtRicIdOne = "ric.11";
+ String nonRtRicIdTwo = "ric.22";
+ String policyTypeName = "type1_1.2.3";
+ String url = "/policies";
+ testHelper.addPolicyType(policyTypeName, nonRtRicIdOne);
+ String policyBodyOne = testHelper.postPolicyBody(nonRtRicIdOne, policyTypeName, "policyOne");
+ testHelper.addPolicyType(policyTypeName, nonRtRicIdTwo);
+ String policyBodyTwo = testHelper.postPolicyBody(nonRtRicIdTwo, policyTypeName, "policyTwo");
+ testHelper.restClientV3().postForEntity(url, policyBodyOne).block();
+ testHelper.restClientV3().postForEntity(url, policyBodyTwo).block();
+ Mono<ResponseEntity<String>> responseMonoGet = testHelper.restClientV3().getForEntity(url);
+ testHelper.testSuccessResponse(responseMonoGet, HttpStatus.OK, responseBody ->
+ responseBody.contains("[{\"policyId\":\"policyTwo\",\"nearRtRicId\":\"ric.22\"},{\"policyId\":\"policyOne\",\"nearRtRicId\":\"ric.11\"}]"));
}
+
+ @Test
+ @DisplayName("test get PolicyType")
+ void testGetPolicyType() throws Exception {
+ String nonRtRicId = "ric.1";
+ String policyTypeName = "type1_1.2.3";
+ String url = "/policy-types";
+ testHelper.addPolicyType(policyTypeName, nonRtRicId);
+ Mono<ResponseEntity<String>> responseMonoGet = testHelper.restClientV3().getForEntity(url+"/" +policyTypeName);
+ testHelper.testSuccessResponse(responseMonoGet, HttpStatus.OK, responseBody -> !(responseBody.isEmpty()));
+ }
+
+ @Test
+ @DisplayName("test get All PolicyTypes")
+ void testGetAllPolicyTypes() throws Exception {
+ String nonRtRicId = "ric.1";
+ String policyTypeName = "type1_1.2.3";
+ String url = "/policy-types";
+ testHelper.addPolicyType(policyTypeName, nonRtRicId);
+ Mono<ResponseEntity<String>> responseMonoGet = testHelper.restClientV3().getForEntity(url);
+ testHelper.testSuccessResponse(responseMonoGet, HttpStatus.OK, responseBody -> responseBody.contains(
+ "{\"policyTypeId\":\"type1_1.2.3\",\"nearRtRicId\":\"ric.1\"}]"
+ ));
+ }
+
+ @Test
+ @DisplayName("test update Policy")
+ void testUpdatePolicy() throws Exception {
+ String nonRtRicId = "ric.1";
+ String policyTypeName = "type1_1.2.3";
+ String url = "/policies";
+ testHelper.addPolicyType(policyTypeName, nonRtRicId);
+ String policyBodyForPost = testHelper.postPolicyBody(nonRtRicId, policyTypeName, "policyOne");
+ testHelper.restClientV3().postForEntity(url, policyBodyForPost).block();
+ String policyBodyForPut = testHelper.putPolicyBody(nonRtRicId, policyTypeName, "policyOne", "ue5200",
+ "qos5200", "5200.0");
+ testHelper.restClientV3().putForEntity(url+"/policyOne", policyBodyForPut).block();
+ Mono<ResponseEntity<String>> responseMonoGet = testHelper.restClientV3().getForEntity(url+"/policyOne");
+ testHelper.testSuccessResponse(responseMonoGet, HttpStatus.OK, responseBody ->
+ responseBody.contains("{\"scope\":{\"ueId\":\"ue5200\",\"qosId\":\"qos5200\"},\"qosObjectives\":{\"priorityLevel\":5200.0}"));
+ }
+} \ No newline at end of file
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/v3/TestHelper.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/v3/TestHelper.java
index 5463b0a1..b0b5858a 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/v3/TestHelper.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/v3/TestHelper.java
@@ -170,10 +170,31 @@ public class TestHelper {
return gson.toJson(policyObjectInfo);
}
+ public String putPolicyBody(String nearRtRicId, String policyTypeName, String policyId, String ueId, String qosId,
+ String priorityLevel) {
+ PolicyObjectInformation policyObjectInfo = new PolicyObjectInformation(nearRtRicId, dummyPolicyObjectForPut(
+ ueId, qosId, priorityLevel), policyTypeName);
+ if (policyId != null && !policyId.isEmpty() && !policyId.isBlank())
+ policyObjectInfo.setPolicyId(policyId);
+ return gson.toJson(policyObjectInfo);
+ }
+
public PolicyObjectInformation policyObjectInfo(String nearRtRicId, String policyTypeName) {
return gson.fromJson(postPolicyBody(nearRtRicId, policyTypeName, ""), PolicyObjectInformation.class);
}
+ public JsonObject dummyPolicyObjectForPut(String... values) {
+ return JsonParser.parseString("{\n" +
+ " \"scope\": {\n" +
+ " \"ueId\": \"" + values[0] + "\",\n" +
+ " \"qosId\": \"" + values[1] + "\"\n" +
+ " },\n" +
+ " \"qosObjectives\": {\n" +
+ " \"priorityLevel\": " + values[2] + "\n" +
+ " }\n" +
+ " }").getAsJsonObject();
+ }
+
public JsonObject dummyPolicyObject() {
return JsonParser.parseString("{\n" +
" \"scope\": {\n" +