diff options
author | liamfallon <liam.fallon@est.tech> | 2019-05-16 16:28:39 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-05-16 16:28:39 +0000 |
commit | 4e60bb128db2a72224a84c73735c0162960a44b6 (patch) | |
tree | 60359faf4458352f657cd0cc84c57355bddf39fc /models-tosca/src/test | |
parent | fe226fad65b116c85f95f55e22cae72ba3e0a37b (diff) |
Allow policy type prefix on policy guard policy id
In order to identify the policy type of a guard policy,
we need to have the first part of the policy id as the
policy type identifier prefix.
Issue-ID: POLICY-1776
Change-Id: I1d6a3c4b122d978ff7ef40ce76ced7f160ebd4fa
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/test')
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java index 6ddf1aeeb..2aadcd7b2 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java @@ -184,6 +184,35 @@ public class LegacyProvider4LegacyGuardTest { } @Test + public void testPolicyCreateBad() throws Exception { + assertThatThrownBy(() -> { + new LegacyProvider().createGuardPolicy(null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new LegacyProvider().createGuardPolicy(null, new LegacyGuardPolicyInput()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new LegacyProvider().createGuardPolicy(pfDao, null); + }).hasMessage("legacyGuardPolicy is marked @NonNull but is null"); + + createPolicyTypes(); + + LegacyGuardPolicyInput originalGip = standardCoder.decode( + ResourceUtils.getResourceAsString("policies/vDNS.policy.guard.frequency.input.json"), + LegacyGuardPolicyInput.class); + + assertNotNull(originalGip); + + originalGip.setPolicyId("i.do.not.exist"); + + assertThatThrownBy(() -> { + new LegacyProvider().createGuardPolicy(pfDao, originalGip); + }).hasMessage("policy type for guard policy \"i.do.not.exist\" unknown"); + } + + @Test public void testPolicyUpdate() throws Exception { assertThatThrownBy(() -> { new LegacyProvider().updateGuardPolicy(null, null); @@ -293,7 +322,7 @@ public class LegacyProvider4LegacyGuardTest { }).hasMessage("no policy found for policy ID: guard.frequency.scaleout"); LegacyGuardPolicyInput otherGip = new LegacyGuardPolicyInput(); - otherGip.setPolicyId("guard.blacklist"); + otherGip.setPolicyId("guard.blacklist.b0"); otherGip.setPolicyVersion("1"); otherGip.setContent(new LegacyGuardPolicyContent()); |