* ONAP Policy API
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.api.main.rest.provider;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+
 import javax.ws.rs.core.Response;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Class to provide all kinds of legacy guard policy operations.
  */
 public class LegacyGuardPolicyProvider extends CommonModelProvider {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(LegacyGuardPolicyProvider.class);
-
-    private static final String INVALID_POLICY_VERSION = "legacy policy version is not an integer";
-    private static final String LEGACY_MINOR_PATCH_SUFFIX = ".0.0";
     private static final Map<String, PfConceptKey> GUARD_POLICY_TYPE_MAP = new LinkedHashMap<>();
 
     static {
         GUARD_POLICY_TYPE_MAP.put("guard.frequency.",
                 new PfConceptKey("onap.policies.controlloop.guard.FrequencyLimiter:1.0.0"));
-        GUARD_POLICY_TYPE_MAP.put("guard.minmax.",
-                new PfConceptKey("onap.policies.controlloop.guard.MinMax:1.0.0"));
+        GUARD_POLICY_TYPE_MAP.put("guard.minmax.", new PfConceptKey("onap.policies.controlloop.guard.MinMax:1.0.0"));
         GUARD_POLICY_TYPE_MAP.put("guard.blacklist.",
                 new PfConceptKey("onap.policies.controlloop.guard.Blacklist:1.0.0"));
     }
     public Map<String, LegacyGuardPolicyOutput> fetchGuardPolicy(String policyId, String policyVersion)
             throws PfModelException {
 
-        if (policyVersion != null) {
-            validNumber(policyVersion, INVALID_POLICY_VERSION);
-        }
         return modelsProvider.getGuardPolicy(policyId, policyVersion);
     }
 
     public Map<Pair<String, String>, Map<String, LegacyGuardPolicyOutput>> fetchDeployedGuardPolicies(String policyId)
             throws PfModelException {
 
-        return collectDeployedPolicies(
-                policyId, getGuardPolicyType(policyId), modelsProvider::getGuardPolicy, Map::putAll, new HashMap<>());
+        return collectDeployedPolicies(policyId, getGuardPolicyType(policyId), modelsProvider::getGuardPolicy,
+                Map::putAll, new HashMap<>());
     }
 
     /**
      *
      * @return the map of LegacyGuardPolicyOutput objectst
      */
-    public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(LegacyGuardPolicyInput body)
-            throws PfModelException {
+    public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(LegacyGuardPolicyInput body) throws PfModelException {
 
-        validateGuardPolicyVersion(body);
         return modelsProvider.createGuardPolicy(body);
     }
 
     public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(String policyId, String policyVersion)
             throws PfModelException {
 
-        validNumber(policyVersion, INVALID_POLICY_VERSION);
-        validateDeleteEligibility(policyId, policyVersion);
-
         return modelsProvider.deleteGuardPolicy(policyId, policyVersion);
     }
 
-    /**
-     * Validates whether specified policy can be deleted based on the rule that deployed policy cannot be deleted.
-     *
-     * @param policyId the ID of policy
-     * @param policyVersion the version of policy
-     *
-     * @throws PfModelException the PfModel parsing exception
-     */
-    private void validateDeleteEligibility(String policyId, String policyVersion) throws PfModelException {
-
-        List<ToscaPolicyIdentifier> policies = new ArrayList<>();
-        policies.add(new ToscaPolicyIdentifier(policyId, policyVersion + LEGACY_MINOR_PATCH_SUFFIX));
-        PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyList(policies).build();
-
-        List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
-
-        if (!pdpGroups.isEmpty()) {
-            throw new PfModelException(Response.Status.CONFLICT,
-                    constructDeletePolicyViolationMessage(policyId, policyVersion, pdpGroups));
-        }
-    }
-
-    /**
-     * Validates the provided guard policy version in the payload.
-     *
-     * @param body the guard policy payload
-     *
-     * @throws PfModelException the PfModel parsing exception
-     */
-    private void validateGuardPolicyVersion(LegacyGuardPolicyInput body) throws PfModelException {
-
-        validateGuardPolicyVersionExist(body);
-        validateNoDuplicateVersionInDb(body);
-    }
-
-    /**
-     * Validates that the guard policy has version specified.
-     *
-     * @param body the guard policy payload
-     *
-     * @throws PfModelException the PfModel parsing exception
-     */
-    private void validateGuardPolicyVersionExist(LegacyGuardPolicyInput body) throws PfModelException {
-
-        if (body.getPolicyVersion() == null) {
-            String errMsg = "mandatory field 'policy-version' is missing in the policy: " + body.getPolicyId();
-            throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errMsg);
-        }
-    }
-
-    /**
-     * Validates that there is no duplicate version already stored in the database.
-     *
-     * @param body the guard policy payload
-     *
-     * @throws PfModelException the PfModel parsing exception
-     */
-    private void validateNoDuplicateVersionInDb(LegacyGuardPolicyInput body) throws PfModelException {
-
-        try {
-            modelsProvider.getGuardPolicy(body.getPolicyId(), body.getPolicyVersion());
-        } catch (PfModelRuntimeException exc) {
-            if (!hasSameGuardPolicyFound(body, exc)) {
-                return;
-            }
-            throw new PfModelException(exc.getErrorResponse().getResponseCode(), "unexpected runtime error", exc);
-        }
-
-        // If it gets here, there is one duplicate version stored in the DB.
-        // Try to get the latest version and return it to the user.
-        Map<String, LegacyGuardPolicyOutput> latest = modelsProvider.getGuardPolicy(body.getPolicyId(), null);
-        final String[] versionArray = latest.values().iterator().next().getVersion().split("\\.");
-        String errMsg = "guard policy " + body.getPolicyId() + ":" + body.getPolicyVersion()
-            + " already exists; its latest version is " + versionArray[0];
-        throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errMsg);
-    }
-
-    /**
-     * Checks if the same guard policy found in the database.
-     *
-     * @param body the legacy guard policy payload
-     * @param exc the thrown runtime exception from policy model provider
-     *
-     * @return a boolean flag indicating the check result
-     */
-    private boolean hasSameGuardPolicyFound(LegacyGuardPolicyInput body, PfModelRuntimeException exc) {
-
-        if (exc.getErrorResponse().getResponseCode() == Response.Status.BAD_REQUEST
-                && exc.getErrorResponse().getErrorMessage().contains("no policy found")) {
-            LOGGER.debug("no duplicate policy {}:{} found in the DB", body.getPolicyId(), body.getPolicyVersion());
-            return false;
-        }
-        return true;
-    }
-
     /**
      * Retrieves guard policy type given guard policy ID.
      *
 
  * ONAP Policy API
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import javax.ws.rs.core.Response;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Class to provide all kinds of legacy operational policy operations.
  */
 public class LegacyOperationalPolicyProvider extends CommonModelProvider {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicyProvider.class);
