+ public void testDeletePolicy() throws Exception {
+ reset();
+ String url = baseUrl() + "/policy?instance=id";
+ Policy policy = addPolicy("id", "typeName", "service1", "ric1");
+ policy.ric().setState(Ric.RicState.ACTIVE);
+ assertThat(policies.size()).isEqualTo(1);
+
+ this.restTemplate.delete(url);
+
+ assertThat(policies.size()).isEqualTo(0);
+ }
+
+ private static <T> List<T> parseList(String json, Class<T> clazz) {
+ if (null == json) {
+ return null;
+ }
+ return gson.fromJson(json, new TypeToken<T>() {}.getType());
+
+ }
+
+ @Test
+ public void testGetPolicySchemas() throws Exception {
+ reset();
+ addPolicyType("type1", "ric1");
+ addPolicyType("type2", "ric2");
+
+ String url = baseUrl() + "/policy_schemas";
+ String rsp = this.restTemplate.getForObject(url, String.class);
+ System.out.println("*** " + rsp);
+ assertThat(rsp).contains("type1");
+ assertThat(rsp).contains("type2");
+ assertThat(rsp).contains("title");
+
+ List<String> info = parseList(rsp, String.class);
+ assertEquals(2, info.size());
+
+ url = baseUrl() + "/policy_schemas?ric=ric1";
+ rsp = this.restTemplate.getForObject(url, String.class);
+ assertThat(rsp).contains("type1");
+ info = parseList(rsp, String.class);
+ assertEquals(1, info.size());
+ }
+
+ @Test
+ public void testGetPolicySchema() throws Exception {
+ reset();
+ addPolicyType("type1", "ric1");
+ addPolicyType("type2", "ric2");
+
+ String url = baseUrl() + "/policy_schema?id=type1";
+ String rsp = this.restTemplate.getForObject(url, String.class);
+ System.out.println(rsp);
+ assertThat(rsp).contains("type1");
+ assertThat(rsp).contains("title");
+ }
+
+ @Test
+ public void testGetPolicyTypes() throws Exception {
+ reset();
+ addPolicyType("type1", "ric1");
+ addPolicyType("type2", "ric2");
+
+ String url = baseUrl() + "/policy_types";
+ String rsp = this.restTemplate.getForObject(url, String.class);
+ assertThat(rsp).isEqualTo("[\"type2\",\"type1\"]");
+
+ url = baseUrl() + "/policy_types?ric=ric1";
+ rsp = this.restTemplate.getForObject(url, String.class);
+ assertThat(rsp).isEqualTo("[\"type1\"]");
+ }
+
+ @Test
+ public void testGetPolicies() throws Exception {