diff options
Diffstat (limited to 'a1-policy-management/src/test/java')
-rw-r--r-- | a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java | 48 |
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 |