aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test/java/org
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2022-11-28 09:40:36 +0100
committerPatrik Buhr <patrik.buhr@est.tech>2022-12-06 14:44:33 +0000
commitc7f757e98066775ed2fdeb67f3d31777e8430624 (patch)
tree117bb2b39183b9c59a5a7935e1057391ec90cb58 /a1-policy-management/src/test/java/org
parentbf5e4cd0b2b2ad91238a34c558ba888c38117376 (diff)
A1-PMS, make service id optional in PUT Policy
Improved API documentation. Fixed a bug that lead to that a policy could be connected to several services if the service_id was changed. Change-Id: I211f5db32747fc912b7ba85bfbc15ce50ee725dd Issue-ID: CCSDK-3819 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'a1-policy-management/src/test/java/org')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java48
1 files changed, 44 insertions, 4 deletions
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 76838bb8..bec55735 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
@@ -434,7 +434,7 @@ class ApplicationTest {
}
private String putPolicyBody(String serviceName, String ricId, String policyTypeName, String policyInstanceId,
- boolean isTransient) {
+ boolean isTransient, String statusNotificationUri) {
PolicyInfo info = new PolicyInfo();
info.policyId = policyInstanceId;
info.policyTypeId = policyTypeName;
@@ -445,12 +445,12 @@ class ApplicationTest {
if (isTransient) {
info.isTransient = isTransient;
}
- info.statusNotificationUri = "statusNotificationUri";
+ info.statusNotificationUri = statusNotificationUri;
return gson.toJson(info);
}
private String putPolicyBody(String serviceName, String ricId, String policyTypeName, String policyInstanceId) {
- return putPolicyBody(serviceName, ricId, policyTypeName, policyInstanceId, false);
+ return putPolicyBody(serviceName, ricId, policyTypeName, policyInstanceId, false, "statusUri");
}
@Test
@@ -465,7 +465,7 @@ class ApplicationTest {
// PUT a transient policy
String url = "/policies";
- String policyBody = putPolicyBody(serviceName, ricId, policyTypeName, policyInstanceId, true);
+ String policyBody = putPolicyBody(serviceName, ricId, policyTypeName, policyInstanceId, true, "statusNotif");
this.rics.getRic(ricId).setState(Ric.RicState.AVAILABLE);
restClient().put(url, policyBody).block();
@@ -507,6 +507,27 @@ class ApplicationTest {
}
@Test
+ void testPutPolicy_NoServiceNoStatusUri() throws Exception {
+ String ricId = "ric.1";
+ String policyTypeName = "type1_1.2.3";
+ String policyInstanceId = "instance_1.2.3";
+
+ addPolicyType(policyTypeName, ricId);
+
+ // PUT a transient policy
+ String url = "/policies";
+ String policyBody = putPolicyBody(null, ricId, policyTypeName, policyInstanceId, true, null);
+ this.rics.getRic(ricId).setState(Ric.RicState.AVAILABLE);
+
+ restClient().put(url, policyBody).block();
+
+ Policy policy = policies.getPolicy(policyInstanceId);
+ assertThat(policy).isNotNull();
+ assertThat(policy.getOwnerServiceId()).isBlank();
+ assertThat(policy.getStatusNotificationUri()).isBlank();
+ }
+
+ @Test
/**
* Test that HttpStatus and body from failing REST call to A1 is passed on to
* the caller.
@@ -554,6 +575,25 @@ class ApplicationTest {
}
@Test
+ void testUpdateService() throws Exception {
+ this.addRic("ric1");
+ this.addPolicy("p", "type1", "", "ric1");
+
+ String url = "/policies?service_id=";
+ String resp = restClient().get(url).block();
+ assertThat(resp).contains("[\"p\"]");
+
+ this.addPolicy("p", "type1", "service", "ric1");
+ url = "/policies?service_id=";
+ resp = restClient().get(url).block();
+ assertThat(resp).contains("[]");
+
+ url = "/policies?service_id=service";
+ resp = restClient().get(url).block();
+ assertThat(resp).contains("[\"p\"]");
+ }
+
+ @Test
void testRefuseToUpdatePolicy() throws Exception {
// Test that only the json can be changed for a already created policy
// In this case service is attempted to be changed