Allow semantic versioning in all templates in pap 53/136653/1
authorFrancescoFioraEst <francesco.fiora@est.tech>
Wed, 22 Nov 2023 16:57:25 +0000 (16:57 +0000)
committerFrancesco Fiora <francesco.fiora@est.tech>
Mon, 27 Nov 2023 10:56:53 +0000 (10:56 +0000)
Issue-ID: POLICY-4887
Change-Id: Iccb46a19c1cb54d8a6b5b7df7294a2d715b2879e
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusProvider.java
main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyUndeployerImpl.java
main/src/test/java/org/onap/policy/pap/main/service/ToscaServiceTemplateServiceTest.java

index 08ec80a..2cbc15b 100644 (file)
@@ -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
index 9b80909..0455f3f 100644 (file)
@@ -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;
 
index eab65a3..ccd083c 100644 (file)
@@ -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");
 
index f3716c1..04eacd5 100644 (file)
@@ -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);
     }