aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java10
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java4
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java29
3 files changed, 23 insertions, 20 deletions
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 256b4782..8dd2df61 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
@@ -97,13 +97,13 @@ public class PolicyController {
private static Gson gson = new GsonBuilder() //
.create(); //
- @GetMapping(path = Consts.V2_API_ROOT + "/policy-types/{policyTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @GetMapping(path = "/v2/policy-types/{policytype_id:.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns a policy type definition")
@ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy type", response = PolicyTypeInfo.class), //
- @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "Policy type is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyType( //
- @PathVariable("policyTypeId") String policyTypeId) {
+ @PathVariable("policytype_id") String policyTypeId) {
try {
PolicyType type = policyTypes.getType(policyTypeId);
PolicyTypeInfo info = new PolicyTypeInfo(type.schema());
@@ -134,7 +134,7 @@ public class PolicyController {
}
}
- @GetMapping(path = Consts.V2_API_ROOT + "/policies/{policy_id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @GetMapping(path = Consts.V2_API_ROOT + "/policies/{policy_id:.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns a policy") //
@ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy found", response = PolicyInfo.class), //
@@ -150,7 +150,7 @@ public class PolicyController {
}
}
- @DeleteMapping(Consts.V2_API_ROOT + "/policies/{policy_id}")
+ @DeleteMapping(Consts.V2_API_ROOT + "/policies/{policy_id:.+}")
@ApiOperation(value = "Delete a policy")
@ApiResponses(value = { //
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
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 b2fa029a..a8fc7e6d 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
@@ -143,9 +143,9 @@ public class ServiceController {
@ApiResponse(code = 204, message = "Service unregistered"),
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Service not found", response = ErrorResponse.ErrorInfo.class)})
- @DeleteMapping(Consts.V2_API_ROOT + "/services/{serviceId}")
+ @DeleteMapping(Consts.V2_API_ROOT + "/services/{service_id:.+}")
public ResponseEntity<Object> deleteService(//
- @PathVariable("serviceId") String serviceId) {
+ @PathVariable("service_id") String serviceId) {
try {
Service service = removeService(serviceId);
// Remove the policies from the repo and let the consistency monitoring
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 02fdaf9c..a0cb2af8 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
@@ -333,10 +333,10 @@ class ApplicationTest {
@Test
void testPutPolicy() throws Exception {
- String serviceName = "service1";
- String ricId = "ric1";
- String policyTypeName = "type1";
- String policyInstanceId = "instance1";
+ String serviceName = "service.1";
+ String ricId = "ric.1";
+ String policyTypeName = "type1_1.2.3";
+ String policyInstanceId = "instance_1.2.3";
putService(serviceName);
addPolicyType(policyTypeName, ricId);
@@ -352,7 +352,7 @@ class ApplicationTest {
assertThat(policy).isNotNull();
assertThat(policy.id()).isEqualTo(policyInstanceId);
assertThat(policy.ownerServiceId()).isEqualTo(serviceName);
- assertThat(policy.ric().id()).isEqualTo("ric1");
+ assertThat(policy.ric().id()).isEqualTo(ricId);
assertThat(policy.isTransient()).isTrue();
// Put a non transient policy
@@ -463,10 +463,11 @@ class ApplicationTest {
@Test
void testDeletePolicy() throws Exception {
- addPolicy("id", "typeName", "service1", "ric1");
+ String policyId = "id.1";
+ addPolicy(policyId, "typeName", "service1", "ric1");
assertThat(policies.size()).isEqualTo(1);
- String url = "/policies/id";
+ String url = "/policies/" + policyId;
ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
@@ -478,11 +479,13 @@ class ApplicationTest {
@Test
void testGetPolicyType() throws Exception {
- addPolicyType("type1", "ric1");
+ String typeId = "AC.D";
+ addPolicyType(typeId, "ric1");
waitForRicState("ric1", RicState.AVAILABLE);
- String url = "/policy-types/type1";
+ String url = "/policy-types/" + typeId;
+
String rsp = this.restClient().get(url).block();
PolicyTypeInfo info = gson.fromJson(rsp, PolicyTypeInfo.class);
@@ -595,12 +598,12 @@ class ApplicationTest {
@Test
void testPutAndGetService() throws Exception {
// PUT
- String serviceName = "name";
+ String serviceName = "ac.dc";
putService(serviceName, 0, HttpStatus.CREATED);
putService(serviceName, 0, HttpStatus.OK);
// GET one service
- String url = "/services?service_id=name";
+ String url = "/services?service_id=" + serviceName;
String rsp = restClient().get(url).block();
ServiceStatusList info = gson.fromJson(rsp, ServiceStatusList.class);
assertThat(info.statusList).hasSize(1);
@@ -615,13 +618,13 @@ class ApplicationTest {
logger.info(rsp);
// Keep alive
- url = "/services/name/keepalive";
+ url = "/services/" + serviceName + "/keepalive";
ResponseEntity<?> entity = restClient().putForEntity(url).block();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
// DELETE service
assertThat(services.size()).isEqualTo(1);
- url = "/services/name";
+ url = "/services/" + serviceName;
restClient().delete(url).block();
assertThat(services.size()).isZero();