summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-11-22 16:57:25 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2023-11-27 10:56:53 +0000
commitd2f73c772bc6da457bbee2f5ee127d78e2f9f1f4 (patch)
tree494ce770d71fd2717f871fdb55897ffdc7989944
parent42aa3913332e6e26cdbb327770c837e20ba7adb8 (diff)
Allow semantic versioning in all templates in pap
Issue-ID: POLICY-4887 Change-Id: Iccb46a19c1cb54d8a6b5b7df7294a2d715b2879e Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusProvider.java17
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java4
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/service/ToscaServiceTemplateServiceTest.java9
4 files changed, 24 insertions, 8 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
index 08ec80a4..2cbc15b1 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
@@ -70,6 +70,7 @@ class TestPolicyStatusControllerV1 extends CommonPapRestServer {
void testQueryDeployedPolicies() throws Exception {
checkRequest(POLICY_STATUS_ENDPOINT + "/my-name");
checkRequest(POLICY_STATUS_ENDPOINT + "/my-name/1.2.3");
+ checkRequest(POLICY_STATUS_ENDPOINT + "/my-name/1.2.3+425");
}
@Test
@@ -83,6 +84,7 @@ class TestPolicyStatusControllerV1 extends CommonPapRestServer {
checkRequest(POLICY_DEPLOYMENT_STATUS_ENDPOINT + "/my-group-name");
checkRequest(POLICY_DEPLOYMENT_STATUS_ENDPOINT + "/my-group-name/my-name");
checkRequest(POLICY_DEPLOYMENT_STATUS_ENDPOINT + "/my-group-name/my-name/1.2.3");
+ checkRequest(POLICY_DEPLOYMENT_STATUS_ENDPOINT + "/my-group-name/my-name/1.2.3-2");
}
@Test
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusProvider.java
index 9b809095..0455f3f0 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusProvider.java
@@ -47,14 +47,21 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierO
public class TestPolicyStatusProvider extends ProviderSuper {
private static final String MY_GROUP = "MyGroup";
private static final String MY_PDP_TYPE = "MySubGroup";
- private static final @NonNull String VERSION = "1.2.3";
+ private static final @NonNull String POLICY_TYPE_VERSION = "1.0.3";
+ private static final @NonNull String POLICY_A_VERSION = "1.2.3+1";
+ private static final @NonNull String POLICY_B_VERSION = "1.2.3-1";
+ private static final @NonNull String POLICY_C_VERSION = "1.2.3";
private static final String PDP_A = "pdpA";
private static final String PDP_B = "pdpB";
private static final String PDP_C = "pdpC";
- private static final ToscaConceptIdentifier POLICY_TYPE = new ToscaConceptIdentifier("MyPolicyType", VERSION);
- private static final ToscaConceptIdentifier POLICY_A = new ToscaConceptIdentifier("MyPolicyA", VERSION);
- private static final ToscaConceptIdentifier POLICY_B = new ToscaConceptIdentifier("MyPolicyB", VERSION);
- private static final ToscaConceptIdentifier POLICY_C = new ToscaConceptIdentifier("MyPolicyC", VERSION);
+ private static final ToscaConceptIdentifier POLICY_TYPE =
+ new ToscaConceptIdentifier("MyPolicyType", POLICY_TYPE_VERSION);
+ private static final ToscaConceptIdentifier POLICY_A =
+ new ToscaConceptIdentifier("MyPolicyA", POLICY_A_VERSION);
+ private static final ToscaConceptIdentifier POLICY_B =
+ new ToscaConceptIdentifier("MyPolicyB", POLICY_B_VERSION);
+ private static final ToscaConceptIdentifier POLICY_C =
+ new ToscaConceptIdentifier("MyPolicyC", POLICY_C_VERSION);
private PolicyStatusProvider prov;
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
index eab65a3d..ccd083cc 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
@@ -82,8 +82,8 @@ public class TestPolicyUndeployerImpl extends ProviderSuper {
super.setUp();
- ident1 = new ToscaConceptIdentifier("ident-a", "2.3.1");
- ident2 = new ToscaConceptIdentifier("ident-b", "2.3.2");
+ ident1 = new ToscaConceptIdentifier("ident-a", "2.3.1+1");
+ ident2 = new ToscaConceptIdentifier("ident-b", "2.3.2-1");
ident3 = new ToscaConceptIdentifier("ident-c", "2.3.3");
ident4 = new ToscaConceptIdentifier("ident-d", "2.3.4");
diff --git a/main/src/test/java/org/onap/policy/pap/main/service/ToscaServiceTemplateServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/ToscaServiceTemplateServiceTest.java
index f3716c19..04eacd50 100644
--- a/main/src/test/java/org/onap/policy/pap/main/service/ToscaServiceTemplateServiceTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/service/ToscaServiceTemplateServiceTest.java
@@ -40,6 +40,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
@@ -52,12 +53,14 @@ class ToscaServiceTemplateServiceTest {
private static final String VERSION_1 = "1.0.0";
+ private static final String VERSION_2 = "1.0.0+456";
+ private static final String VERSION_3 = "1.0.0-46";
private static final String VERSION = "version";
private static final String NAME = "name";
private static final String INVALID_VERSION_ERR_MSG =
- "parameter \"version\": value \"version\", does not match regular expression \"^(\\d+.){2}\\d+$\"";
+ "parameter \"version\": value \"version\", does not match regular expression \"" + PfKey.VERSION_REGEXP + "\"";
private static final String NODE_TEMPLATE_NAME = "tca_metadata";
private static final String NODE_TEMPLATE_VERSION = "1.0.0";
@@ -123,6 +126,10 @@ class ToscaServiceTemplateServiceTest {
assertThat(toscaService.getPolicyList(NAME, VERSION_1)).isEmpty();
+ assertThat(toscaService.getPolicyList(NAME, VERSION_2)).isEmpty();
+
+ assertThat(toscaService.getPolicyList(NAME, VERSION_3)).isEmpty();
+
assertThat(toscaService.getPolicyList("onap.restart.tca", VERSION_1)).hasSize(1);
}