-
-    private static final String INVALID_POLICY_VERSION = "legacy policy version is not an integer";
-    private static final String LEGACY_MINOR_PATCH_SUFFIX = ".0.0";
     private static final PfConceptKey LEGACY_OPERATIONAL_TYPE =
             new PfConceptKey("onap.policies.controlloop.Operational", "1.0.0");
 
     public LegacyOperationalPolicy fetchOperationalPolicy(String policyId, String policyVersion)
             throws PfModelException {
 
-        if (policyVersion != null) {
-            validNumber(policyVersion, INVALID_POLICY_VERSION);
-        }
         return modelsProvider.getOperationalPolicy(policyId, policyVersion);
     }
 
     public Map<Pair<String, String>, List<LegacyOperationalPolicy>> fetchDeployedOperationalPolicies(String policyId)
             throws PfModelException {
 
-        return collectDeployedPolicies(
-                policyId, LEGACY_OPERATIONAL_TYPE, modelsProvider::getOperationalPolicy, List::add, new ArrayList<>(5));
+        return collectDeployedPolicies(policyId, LEGACY_OPERATIONAL_TYPE, modelsProvider::getOperationalPolicy,
+                List::add, new ArrayList<>(5));
     }
 
     /**
      */
     public LegacyOperationalPolicy createOperationalPolicy(LegacyOperationalPolicy body) throws PfModelException {
 
-        validateOperationalPolicyVersion(body);
         return modelsProvider.createOperationalPolicy(body);
     }
 
     public LegacyOperationalPolicy deleteOperationalPolicy(String policyId, String policyVersion)
             throws PfModelException {
 
-        validNumber(policyVersion, INVALID_POLICY_VERSION);
-        validateDeleteEligibility(policyId, policyVersion);
-
         return modelsProvider.deleteOperationalPolicy(policyId, policyVersion);
     }
