summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorChenfei Gao <cgao@research.att.com>2019-05-21 22:43:25 -0400
committerChenfei Gao <cgao@research.att.com>2019-05-21 22:43:33 -0400
commitbbf59429cf462ae417a16afa631c87f495e261df (patch)
tree3566574c04694a7f9f955f7fd8f626a46d8b4df6 /main/src/test
parentf3819951cf22cf93940679964a8c46bd8dfc89cb (diff)
Modify legacy API and policy provider to support version enabled features in legacy db provider
Includes: a) Modify legacy API endpoints to retrieve the latest version of legacy policies b) Modify legacy policy providers to support newly added version enabled features in db provider c) Fix corresponding junit test failures Issue-ID: POLICY-1777 Change-Id: I641170b37e2929b5060414832d4b8395493cecdc Signed-off-by: Chenfei Gao <cgao@research.att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java69
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java71
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java61
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java20
-rw-r--r--main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver1.json15
-rw-r--r--main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver2.json15
6 files changed, 182 insertions, 69 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index 6be91739..ec4640e3 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -107,29 +107,34 @@ public class TestApiRestServer {
private static final String GUARD_POLICIES =
"policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies";
- private static final String GUARD_POLICIES_VDNS_FL =
- "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.frequency.scaleout";
- private static final String GUARD_POLICIES_VDNS_MINMAX =
- "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.minmax.scaleout";
+ private static final String GUARD_POLICIES_VDNS_FL_LATEST =
+ "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.frequency.scaleout"
+ + "/versions/latest";
+ private static final String GUARD_POLICIES_VDNS_MINMAX_LATEST =
+ "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.minmax.scaleout"
+ + "/versions/latest";
private static final String GUARD_POLICIES_VDNS_FL_VERSION = "policytypes/"
- + "onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.frequency.scaleout/versions/1.0.0";
+ + "onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.frequency.scaleout/versions/1";
private static final String GUARD_POLICIES_VDNS_MINMAX_VERSION = "policytypes/"
- + "onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.minmax.scaleout/versions/1.0.0";
+ + "onap.policies.controlloop.Guard/versions/1.0.0/policies/guard.minmax.scaleout/versions/1";
private static final String OPS_POLICIES =
"policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies";
- private static final String OPS_POLICIES_VCPE =
- "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.restart";
- private static final String OPS_POLICIES_VDNS =
- "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.scaleout";
- private static final String OPS_POLICIES_VFIREWALL =
- "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.modifyconfig";
+ private static final String OPS_POLICIES_VCPE_LATEST =
+ "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.restart"
+ + "/versions/latest";
+ private static final String OPS_POLICIES_VDNS_LATEST =
+ "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.scaleout"
+ + "/versions/latest";
+ private static final String OPS_POLICIES_VFIREWALL_LATEST =
+ "policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.modifyconfig"
+ + "/versions/latest";
private static final String OPS_POLICIES_VCPE_VERSION = "policytypes/"
- + "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.restart/versions/1.0.0";
+ + "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.restart/versions/1";
private static final String OPS_POLICIES_VDNS_VERSION = "policytypes/"
- + "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.scaleout/versions/1.0.0";
+ + "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.scaleout/versions/1";
private static final String OPS_POLICIES_VFIREWALL_VERSION = "policytypes/"
- + "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0";
+ + "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.modifyconfig/versions/1";
private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
private Main main;
@@ -469,28 +474,28 @@ public class TestApiRestServer {
assertThatCode(() -> {
main = startApiService(true);
- Response rawResponse = readResource(GUARD_POLICIES_VDNS_FL, true);
+ Response rawResponse = readResource(GUARD_POLICIES_VDNS_FL_LATEST, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: guard.frequency.scaleout",
+ assertEquals("no policy found for policy: guard.frequency.scaleout:null",
error.getErrorMessage());
rawResponse = readResource(GUARD_POLICIES_VDNS_FL_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: guard.frequency.scaleout",
+ assertEquals("no policy found for policy: guard.frequency.scaleout:1",
error.getErrorMessage());
- rawResponse = readResource(GUARD_POLICIES_VDNS_MINMAX, true);
+ rawResponse = readResource(GUARD_POLICIES_VDNS_MINMAX_LATEST, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: guard.minmax.scaleout",
+ assertEquals("no policy found for policy: guard.minmax.scaleout:null",
error.getErrorMessage());
rawResponse = readResource(GUARD_POLICIES_VDNS_MINMAX_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: guard.minmax.scaleout",
+ assertEquals("no policy found for policy: guard.minmax.scaleout:1",
error.getErrorMessage());
}).doesNotThrowAnyException();
}
@@ -500,40 +505,40 @@ public class TestApiRestServer {
assertThatCode(() -> {
main = startApiService(true);
- Response rawResponse = readResource(OPS_POLICIES_VCPE, true);
+ Response rawResponse = readResource(OPS_POLICIES_VCPE_LATEST, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.restart",
+ assertEquals("no policy found for policy: operational.restart:null",
error.getErrorMessage());
rawResponse = readResource(OPS_POLICIES_VCPE_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.restart",
+ assertEquals("no policy found for policy: operational.restart:1",
error.getErrorMessage());
- rawResponse = readResource(OPS_POLICIES_VDNS, true);
+ rawResponse = readResource(OPS_POLICIES_VDNS_LATEST, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.scaleout",
+ assertEquals("no policy found for policy: operational.scaleout:null",
error.getErrorMessage());
rawResponse = readResource(OPS_POLICIES_VDNS_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.scaleout",
+ assertEquals("no policy found for policy: operational.scaleout:1",
error.getErrorMessage());
- rawResponse = readResource(OPS_POLICIES_VFIREWALL, true);
+ rawResponse = readResource(OPS_POLICIES_VFIREWALL_LATEST, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.modifyconfig",
+ assertEquals("no policy found for policy: operational.modifyconfig:null",
error.getErrorMessage());
rawResponse = readResource(OPS_POLICIES_VFIREWALL_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.modifyconfig",
+ assertEquals("no policy found for policy: operational.modifyconfig:1",
error.getErrorMessage());
}).doesNotThrowAnyException();
}
@@ -546,7 +551,7 @@ public class TestApiRestServer {
Response rawResponse = deleteResource(GUARD_POLICIES_VDNS_FL_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: guard.frequency.scaleout",
+ assertEquals("no policy found for policy: guard.frequency.scaleout:1",
error.getErrorMessage());
}).doesNotThrowAnyException();
}
@@ -559,7 +564,7 @@ public class TestApiRestServer {
Response rawResponse = deleteResource(OPS_POLICIES_VCPE_VERSION, true);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("no policy found for policy ID: operational.restart",
+ assertEquals("no policy found for policy: operational.restart:1",
error.getErrorMessage());
}).doesNotThrowAnyException();
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
index fb7c21c7..93144119 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
@@ -58,6 +58,8 @@ public class TestLegacyGuardPolicyProvider {
private static StandardCoder standardCoder;
private static final String POLICY_RESOURCE = "policies/vDNS.policy.guard.frequency.input.json";
+ private static final String POLICY_RESOURCE_VER1 = "policies/vDNS.policy.guard.frequency.input.ver1.json";
+ private static final String POLICY_RESOURCE_VER2 = "policies/vDNS.policy.guard.frequency.input.ver2.json";
private static final String POLICY_TYPE_RESOURCE =
"policytypes/onap.policies.controlloop.guard.FrequencyLimiter.json";
private static final String POLICY_TYPE_ID = "onap.policies.controlloop.guard.FrequencyLimiter:1.0.0";
@@ -103,11 +105,56 @@ public class TestLegacyGuardPolicyProvider {
assertThatThrownBy(() -> {
guardPolicyProvider.fetchGuardPolicy("dummy", null);
- }).hasMessage("no policy found for policy ID: dummy");
+ }).hasMessage("no policy found for policy: dummy:null");
assertThatThrownBy(() -> {
guardPolicyProvider.fetchGuardPolicy("dummy", "dummy");
- }).hasMessage("no policy found for policy ID: dummy");
+ }).hasMessage("legacy policy version is not an integer");
+
+ assertThatCode(() -> {
+ String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+ ToscaServiceTemplate policyTypeServiceTemplate =
+ standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_VER1);
+ LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
+ Map<String, LegacyGuardPolicyOutput> createdPolicy = guardPolicyProvider.createGuardPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+ assertFalse(createdPolicy.isEmpty());
+
+ policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_VER2);
+ policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
+ createdPolicy = guardPolicyProvider.createGuardPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+ assertFalse(createdPolicy.isEmpty());
+
+ Map<String, LegacyGuardPolicyOutput> firstVersion =
+ guardPolicyProvider.fetchGuardPolicy("guard.frequency.scaleout", "1");
+ assertNotNull(firstVersion);
+ assertEquals("1",
+ firstVersion.get("guard.frequency.scaleout").getMetadata().get("policy-version").toString());
+
+ Map<String, LegacyGuardPolicyOutput> latestVersion =
+ guardPolicyProvider.fetchGuardPolicy("guard.frequency.scaleout", null);
+ assertNotNull(latestVersion);
+ assertEquals("2",
+ latestVersion.get("guard.frequency.scaleout").getMetadata().get("policy-version").toString());
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.fetchGuardPolicy("guard.frequency.scaleout", "1.0.0");
+ }).hasMessage("legacy policy version is not an integer");
+
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.fetchGuardPolicy("guard.frequency.scaleout", "latest");
+ }).hasMessage("legacy policy version is not an integer");
+
+ assertThatCode(() -> {
+ guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1");
+ guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "2");
+ policyTypeProvider.deletePolicyType("onap.policies.controlloop.guard.FrequencyLimiter", "1.0.0");
+ }).doesNotThrowAnyException();
}
@Test
@@ -124,9 +171,7 @@ public class TestLegacyGuardPolicyProvider {
ToscaServiceTemplate policyTypeServiceTemplate =
standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
- }).doesNotThrowAnyException();
- assertThatCode(() -> {
String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
Map<String, LegacyGuardPolicyOutput> createdPolicy = guardPolicyProvider.createGuardPolicy(policyToCreate);
@@ -147,42 +192,38 @@ public class TestLegacyGuardPolicyProvider {
}).hasMessage("version is marked @NonNull but is null");
assertThatThrownBy(() -> {
- guardPolicyProvider.deleteGuardPolicy("dummy", "dummy");
- }).hasMessage("no policy found for policy ID: dummy");
+ guardPolicyProvider.deleteGuardPolicy("dummy", "1.0.0");
+ }).hasMessage("legacy policy version is not an integer");
assertThatCode(() -> {
String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
ToscaServiceTemplate policyTypeServiceTemplate =
standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
- }).doesNotThrowAnyException();
- assertThatCode(() -> {
String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
Map<String, LegacyGuardPolicyOutput> createdPolicy = guardPolicyProvider.createGuardPolicy(policyToCreate);
assertNotNull(createdPolicy);
assertFalse(createdPolicy.isEmpty());
- }).doesNotThrowAnyException();
- assertThatCode(() -> {
Map<String, LegacyGuardPolicyOutput> deletedPolicy = guardPolicyProvider
- .deleteGuardPolicy("guard.frequency.scaleout", "1.0.0");
+ .deleteGuardPolicy("guard.frequency.scaleout", "1");
assertNotNull(deletedPolicy);
assertFalse(deletedPolicy.isEmpty());
assertTrue(deletedPolicy.containsKey("guard.frequency.scaleout"));
assertEquals("onap.policies.controlloop.guard.FrequencyLimiter",
deletedPolicy.get("guard.frequency.scaleout").getType());
- assertEquals("1.0.0", deletedPolicy.get("guard.frequency.scaleout").getVersion());
+ assertEquals("1",
+ deletedPolicy.get("guard.frequency.scaleout").getMetadata().get("policy-version").toString());
}).doesNotThrowAnyException();
assertThatThrownBy(() -> {
- guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1.0.0");
- }).hasMessage("no policy found for policy ID: guard.frequency.scaleout");
+ guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1");
+ }).hasMessage("no policy found for policy: guard.frequency.scaleout:1");
assertThatCode(() -> {
policyTypeProvider.deletePolicyType("onap.policies.controlloop.guard.FrequencyLimiter", "1.0.0");
}).doesNotThrowAnyException();
-
}
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
index b5bcbbd6..5eee1e67 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
@@ -98,11 +98,54 @@ public class TestLegacyOperationalPolicyProvider {
assertThatThrownBy(() -> {
operationalPolicyProvider.fetchOperationalPolicy("dummy", null);
- }).hasMessage("no policy found for policy ID: dummy");
+ }).hasMessage("no policy found for policy: dummy:null");
assertThatThrownBy(() -> {
operationalPolicyProvider.fetchOperationalPolicy("dummy", "dummy");
- }).hasMessage("no policy found for policy ID: dummy");
+ }).hasMessage("legacy policy version is not an integer");
+
+ assertThatCode(() -> {
+ String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+ ToscaServiceTemplate policyTypeServiceTemplate =
+ standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
+ LegacyOperationalPolicy createdPolicy = operationalPolicyProvider.createOperationalPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+
+ policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
+ createdPolicy = operationalPolicyProvider.createOperationalPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+
+ LegacyOperationalPolicy firstVersion =
+ operationalPolicyProvider.fetchOperationalPolicy("operational.restart", "1");
+ assertNotNull(firstVersion);
+ assertEquals("1",
+ firstVersion.getPolicyVersion());
+
+ LegacyOperationalPolicy latestVersion =
+ operationalPolicyProvider.fetchOperationalPolicy("operational.restart", null);
+ assertNotNull(latestVersion);
+ assertEquals("2",
+ latestVersion.getPolicyVersion());
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.fetchOperationalPolicy("operational.restart", "1.0.0");
+ }).hasMessage("legacy policy version is not an integer");
+
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.fetchOperationalPolicy("operational.restart", "latest");;
+ }).hasMessage("legacy policy version is not an integer");
+
+ assertThatCode(() -> {
+ operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "1");
+ operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "2");
+ policyTypeProvider.deletePolicyType("onap.policies.controlloop.Operational", "1.0.0");
+ }).doesNotThrowAnyException();
}
@Test
@@ -119,9 +162,7 @@ public class TestLegacyOperationalPolicyProvider {
ToscaServiceTemplate policyTypeServiceTemplate =
standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
- }).doesNotThrowAnyException();
- assertThatCode(() -> {
String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
LegacyOperationalPolicy createdPolicy = operationalPolicyProvider.createOperationalPolicy(policyToCreate);
@@ -141,25 +182,21 @@ public class TestLegacyOperationalPolicyProvider {
assertThatThrownBy(() -> {
operationalPolicyProvider.deleteOperationalPolicy("dummy", "dummy");
- }).hasMessage("no policy found for policy ID: dummy");
+ }).hasMessage("legacy policy version is not an integer");
assertThatCode(() -> {
String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
ToscaServiceTemplate policyTypeServiceTemplate =
standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
- }).doesNotThrowAnyException();
- assertThatCode(() -> {
String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
LegacyOperationalPolicy createdPolicy = operationalPolicyProvider.createOperationalPolicy(policyToCreate);
assertNotNull(createdPolicy);
- }).doesNotThrowAnyException();
- assertThatCode(() -> {
LegacyOperationalPolicy deletedPolicy = operationalPolicyProvider
- .deleteOperationalPolicy("operational.restart", "1.0.0");
+ .deleteOperationalPolicy("operational.restart", "1");
assertNotNull(deletedPolicy);
assertEquals("operational.restart", deletedPolicy.getPolicyId());
assertTrue(deletedPolicy.getContent()
@@ -167,8 +204,8 @@ public class TestLegacyOperationalPolicyProvider {
}).doesNotThrowAnyException();
assertThatThrownBy(() -> {
- operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "1.0.0");
- }).hasMessage("no policy found for policy ID: operational.restart");
+ operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "1");
+ }).hasMessage("no policy found for policy: operational.restart:1");
assertThatCode(() -> {
policyTypeProvider.deletePolicyType("onap.policies.controlloop.Operational", "1.0.0");
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index 8b1be3d5..947221a7 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -95,16 +95,16 @@ public class TestPolicyProvider {
public void testFetchPolicies() {
assertThatThrownBy(() -> {
- policyProvider.fetchPolicies("dummy", "dummy", null, null);
- }).hasMessage("policy with ID null:null and type dummy:dummy does not exist");
+ policyProvider.fetchPolicies("dummy", "1.0.0", null, null);
+ }).hasMessage("policy with ID null:null and type dummy:1.0.0 does not exist");
assertThatThrownBy(() -> {
- policyProvider.fetchPolicies("dummy", "dummy", "dummy", null);
- }).hasMessage("policy with ID dummy:null and type dummy:dummy does not exist");
+ policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", null);
+ }).hasMessage("policy with ID dummy:null and type dummy:1.0.0 does not exist");
assertThatThrownBy(() -> {
- policyProvider.fetchPolicies("dummy", "dummy", "dummy", "dummy");
- }).hasMessage("policy with ID dummy:dummy and type dummy:dummy does not exist");
+ policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0");
+ }).hasMessage("policy with ID dummy:1.0.0 and type dummy:1.0.0 does not exist");
}
@Test
@@ -127,8 +127,8 @@ public class TestPolicyProvider {
public void testCreatePolicy() {
assertThatThrownBy(() -> {
- policyProvider.createPolicy("dummy", "dummy", new ToscaServiceTemplate());
- }).hasMessage("policy type with ID dummy:dummy does not exist");
+ policyProvider.createPolicy("dummy", "1.0.0", new ToscaServiceTemplate());
+ }).hasMessage("policy type with ID dummy:1.0.0 does not exist");
assertThatCode(() -> {
String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
@@ -167,8 +167,8 @@ public class TestPolicyProvider {
public void testDeletePolicy() {
assertThatThrownBy(() -> {
- policyProvider.deletePolicy("dummy", "dummy", "dummy", "dummy");
- }).hasMessage("policy with ID dummy:dummy and type dummy:dummy does not exist");
+ policyProvider.deletePolicy("dummy", "1.0.0", "dummy", "1.0.0");
+ }).hasMessage("policy with ID dummy:1.0.0 and type dummy:1.0.0 does not exist");
assertThatCode(() -> {
String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
diff --git a/main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver1.json b/main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver1.json
new file mode 100644
index 00000000..6dc54cb8
--- /dev/null
+++ b/main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver1.json
@@ -0,0 +1,15 @@
+{
+ "policy-id" : "guard.frequency.scaleout",
+ "policy-version" : "1",
+ "content" : {
+ "actor": "SO",
+ "recipe": "scaleOut",
+ "targets": ".*",
+ "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+ "limit": "1",
+ "timeWindow": "10",
+ "timeUnits": "minute",
+ "guardActiveStart": "00:00:01-05:00",
+ "guardActiveEnd": "23:59:59-05:00"
+ }
+}
diff --git a/main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver2.json b/main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver2.json
new file mode 100644
index 00000000..a8c325fb
--- /dev/null
+++ b/main/src/test/resources/policies/vDNS.policy.guard.frequency.input.ver2.json
@@ -0,0 +1,15 @@
+{
+ "policy-id" : "guard.frequency.scaleout",
+ "policy-version" : "2",
+ "content" : {
+ "actor": "SO",
+ "recipe": "scaleOut",
+ "targets": ".*",
+ "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+ "limit": "1",
+ "timeWindow": "10",
+ "timeUnits": "minute",
+ "guardActiveStart": "00:00:01-05:00",
+ "guardActiveEnd": "23:59:59-05:00"
+ }
+}