+ public void testDeletePolicy() throws Exception {
+ addPolicy("id", "typeName", "service1", "ric1");
+ assertThat(policies.size()).isEqualTo(1);
+
+ String url = "/policy?instance=id";
+ ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
+
+ assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
+ assertThat(policies.size()).isEqualTo(0);
+
+ // Delete a non existing policy
+ testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
+ }
+
+ @Test
+ public void testGetPolicySchemas() throws Exception {
+ addPolicyType("type1", "ric1");
+ addPolicyType("type2", "ric2");
+
+ String url = "/policy_schemas";
+ String rsp = this.restClient().get(url).block();
+ assertThat(rsp).contains("type1");
+ assertThat(rsp).contains("[{\"title\":\"type2\"}");
+
+ List<String> info = parseSchemas(rsp);
+ assertThat(info.size()).isEqualTo(2);
+
+ url = "/policy_schemas?ric=ric1";
+ rsp = restClient().get(url).block();
+ assertThat(rsp).contains("type1");
+ info = parseSchemas(rsp);
+ assertThat(info.size()).isEqualTo(1);
+
+ // Get schema for non existing RIC
+ url = "/policy_schemas?ric=ric1XXX";
+ testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
+ }
+
+ @Test
+ public void testGetPolicySchema() throws Exception {
+ addPolicyType("type1", "ric1");
+ addPolicyType("type2", "ric2");
+
+ String url = "/policy_schema?id=type1";
+ String rsp = restClient().get(url).block();
+ System.out.println(rsp);
+ assertThat(rsp).contains("type1");
+ assertThat(rsp).contains("title");
+
+ // Get non existing schema
+ url = "/policy_schema?id=type1XX";
+ testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
+ }
+
+ @Test
+ public void testGetPolicyTypes() throws Exception {
+ addPolicyType("type1", "ric1");
+ addPolicyType("type2", "ric2");
+
+ String url = "/policy_types";
+ String rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[\"type2\",\"type1\"]");
+
+ url = "/policy_types?ric=ric1";
+ rsp = restClient().get(url).block();
+ assertThat(rsp).isEqualTo("[\"type1\"]");
+
+ // Get policy types for non existing RIC
+ url = "/policy_types?ric=ric1XXX";
+ testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
+ }
+
+ @Test
+ public void testGetPolicies() throws Exception {
+ reset();