X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-pdp%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fpdp%2Fpersistence%2Fconcepts%2FJpaPdpSubGroupTest.java;h=566de0d98d736a5865622922dcb455f301cfc5e1;hb=b205fafdef86b5a3b6751415b6eb266243cf961f;hp=969b59c6dd9fcf2a17b4fe3f689c4482db2cec6c;hpb=c060c361ada331e2c728b28ddb80a6d720d295a7;p=policy%2Fmodels.git diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java index 969b59c6d..566de0d98 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,7 +52,7 @@ public class JpaPdpSubGroupTest { private static final String PDP_A = "PDP-A"; @Test - public void testJpaPdpSubGroup() { + public void testJpaPdpSubGroupErrors() { assertThatThrownBy(() -> { new JpaPdpSubGroup((JpaPdpSubGroup) null); }).hasMessageMatching("copyConcept is marked .*ull but is null"); @@ -114,7 +114,10 @@ public class JpaPdpSubGroupTest { }).hasMessageMatching(NULL_KEY_ERROR); assertNotNull(new JpaPdpSubGroup((new PfReferenceKey()))); + } + @Test + public void testJpaPdpSubGroup() { PdpSubGroup testPdpSubgroup = new PdpSubGroup(); testPdpSubgroup.setPdpType(PDP_A); JpaPdpSubGroup testJpaPdpSubGroup = new JpaPdpSubGroup(); @@ -154,6 +157,11 @@ public class JpaPdpSubGroupTest { testJpaPdpSubGroup.setSupportedPolicyTypes(new ArrayList<>()); testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfSearchableKey("APolicyType:1.0.0")); assertTrue(testJpaPdpSubGroup.validate("").isValid()); + } + + @Test + public void testJpaPdpSubGroupSavedKey() { + JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup(); PfReferenceKey savedKey = testJpaPdpSubGroup.getKey(); testJpaPdpSubGroup.setKey(PfReferenceKey.getNullKey()); @@ -185,6 +193,11 @@ public class JpaPdpSubGroupTest { assertTrue(testJpaPdpSubGroup.validate("").isValid()); testJpaPdpSubGroup.setProperties(null); assertTrue(testJpaPdpSubGroup.validate("").isValid()); + } + + @Test + public void testJpaPdpSubGroupPolicyTypes() { + JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup(); List supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes(); assertNotNull(supportedPolicyTypes); @@ -212,6 +225,11 @@ public class JpaPdpSubGroupTest { assertTrue(testJpaPdpSubGroup.validate("").isValid()); testJpaPdpSubGroup.setPdpInstances(pdpInstances); assertTrue(testJpaPdpSubGroup.validate("").isValid()); + } + + @Test + public void testJpaPdpSubGroupKeys() { + JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup(); JpaPdpSubGroup otherJpaPdpSubGroup = new JpaPdpSubGroup(testJpaPdpSubGroup); assertEquals(0, testJpaPdpSubGroup.compareTo(otherJpaPdpSubGroup)); @@ -278,4 +296,21 @@ public class JpaPdpSubGroupTest { assertEquals(testJpaPdpSubGroup, new JpaPdpSubGroup(testJpaPdpSubGroup)); } + + private JpaPdpSubGroup setUpJpaPdpSubGroup() { + PdpSubGroup testPdpSubgroup = new PdpSubGroup(); + testPdpSubgroup.setPdpType(PDP_A); + JpaPdpSubGroup testJpaPdpSubGroup = new JpaPdpSubGroup(); + testJpaPdpSubGroup.setKey(PfReferenceKey.getNullKey()); + testJpaPdpSubGroup.fromAuthorative(testPdpSubgroup); + testJpaPdpSubGroup.getKey().setParentConceptKey(new PfConceptKey("Parent:1.0.0")); + testJpaPdpSubGroup.setProperties(new LinkedHashMap<>()); + testJpaPdpSubGroup.setDesiredInstanceCount(0); + testJpaPdpSubGroup.setCurrentInstanceCount(0); + testJpaPdpSubGroup.setProperties(null); + testJpaPdpSubGroup.setSupportedPolicyTypes(new ArrayList<>()); + testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfSearchableKey("APolicyType:1.0.0")); + testJpaPdpSubGroup.clean(); + return testJpaPdpSubGroup; + } }