diff options
Diffstat (limited to 'models-pdp/src/test')
6 files changed, 50 insertions, 47 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java index eac2fb5d6..2580ca829 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPdpSubGroup.java @@ -27,8 +27,8 @@ import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.Map; import java.util.TreeMap; + import org.junit.Test; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Test the copy constructor, as {@link TestModels} tests the other methods. @@ -39,7 +39,7 @@ public class TestPdpSubGroup { public void testCopyConstructor() { assertThatThrownBy(() -> new PdpSubGroup(null)).isInstanceOf(NullPointerException.class); - PdpSubGroup orig = new PdpSubGroup(); + final PdpSubGroup orig = new PdpSubGroup(); // verify with null values assertEquals( @@ -51,27 +51,29 @@ public class TestPdpSubGroup { orig.setCurrentInstanceCount(10); orig.setDesiredInstanceCount(11); - Pdp inst1 = new Pdp(); + final Pdp inst1 = new Pdp(); inst1.setInstanceId("my-id-A"); - Pdp inst2 = new Pdp(); + final Pdp inst2 = new Pdp(); inst2.setInstanceId("my-id-B"); orig.setPdpInstances(Arrays.asList(inst1, inst2)); orig.setPdpType("my-type"); - ToscaPolicy pol1 = new ToscaPolicy(); - pol1.setDescription("policy-A"); - ToscaPolicy pol2 = new ToscaPolicy(); - pol2.setDescription("policy-B"); + final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier(); + pol1.setName("policy-A"); + pol1.setVersion("1.0.0"); + final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier(); + pol2.setName("policy-B"); + pol1.setVersion("2.0.0"); orig.setPolicies(Arrays.asList(pol1, pol2)); - Map<String, String> props = new TreeMap<>(); + final Map<String, String> props = new TreeMap<>(); props.put("key-A", "value-A"); props.put("key-B", "value-B"); orig.setProperties(props); - PolicyTypeIdent supp1 = new PolicyTypeIdent("supp-A", "1.2"); - PolicyTypeIdent supp2 = new PolicyTypeIdent("supp-B", "3.4"); + final ToscaPolicyTypeIdentifier supp1 = new ToscaPolicyTypeIdentifier("supp-A", "1.2"); + final ToscaPolicyTypeIdentifier supp2 = new ToscaPolicyTypeIdentifier("supp-B", "3.4"); orig.setSupportedPolicyTypes(Arrays.asList(supp1, supp2)); assertEquals(orig.toString(), new PdpSubGroup(orig).toString()); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPolicyTypeIdent.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyIdentifier.java index 9247544fd..7a09e9d44 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPolicyTypeIdent.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyIdentifier.java @@ -28,36 +28,35 @@ import org.junit.Test; /** * Test the other constructors, as {@link TestModels} tests the other methods. */ -public class TestPolicyTypeIdent extends IdentTestBase<PolicyTypeIdent> { +public class TestToscaPolicyIdentifier extends ToscaIdentifierTestBase<ToscaPolicyIdentifier> { private static final String NAME = "my-name"; private static final String VERSION = "1.2.3"; - public TestPolicyTypeIdent() { - super(PolicyTypeIdent.class); + public TestToscaPolicyIdentifier() { + super(ToscaPolicyIdentifier.class); } @Test public void testAllArgsConstructor() { - assertThatThrownBy(() -> new PolicyTypeIdent(null, VERSION)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> new PolicyTypeIdent(NAME, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); - PolicyTypeIdent orig = new PolicyTypeIdent(NAME, VERSION); + ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier(NAME, VERSION); assertEquals(NAME, orig.getName()); assertEquals(VERSION, orig.getVersion()); } @Test public void testCopyConstructor() { - assertThatThrownBy(() -> new PolicyTypeIdent(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyIdentifier(null)).isInstanceOf(NullPointerException.class); - PolicyTypeIdent orig = new PolicyTypeIdent(); + ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier(); // verify with null values - assertEquals(orig.toString(), new PolicyTypeIdent(orig).toString()); + assertEquals(orig.toString(), new ToscaPolicyIdentifier(orig).toString()); // verify with all values - orig = new PolicyTypeIdent(NAME, VERSION); - assertEquals(orig.toString(), new PolicyTypeIdent(orig).toString()); + orig = new ToscaPolicyIdentifier(NAME, VERSION); + assertEquals(orig.toString(), new ToscaPolicyIdentifier(orig).toString()); } - } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPolicyIdentOptVersion.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyIdentifierOptVersion.java index 6ae7ad32b..c4e9278eb 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPolicyIdentOptVersion.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyIdentifierOptVersion.java @@ -30,25 +30,26 @@ import org.junit.Test; /** * Test the other constructors, as {@link TestModels} tests the other methods. */ -public class TestPolicyIdentOptVersion extends IdentTestBase<PolicyIdentOptVersion> { +public class TestToscaPolicyIdentifierOptVersion extends ToscaIdentifierTestBase<ToscaPolicyIdentifierOptVersion> { private static final String NAME = "my-name"; private static final String VERSION = "1.2.3"; - public TestPolicyIdentOptVersion() { - super(PolicyIdentOptVersion.class); + public TestToscaPolicyIdentifierOptVersion() { + super(ToscaPolicyIdentifierOptVersion.class); } @Test public void testAllArgsConstructor_testIsNullVersion() { - assertThatThrownBy(() -> new PolicyIdentOptVersion(null, VERSION)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion(null, VERSION)) + .isInstanceOf(NullPointerException.class); // with null version - PolicyIdentOptVersion orig = new PolicyIdentOptVersion(NAME, null); + ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(NAME, null); assertEquals(NAME, orig.getName()); assertEquals(null, orig.getVersion()); assertTrue(orig.isNullVersion()); - orig = new PolicyIdentOptVersion(NAME, VERSION); + orig = new ToscaPolicyIdentifierOptVersion(NAME, VERSION); assertEquals(NAME, orig.getName()); assertEquals(VERSION, orig.getVersion()); assertFalse(orig.isNullVersion()); @@ -56,15 +57,15 @@ public class TestPolicyIdentOptVersion extends IdentTestBase<PolicyIdentOptVersi @Test public void testCopyConstructor() throws Exception { - assertThatThrownBy(() -> new PolicyIdentOptVersion(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion(null)).isInstanceOf(NullPointerException.class); - PolicyIdentOptVersion orig = new PolicyIdentOptVersion(); + ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(); // verify with null values - assertEquals(orig.toString(), new PolicyIdentOptVersion(orig).toString()); + assertEquals(orig.toString(), new ToscaPolicyIdentifierOptVersion(orig).toString()); // verify with all values orig = makeIdent(NAME, VERSION); - assertEquals(orig.toString(), new PolicyIdentOptVersion(orig).toString()); + assertEquals(orig.toString(), new ToscaPolicyIdentifierOptVersion(orig).toString()); } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPolicyIdent.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyTypeIdentifier.java index da942468a..ab314ef12 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestPolicyIdent.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestToscaPolicyTypeIdentifier.java @@ -28,35 +28,36 @@ import org.junit.Test; /** * Test the other constructors, as {@link TestModels} tests the other methods. */ -public class TestPolicyIdent extends IdentTestBase<PolicyIdent> { +public class TestToscaPolicyTypeIdentifier extends ToscaIdentifierTestBase<ToscaPolicyTypeIdentifier> { private static final String NAME = "my-name"; private static final String VERSION = "1.2.3"; - public TestPolicyIdent() { - super(PolicyIdent.class); + public TestToscaPolicyTypeIdentifier() { + super(ToscaPolicyTypeIdentifier.class); } @Test public void testAllArgsConstructor() { - assertThatThrownBy(() -> new PolicyIdent(null, VERSION)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> new PolicyIdent(NAME, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); - PolicyIdent orig = new PolicyIdent(NAME, VERSION); + ToscaPolicyTypeIdentifier orig = new ToscaPolicyTypeIdentifier(NAME, VERSION); assertEquals(NAME, orig.getName()); assertEquals(VERSION, orig.getVersion()); } @Test public void testCopyConstructor() { - assertThatThrownBy(() -> new PolicyIdent(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(null)).isInstanceOf(NullPointerException.class); - PolicyIdent orig = new PolicyIdent(); + ToscaPolicyTypeIdentifier orig = new ToscaPolicyTypeIdentifier(); // verify with null values - assertEquals(orig.toString(), new PolicyIdent(orig).toString()); + assertEquals(orig.toString(), new ToscaPolicyTypeIdentifier(orig).toString()); // verify with all values - orig = new PolicyIdent(NAME, VERSION); - assertEquals(orig.toString(), new PolicyIdent(orig).toString()); + orig = new ToscaPolicyTypeIdentifier(NAME, VERSION); + assertEquals(orig.toString(), new ToscaPolicyTypeIdentifier(orig).toString()); } + } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/IdentTestBase.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ToscaIdentifierTestBase.java index 10bc9a997..8b6a4f7bb 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/IdentTestBase.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ToscaIdentifierTestBase.java @@ -29,7 +29,7 @@ import org.onap.policy.common.utils.coder.StandardCoder; * * @param <T> type of key being tested */ -public class IdentTestBase<T> { +public class ToscaIdentifierTestBase<T> { private static final Coder coder = new StandardCoder(); @@ -40,7 +40,7 @@ public class IdentTestBase<T> { * Constructs the object. * @param clazz the type of class being tested */ - public IdentTestBase(Class<T> clazz) { + public ToscaIdentifierTestBase(Class<T> clazz) { this.clazz = clazz; } diff --git a/models-pdp/src/test/java/org/onap/policy/models/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/persistence/provider/PdpProviderTest.java index 14990f911..fcb9062c6 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/persistence/provider/PdpProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/persistence/provider/PdpProviderTest.java @@ -41,7 +41,7 @@ import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpGroups; import org.onap.policy.models.pdp.concepts.PdpSubGroup; -import org.onap.policy.models.pdp.concepts.PolicyTypeIdent; +import org.onap.policy.models.pdp.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.pdp.persistence.provider.PdpProvider; |