aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-05-22 02:38:32 +0000
committerliamfallon <liam.fallon@est.tech>2019-05-22 02:38:32 +0000
commit3a228ca91c313990741ef6a537d9f9615a0e0215 (patch)
tree77049c4ea0d2892730656bceb259d7110f8282c7 /models-provider/src
parentd5ed712cf50bcf270fed8cd597d78ff4ff9370a0 (diff)
Fix name/version regexp in model keys
The regular expressions for checking names and versions in policy key names and versions were not expressive enough to restrict all error names and versions. Issue-ID: POLICY-1777 Change-Id: I037eca051f6c7a9f1e7182150d40d8b8d906a75c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider/src')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java4
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java16
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java8
3 files changed, 14 insertions, 14 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
index 9b494d1ab..bd28c3238 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
@@ -232,7 +232,7 @@ public interface PolicyModelsProvider extends AutoCloseable {
* Delete legacy operational policy.
*
* @param policyId ID of the policy.
- * @param policyVersion version of the policy, set to null to get the latest policy
+ * @param policyVersion version of the policy
* @return the deleted policy
* @throws PfModelException on errors deleting policies
*/
@@ -274,7 +274,7 @@ public interface PolicyModelsProvider extends AutoCloseable {
* Delete legacy guard policy.
*
* @param policyId ID of the policy.
- * @param policyVersion version of the policy, set to null to get the latest policy
+ * @param policyVersion version of the policy
* @return the deleted policy
* @throws PfModelException on errors deleting policies
*/
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 6fac58706..456f88d9b 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -440,8 +440,8 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("no policy found for policy: policy_id:null");
assertThatThrownBy(() -> {
- databaseProvider.getOperationalPolicy("policy_id", "10.9.8");
- }).hasMessage("no policy found for policy: policy_id:10.9.8");
+ databaseProvider.getOperationalPolicy("policy_id", "10");
+ }).hasMessage("no policy found for policy: policy_id:10");
assertThatThrownBy(() -> {
databaseProvider.createOperationalPolicy(new LegacyOperationalPolicy());
@@ -452,16 +452,16 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deleteOperationalPolicy("policy_id", "55.44.33");
- }).hasMessage("no policy found for policy: policy_id:55.44.33");
+ databaseProvider.deleteOperationalPolicy("policy_id", "55");
+ }).hasMessage("no policy found for policy: policy_id:55");
assertThatThrownBy(() -> {
databaseProvider.getGuardPolicy("policy_id", null);
}).hasMessage("no policy found for policy: policy_id:null");
assertThatThrownBy(() -> {
- databaseProvider.getGuardPolicy("policy_id", "6.7.5");
- }).hasMessage("no policy found for policy: policy_id:6.7.5");
+ databaseProvider.getGuardPolicy("policy_id", "6");
+ }).hasMessage("no policy found for policy: policy_id:6");
assertThatThrownBy(() -> {
databaseProvider.createGuardPolicy(new LegacyGuardPolicyInput());
@@ -472,8 +472,8 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("policy type for guard policy \"null\" unknown");
assertThatThrownBy(() -> {
- databaseProvider.deleteGuardPolicy("policy_id", "33.22.11");
- }).hasMessage("no policy found for policy: policy_id:33.22.11");
+ databaseProvider.deleteGuardPolicy("policy_id", "33");
+ }).hasMessage("no policy found for policy: policy_id:33");
assertEquals(0, databaseProvider.getPdpGroups("name").size());
assertEquals(0, databaseProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).size());
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
index 4f4c1c3fb..07f4ed72d 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
@@ -121,8 +121,8 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull String policyId, final String policyVersion)
- throws PfModelException {
+ public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull String policyId,
+ @NonNull final String policyVersion) throws PfModelException {
return null;
}
@@ -145,8 +145,8 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull String policyId, final String policyVersion)
- throws PfModelException {
+ public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull String policyId,
+ @NonNull final String policyVersion) throws PfModelException {
return null;
}