Added GET policy_ids in the agent NBI
[nonrtric.git] / policy-agent / src / test / java / org / oransc / policyagent / ApplicationTest.java
index 5b6c5ba..55b0b43 100644 (file)
@@ -496,6 +496,32 @@ public class ApplicationTest {
         testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
     }
 
+    @Test
+    public void testGetPolicyIdsFilter() throws Exception {
+        addPolicy("id1", "type1", "service1", "ric1");
+        addPolicy("id2", "type1", "service2", "ric1");
+        addPolicy("id3", "type2", "service1", "ric1");
+
+        String url = "/policy_ids?type=type1";
+        String rsp = restClient().get(url).block();
+        logger.info(rsp);
+        assertThat(rsp).contains("id1");
+        assertThat(rsp).contains("id2");
+        assertThat(rsp.contains("id3")).isFalse();
+
+        url = "/policy_ids?type=type1&service=service1&ric=ric1";
+        rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[\"id1\"]");
+
+        // Test get policy ids for non existing type
+        url = "/policy_ids?type=type1XXX";
+        testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
+
+        // Test get policy ids for non existing RIC
+        url = "/policy_ids?ric=XXX";
+        testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
+    }
+
     @Test
     public void testPutAndGetService() throws Exception {
         // PUT