-
-    /**
-     * Validates whether specified policy can be deleted based on the rule that deployed policy cannot be deleted.
-     *
-     * @param policyId the ID of policy
-     * @param policyVersion the version of policy
-     *
-     * @throws PfModelException the PfModel parsing exception
-     */
-    private void validateDeleteEligibility(String policyId, String policyVersion) throws PfModelException {
-
-        List<ToscaPolicyIdentifier> policies = new ArrayList<>(5);
-        policies.add(new ToscaPolicyIdentifier(policyId, policyVersion + LEGACY_MINOR_PATCH_SUFFIX));
-        PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyList(policies).build();
-
-        List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
-
-        if (!pdpGroups.isEmpty()) {
-            throw new PfModelException(Response.Status.CONFLICT,
-                    constructDeletePolicyViolationMessage(policyId, policyVersion, pdpGroups));
-        }
-    }
-
-    /**
-     * Validates the specified version of the operational policy provided in the payload.
-     *
-     * @param body the operational policy payload
-     *
-     * @throws PfModelException on errors parsing PfModel
-     */
-    private void validateOperationalPolicyVersion(LegacyOperationalPolicy body) throws PfModelException {
-
-        validateOperationalPolicyVersionExist(body);
-        validateNoDuplicateVersionInDb(body);
-    }
-
-    /**
-     * Validates whether the version of the operational policy is specified in the payload.
-     *
-     * @param body the operational policy payload
-     *
-     * @throws PfModelException on errors parsing PfModel
-     */
-    private void validateOperationalPolicyVersionExist(LegacyOperationalPolicy body) throws PfModelException {
-
-        if (body.getPolicyVersion() == null) {
-            String errMsg = "mandatory field 'policy-version' is missing in the policy: " + body.getPolicyId();
-            throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errMsg);
-        }
-    }
-
-    /**
-     * Validates that there is no duplicate version of the operational policy which is already stored in the database.
-     *
-     * @param body the operational policy payload
-     *
-     * @throws PfModelException on errors parsing PfModel
-     */
-    private void validateNoDuplicateVersionInDb(LegacyOperationalPolicy body) throws PfModelException {
-
-        try {
-            modelsProvider.getOperationalPolicy(body.getPolicyId(), body.getPolicyVersion());
-        } catch (PfModelRuntimeException exc) {
-            if (!hasSameOperationalPolicyFound(body, exc)) {
-                return;
-            }
-            throw new PfModelException(exc.getErrorResponse().getResponseCode(), "unexpected runtime error", exc);
-        }
-
-        // There is one duplicate version stored in the DB.
-        // Try to get the latest version
-        LegacyOperationalPolicy latest = modelsProvider.getOperationalPolicy(body.getPolicyId(), null);
-        final String[] versionArray = latest.getPolicyVersion().split("\\.");
-        String errMsg = "operational policy " + body.getPolicyId() + ":" + body.getPolicyVersion()
-            + " already exists; its latest version is " + versionArray[0];
-        throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errMsg);
-    }
-
-    /**
-     * Checks if the same operational policy found in the database.
-     *
-     * @param body the legacy operational policy payload
-     * @param exc the runtime exception thrown by policy model provider
-     *
-     * @return a boolean flag indicating the check result
-     */
-    private boolean hasSameOperationalPolicyFound(LegacyOperationalPolicy body, PfModelRuntimeException exc) {
-
-        if (exc.getErrorResponse().getResponseCode() == Response.Status.BAD_REQUEST
-                && exc.getErrorResponse().getErrorMessage().contains("no policy found")) {
-            LOGGER.debug("no duplicate policy {}:{} found in the DB", body.getPolicyId(), body.getPolicyVersion());
-            return false;
-        }
-        return true;
-    }
 }
