aboutsummaryrefslogtreecommitdiffstats
path: root/models-base/src
diff options
context:
space:
mode:
Diffstat (limited to 'models-base/src')
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java23
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java24
2 files changed, 34 insertions, 13 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
index de328e9f2..ce1c3e888 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 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");
@@ -42,7 +42,7 @@ public class PfReferenceKeyTest {
private static final String VERSION001 = "0.0.1";
@Test
- public void testPfReferenceKey() {
+ public void testPfReferenceKeyNotNull() {
assertNotNull(new PfReferenceKey());
assertNotNull(new PfReferenceKey(new PfConceptKey()));
assertNotNull(new PfReferenceKey(new PfConceptKey(), LOCAL_NAME));
@@ -57,7 +57,10 @@ public class PfReferenceKeyTest {
assertThatThrownBy(() -> new PfReferenceKey(new PfConceptKey(), null))
.hasMessage("parameter \"localName\" is null");
+ }
+ @Test
+ public void testPfReferenceKey() {
PfReferenceKey testReferenceKey = new PfReferenceKey();
testReferenceKey.setParentConceptKey(new PfConceptKey("PN", VERSION001));
assertEquals("PN:0.0.1", testReferenceKey.getParentConceptKey().getId());
@@ -96,7 +99,11 @@ public class PfReferenceKeyTest {
assertEquals(PfKey.Compatibility.IDENTICAL, testReferenceKey.getCompatibility(testReferenceKey));
assertTrue(testReferenceKey.validate("").isValid());
+ }
+ @Test
+ public void testMultiplePfReferenceKey() {
+ PfReferenceKey testReferenceKey = setTestReferenceKey();
testReferenceKey.clean();
PfReferenceKey clonedReferenceKey = new PfReferenceKey(testReferenceKey);
@@ -172,4 +179,16 @@ public class PfReferenceKeyTest {
assertThat(validationResult4.getResult()).contains("\"localName\"")
.contains("does not match regular expression [A-Za-z0-9\\-_\\.]+|^$");
}
+
+ private PfReferenceKey setTestReferenceKey() {
+ PfReferenceKey testReferenceKey = new PfReferenceKey();
+ testReferenceKey.setParentConceptKey(new PfConceptKey("PN", VERSION001));
+ testReferenceKey.setParentReferenceKey(new PfReferenceKey("PN", VERSION001, "LN"));
+ testReferenceKey.setParentKeyName("NPKN");
+ testReferenceKey.setParentKeyVersion(VERSION001);
+ testReferenceKey.setParentLocalName(NPKLN);
+ testReferenceKey.setLocalName("NLN");
+
+ return testReferenceKey;
+ }
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java
index 4afdadff3..79f271c9c 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java
@@ -59,17 +59,6 @@ public class PfTimestampKeyTest {
assertEquals(someKey2, someKey1.getKey());
assertEquals(1, someKey1.getKeys().size());
-
- assertThatThrownBy(() -> new PfTimestampKey((PfTimestampKey) null)).isInstanceOf(NullPointerException.class)
- .hasMessageMatching(CONCEPT_IS_NULL);
- assertThatThrownBy(() -> new PfTimestampKey(null, null, null)).isInstanceOf(NullPointerException.class)
- .hasMessageMatching(NAME_IS_NULL);
- assertThatThrownBy(() -> new PfTimestampKey("my-name", null, null)).isInstanceOf(NullPointerException.class)
- .hasMessageMatching(VERSION_IS_NULL);
- assertThatThrownBy(() -> new PfTimestampKey("my-name", VERSION001, null))
- .isInstanceOf(NullPointerException.class)
- .hasMessageMatching("^instant is marked .*on.*ull but is null$");
-
assertThatThrownBy(() -> someKey0.setName(null)).isInstanceOf(NullPointerException.class)
.hasMessageMatching(NAME_IS_NULL);
assertThatThrownBy(() -> someKey0.setVersion(null)).isInstanceOf(NullPointerException.class)
@@ -94,4 +83,17 @@ public class PfTimestampKeyTest {
assertFalse(someKey4.isNullKey());
assertFalse(someKey1.isNullKey());
}
+
+ @Test
+ public void testTimestampKeyErrors() {
+ assertThatThrownBy(() -> new PfTimestampKey((PfTimestampKey) null)).isInstanceOf(NullPointerException.class)
+ .hasMessageMatching(CONCEPT_IS_NULL);
+ assertThatThrownBy(() -> new PfTimestampKey(null, null, null)).isInstanceOf(NullPointerException.class)
+ .hasMessageMatching(NAME_IS_NULL);
+ assertThatThrownBy(() -> new PfTimestampKey("my-name", null, null)).isInstanceOf(NullPointerException.class)
+ .hasMessageMatching(VERSION_IS_NULL);
+ assertThatThrownBy(() -> new PfTimestampKey("my-name", VERSION001, null))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessageMatching("^instant is marked .*on.*ull but is null$");
+ }
}