From c38fcf1a16f0d6bfdf2d80efa64a94ae68d80f03 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 12 Apr 2019 15:53:08 -0400 Subject: Check for duplicates in lists Modified duplicate subgroup check to eliminate sonar issue. Added duplicate group check. Modified ModelsTest to exclude PdpMessage, which seemed to cause intermittent junit failures. Change-Id: Id281874506d3a39610739e24cee49360b345724f Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn --- .../test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java | 6 +++++- .../java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'models-pdp/src/test/java/org/onap') diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java index 7a6c03c71..743839362 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java @@ -42,6 +42,10 @@ public class ModelsTest { public void testPdpModels() { final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) .with(new GetterTester()).build(); - validator.validate(POJO_PACKAGE, new FilterPackageInfo(), new FilterClassName(PdpMessage.class.getName())); + + // exclude Test classes and PdpMessage + validator.validate(POJO_PACKAGE, new FilterPackageInfo(), + new FilterClassName("^((?!Test$).)*$"), + new FilterClassName("^((?!" + PdpMessage.class.getName() + ").)*$")); } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java index 22e178da2..e0fafc18d 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java @@ -82,6 +82,11 @@ public class PdpGroupsTest { groupX.setName(null); groups.setGroups(Arrays.asList(group1, groupX)); assertInvalid(groups); + + // duplicate groups + groups = new PdpGroups(); + groups.setGroups(Arrays.asList(group1, group2, group1)); + assertInvalid(groups); } private void assertInvalid(PdpGroups groups) { -- cgit 1.2.3-korg