- public void getPolicies() throws Exception {
- String url = "http://localhost:" + port + "/policies";
- addRic(beans.getRics(), "ric1", url);
+ public void testDeletePolicy() throws Exception {
+ reset();
+ String url = baseUrl() + "/policy?instance=id";
+ addPolicy("id", "typeName", "service1", "ric1");
+ assertThat(policies.size()).isEqualTo(1);
+
+ this.restTemplate.delete(url);
+
+ assertThat(policies.size()).isEqualTo(0);
+ }
+
+ public 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 testGetPolicyTypes() throws Exception {
+ String url = baseUrl() + "/policy_types";
+ reset();
+ addPolicy("id1", "type1", "service1");
+ addPolicy("id2", "type2", "service2");
+
+ String rsp = this.restTemplate.getForObject(url, String.class);
+ System.out.println(rsp);
+ assertThat(rsp).contains("type1");
+ assertThat(rsp).contains("type2");
+
+ List<PolicyTypeInfo> info = parseList(rsp, PolicyTypeInfo.class);
+ System.out.println(info.size());
+
+ }
+
+ @Test
+ public void testGetPolicies() throws Exception {
+ String url = baseUrl() + "/policies";