\ No newline at end of file
 
 import org.apache.commons.lang3.tuple.Pair;\r
 import org.onap.policy.models.base.PfConceptKey;\r
 import org.onap.policy.models.base.PfModelException;\r
-import org.onap.policy.models.pdp.concepts.PdpGroup;\r
-import org.onap.policy.models.pdp.concepts.PdpGroupFilter;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
 \r
 /**\r
     public ToscaServiceTemplate deletePolicy(String policyTypeId, String policyTypeVersion, String policyId,\r
             String policyVersion) throws PfModelException {\r
 \r
-        validateDeleteEligibility(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
-\r
         ToscaServiceTemplate serviceTemplate = modelsProvider.deletePolicy(policyId, policyVersion);\r
 \r
         if (!hasPolicy(serviceTemplate)) {\r
         return serviceTemplate;\r
     }\r
 \r
-    /**\r
-     * Validates whether specified policy can be deleted based on the rule that deployed policy cannot be deleted.\r
-     *\r
-     * @param policyTypeId the ID of policy type\r
-     * @param policyTypeVersion the version of policy type\r
-     * @param policyId the ID of policy\r
-     * @param policyVersion the version of policy\r
-     *\r
-     * @throws PfModelException the PfModel parsing exception\r
-     */\r
-    private void validateDeleteEligibility(String policyTypeId, String policyTypeVersion, String policyId,\r
-            String policyVersion) throws PfModelException {\r
-\r
-        // TODO: Remove this method when delete validation is implemented in the tosca provider\r
-        List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>(1);\r
-        policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion));\r
-        List<ToscaPolicyIdentifier> policies = new ArrayList<>(1);\r
-        policies.add(new ToscaPolicyIdentifier(policyId, policyVersion));\r
-        PdpGroupFilter pdpGroupFilter =\r
-                PdpGroupFilter.builder().policyTypeList(policyTypes).policyList(policies).build();\r
-\r
-        List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);\r
-\r
-        if (!pdpGroups.isEmpty()) {\r
-            throw new PfModelException(Response.Status.CONFLICT,\r
-                    constructDeletePolicyViolationMessage(policyId, policyVersion, pdpGroups));\r
-        }\r
-    }\r
-\r
     /**\r
      * Retrieves the specified version of the policy.\r
      *\r
 
 \r
 package org.onap.policy.api.main.rest.provider;\r
 \r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map.Entry;\r
-\r
 import javax.ws.rs.core.Response;\r
 \r
 import org.onap.policy.models.base.PfModelException;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
 \r
             throw new PfModelException(Response.Status.BAD_REQUEST,\r
                     "no policy types specified in the service template");\r
         }\r
-        validatePolicyTypeVersionExist(body);\r
+\r
         return modelsProvider.createPolicyTypes(body);\r
     }\r
 \r
     public ToscaServiceTemplate deletePolicyType(String policyTypeId, String policyTypeVersion)\r
             throws PfModelException {\r
 \r
-        validateDeleteEligibility(policyTypeId, policyTypeVersion);\r
-\r
         ToscaServiceTemplate serviceTemplate = modelsProvider.deletePolicyType(policyTypeId, policyTypeVersion);\r
 \r
         if (!hasPolicyType(serviceTemplate)) {\r
         return serviceTemplate;\r
     }\r
 \r
-    /**\r
-     * Validates whether specified policy type can be deleted based on the rule that policy type parameterized by at\r
-     * least one policies cannot be deleted.\r
-     *\r
-     * @param policyTypeId the ID of policy type\r
-     * @param policyTypeVersion the version of policy type\r
-     *\r
-     * @throws PfModelException the PfModel parsing exception\r
-     */\r
-    private void validateDeleteEligibility(String policyTypeId, String policyTypeVersion) throws PfModelException {\r
-\r
-        ToscaPolicyFilter policyFilter =\r
-                ToscaPolicyFilter.builder().type(policyTypeId).typeVersion(policyTypeVersion).build();\r
-        List<ToscaPolicy> policies = modelsProvider.getFilteredPolicyList(policyFilter);\r
-        if (!policies.isEmpty()) {\r
-            throw new PfModelException(Response.Status.CONFLICT,\r
-                    constructDeletePolicyTypeViolationMessage(policyTypeId, policyTypeVersion, policies));\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Validates that each policy type has a version specified in the payload.\r
-     *\r
-     * @param body the TOSCA service template payload to check against\r
-     *\r
-     * @throws PfModelException the PfModel parsing exception\r
-     */\r
-    private void validatePolicyTypeVersionExist(ToscaServiceTemplate body) throws PfModelException {\r
-\r
-        List<String> invalidPolicyTypeNames = new ArrayList<>();\r
-        for (Entry<String, ToscaPolicyType> policyType : body.getPolicyTypes().entrySet()) {\r
-            if (!"tosca.policies.Root".equals(policyType.getValue().getDerivedFrom())\r
-                    && policyType.getValue().getVersion() == null) {\r
-                invalidPolicyTypeNames.add(policyType.getKey());\r
-            }\r
-        }\r
-\r
-        if (!invalidPolicyTypeNames.isEmpty()) {\r
-            String errorMsg = "mandatory 'version' field is missing in policy types: "\r
-                    + String.join(", ", invalidPolicyTypeNames);\r
-            throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errorMsg);\r
-        }\r
-    }\r
-\r
     /**\r
      * Retrieves the specified version of the policy type.\r
      *\r
 
         Response rawResponse = deleteResource(POLICYTYPES_TCA_POLICIES_VCPE_VERSION1, mediaType);
         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
         ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
-        assertEquals("policies for onap.restart.tca:1.0.0 do not exist", error.getErrorMessage());
+        assertEquals("no policies found", error.getErrorMessage());
     }
 
     @Test
 
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyContent;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
 
 
         assertThatThrownBy(() -> {
             guardPolicyProvider.fetchGuardPolicy("dummy", "dummy");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"dummy.0.0\", does not match regular expression");
 
         assertThatCode(() -> {
             ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
 
         assertThatThrownBy(() -> {
             guardPolicyProvider.fetchGuardPolicy("guard.frequency.scaleout", "1.0.0");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"1.0.0.0.0\", does not match regular expression");
 
         assertThatThrownBy(() -> {
             guardPolicyProvider.fetchGuardPolicy("guard.frequency.scaleout", "latest");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"latest.0.0\", does not match regular expression");
 
         assertThatCode(() -> {
             guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1");
             // Test validateDeleteEligibility exception path(!pdpGroups.isEmpty())
             assertThatThrownBy(() -> {
                 guardPolicyProvider.deleteGuardPolicy(POLICY_NAME, POLICY_VERSION);
-            }).hasMessageContaining("policy with ID " + POLICY_NAME + ":" + POLICY_VERSION
-                    + " cannot be deleted as it is deployed in pdp groups");
+            }).hasMessageContaining("policy is in use, it is deployed in PDP group group subgroup type");
         } catch (Exception exc) {
             fail("Test should not throw an exception");
         }
                 createdPolicy.get("guard.frequency.scaleout").getType());
         assertEquals("1.0.0", createdPolicy.get("guard.frequency.scaleout").getVersion());
 
-        assertThatThrownBy(() -> {
-            String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_NO_VERSION);
-            LegacyGuardPolicyInput badPolicyToCreate =
-                    standardCoder.decode(badPolicyString, LegacyGuardPolicyInput.class);
-            guardPolicyProvider.createGuardPolicy(badPolicyToCreate);
-        }).hasMessage("mandatory field 'policy-version' is missing in the policy: guard.frequency.scaleout");
+        String defaultPolicyVersionString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_NO_VERSION);
+        LegacyGuardPolicyInput defaultVersionPolicy =
+                standardCoder.decode(defaultPolicyVersionString, LegacyGuardPolicyInput.class);
+        createdPolicy = guardPolicyProvider.createGuardPolicy(defaultVersionPolicy);
+        assertEquals("1.0.0", createdPolicy.get("guard.frequency.scaleout.noversion").getVersion());
+
+        assertThatCode(() -> {
+            String duplicatePolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+            LegacyGuardPolicyInput duplicatePolicyToCreate =
+                    standardCoder.decode(duplicatePolicyString, LegacyGuardPolicyInput.class);
+            guardPolicyProvider.createGuardPolicy(duplicatePolicyToCreate);
+        }).doesNotThrowAnyException();
 
         assertThatThrownBy(() -> {
             String duplicatePolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             LegacyGuardPolicyInput duplicatePolicyToCreate =
                     standardCoder.decode(duplicatePolicyString, LegacyGuardPolicyInput.class);
+            duplicatePolicyToCreate.setContent(new LegacyGuardPolicyContent());
             guardPolicyProvider.createGuardPolicy(duplicatePolicyToCreate);
-        }).hasMessage("guard policy guard.frequency.scaleout:1 already exists; its latest version is 1");
+        }).hasMessageContaining("INVALID:entity in incoming fragment does not equal existing entity");
     }
 
     @Test
                     databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size());
             assertThatThrownBy(() -> {
                 guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1");
-            }).hasMessageContaining("cannot be deleted as it is deployed in pdp groups");
+            }).hasMessageContaining("policy is in use, it is deployed in PDP group group subgroup type");
         } catch (Exception exc) {
             fail("Test should not throw an exception");
         }
     public void testDeleteGuardPolicy() {
         assertThatThrownBy(() -> {
             guardPolicyProvider.deleteGuardPolicy("dummy", null);
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
 
         assertThatThrownBy(() -> {
             guardPolicyProvider.deleteGuardPolicy("dummy", "1.0.0");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"1.0.0.0.0\", does not match regular expression");
 
         assertThatCode(() -> {
             ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
 
 
         assertThatThrownBy(() -> {
             operationalPolicyProvider.fetchOperationalPolicy("dummy", "dummy");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"dummy.0.0\", does not match regular expression");
 
         ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
                 .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
 
         assertThatThrownBy(() -> {
             operationalPolicyProvider.fetchOperationalPolicy("operational.restart", "1.0.0");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"1.0.0.0.0\", does not match regular expression");
 
         assertThatThrownBy(() -> {
             operationalPolicyProvider.fetchOperationalPolicy("operational.restart", "latest");
             ;
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"latest.0.0\", does not match regular expression");
 
         operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "1");
         policyTypeProvider.deletePolicyType("onap.policies.controlloop.Operational", "1.0.0");
             // Test validateDeleteEligibility exception path(!pdpGroups.isEmpty())
             assertThatThrownBy(() -> {
                 operationalPolicyProvider.deleteOperationalPolicy(POLICY_NAME, POLICY_VERSION);
-            }).hasMessageContaining("policy with ID " + POLICY_NAME + ":" + POLICY_VERSION
-                    + " cannot be deleted as it is deployed in pdp groups");
+            }).hasMessageContaining("policy is in use, it is deployed in PDP group group subgroup type");
         } catch (Exception exc) {
             fail("Test should not throw an exception");
         }
         assertEquals("operational.restart", createdPolicy.getPolicyId());
         assertTrue(createdPolicy.getContent().startsWith("controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20"));
 
-        assertThatThrownBy(() -> {
-            String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_NO_VERSION);
-            LegacyOperationalPolicy badPolicyToCreate =
-                    standardCoder.decode(badPolicyString, LegacyOperationalPolicy.class);
-            operationalPolicyProvider.createOperationalPolicy(badPolicyToCreate);
-        }).hasMessage("mandatory field 'policy-version' is missing in the policy: operational.scaleout");
+        String defaultPolicyVersionString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_NO_VERSION);
+        LegacyOperationalPolicy defaultPolicyVersionPolicy =
+                standardCoder.decode(defaultPolicyVersionString, LegacyOperationalPolicy.class);
+        createdPolicy = operationalPolicyProvider.createOperationalPolicy(defaultPolicyVersionPolicy);
+        assertEquals("1", createdPolicy.getPolicyVersion());
+
+        assertThatCode(() -> {
+            String duplicatePolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+            LegacyOperationalPolicy duplicatePolicyToCreate =
+                    standardCoder.decode(duplicatePolicyString, LegacyOperationalPolicy.class);
+            operationalPolicyProvider.createOperationalPolicy(duplicatePolicyToCreate);
+        }).doesNotThrowAnyException();
 
         assertThatThrownBy(() -> {
             String duplicatePolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             LegacyOperationalPolicy duplicatePolicyToCreate =
                     standardCoder.decode(duplicatePolicyString, LegacyOperationalPolicy.class);
+            duplicatePolicyToCreate.setContent("some other content");
             operationalPolicyProvider.createOperationalPolicy(duplicatePolicyToCreate);
-        }).hasMessage("operational policy operational.restart:1 already exists; its latest version is 1");
+        }).hasMessageContaining("INVALID:entity in incoming fragment does not equal existing entity");
     }
 
     @Test
                     databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size());
             assertThatThrownBy(() -> {
                 operationalPolicyProvider.deleteOperationalPolicy(policyId, policyVersion);
-            }).hasMessageContaining("cannot be deleted as it is deployed in pdp groups");
+            }).hasMessageContaining("policy is in use, it is deployed in PDP group group subgroup type");
         } catch (Exception exc) {
             fail("Test should not throw an exception");
         }
 
         assertThatThrownBy(() -> {
             operationalPolicyProvider.deleteOperationalPolicy("dummy", null);
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
 
         assertThatThrownBy(() -> {
             operationalPolicyProvider.deleteOperationalPolicy("dummy", "dummy");
-        }).hasMessage("legacy policy version is not an integer");
+        }).hasMessageContaining("parameter \"version\": value \"dummy.0.0\", does not match regular expression");
 
         assertThatCode(() -> {
             ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
 
             assertThatThrownBy(() -> {
                 policyProvider.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca",
                         "1.0.0");
-            }).hasMessageContaining("policy with ID " + policyId + ":" + policyVersion
-                    + " cannot be deleted as it is deployed in pdp groups");
+            }).hasMessageContaining("policy is in use, it is deployed in PDP group group subgroup type");
         } catch (Exception exc) {
             fail("Test should not throw an exception");
         }
         assertThatThrownBy(() -> {
             policyProvider.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca",
                     "1.0.0");
-        }).hasMessageContaining("policies for onap.restart.tca:1.0.0 do not exist");
+        }).hasMessageContaining("no policies found");
     }
 }
 
                     standardYamlCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_WITH_NO_VERSION),
                             ToscaServiceTemplate.class);
             policyTypeProvider.createPolicyType(badPolicyType);
-        }).hasMessage("mandatory 'version' field is missing in policy types: onap.policies.optimization.Resource");
+        }).hasMessageContaining("INVALID:key version is a null version");
 
         policyTypeProvider.deletePolicyType(POLICY_TYPE_NAME_MONITORING, POLICY_TYPE_VERSION);
     }
                 .decode(ResourceUtils.getResourceAsString(POLICY_RESOURCE_MONITORING), ToscaServiceTemplate.class);
         policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
 
-        String exceptionMessage = "policy type with ID onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 "
-                + "cannot be deleted as it is parameterized by policies onap.restart.tca:1.0.0";
+        String exceptionMessage = "policy type onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 is in use, "
+                + "it is referenced in policy onap.restart.tca:1.0.0";
         assertThatThrownBy(() -> {
             policyTypeProvider.deletePolicyType("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0");
         }).hasMessage(exceptionMessage);
 
         assertThatThrownBy(() -> {
             policyTypeProvider.deletePolicyType("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0");
-        }).hasMessage("policy types for onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 do not exist");
+        }).hasMessage("policy type onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 not found");
     }
 }
 
 {
-  "policy-id" : "guard.frequency.scaleout",
+  "policy-id" : "guard.frequency.scaleout.noversion",
   "content" : {
             "actor": "SO",
             "recipe": "VF Module Create",