diff options
author | liamfallon <liam.fallon@est.tech> | 2020-05-06 17:02:23 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2020-05-06 17:02:27 +0100 |
commit | f4ca53652d2db9624e1f267bee5b511600ff0e5d (patch) | |
tree | f74d5536f3bd8235b8d637c16ba5ce155a1e9fb0 /main/src/test | |
parent | d4f82c0db1d9686861792c6785a42acbd8c5dc6c (diff) |
Make type and type_version mandatory on policies
Up until now, the "type" and "type_version" fields defaulted to "NULL"
and "0.0.0" respectively when they were not specified because the
"type_version" field was not always specified on policies in previous
releases. In cases where the "type_version" field was not specified, it
was assumend that a "0.0.0" version of the policy type existed. In
parallel, if the version field was not specified on the policy type, the
version was stored as 0.0.0.
This behaviour is now changed and the "type" and "type_version" fields
are now always mandatory.
Issue-ID: POLICY-2538
Change-Id: Ieec97f4a111edd13dbe31116c7549f07c19ef0aa
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main/src/test')
-rw-r--r-- | main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java | 7 | ||||
-rw-r--r-- | main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java | 5 |
2 files changed, 7 insertions, 5 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 a3cd8d62..6674026c 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 @@ -317,7 +317,7 @@ public class TestApiRestServer { String toscaPolicy = ResourceUtils.getResourceAsString(TOSCA_POLICY_RESOURCE_NAMES[TOSCA_POLICIES_RESOURCE_NAMES.length - 1]); - toscaPolicy = toscaPolicy.replaceAll("onap.policies.monitoring.cdap.tca.hi.lo.app", ""); + toscaPolicy = toscaPolicy.replaceAll("onap.policies.monitoring.cdap.tca.hi.lo.app", "IDontExist"); TextFileUtils.putStringAsTextFile(toscaPolicy, "src/test/resources/policies/BadTestPolicy.yaml"); Response rawResponse2 = @@ -341,13 +341,14 @@ public class TestApiRestServer { String toscaPolicy = ResourceUtils.getResourceAsString(TOSCA_POLICY_RESOURCE_NAMES[TOSCA_POLICIES_RESOURCE_NAMES.length - 1]); - toscaPolicy = toscaPolicy.replaceAll("onap.policies.monitoring.cdap.tca.hi.lo.app", ""); + toscaPolicy = toscaPolicy.replaceAll("onap.policies.monitoring.cdap.tca.hi.lo.app", "IDontExist"); TextFileUtils.putStringAsTextFile(toscaPolicy, "src/test/resources/policies/BadTestPolicy.yaml"); Response rawResponse2 = createResource(POLICIES, "src/test/resources/policies/BadTestPolicy.yaml"); ErrorResponse errorResponse = rawResponse2.readEntity(ErrorResponse.class); assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), rawResponse2.getStatus()); - assertThat(errorResponse.getErrorMessage()).contains("policy type NULL:1.0.0 referenced in policy not found"); + assertThat(errorResponse.getErrorMessage()) + .contains("policy type IDontExist:1.0.0 referenced in policy not found"); } @Test 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 63542420..0fcedbeb 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 @@ -246,8 +246,9 @@ public class TestPolicyProvider { standardCoder.decode(badPolicyString, ToscaServiceTemplate.class); policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", badPolicyServiceTemplate); - }).hasMessageContaining( - "policy type onap.policies.monitoring.cdap.tca.hi.lo.appxxx:0.0.0 referenced in policy not found"); + }).hasMessage( + "PolicyType version not specified, the version of the PolicyType for this policy must be specified in the " + + "type_version field"); assertThatThrownBy(() -> { String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_BAD_POLICYTYPE_VERSION); |