diff options
author | Jim Hahn <jrh3@att.com> | 2019-04-15 09:55:12 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-04-15 09:55:12 -0400 |
commit | 98508d7f797c8a94b5b4f03941f39be96db03166 (patch) | |
tree | 580ab5b040fe0ca94efe2f49f42414b02e042cdd /models-tosca/src/test/java | |
parent | aca88111b78129371aebd6d2c9250a8abb9cc2ac (diff) |
Add conversion from plain Ident to IdentOptVersion
Added a "copy constructor" that copies an Ident to an Ident
with an optional version. The reverse does not make sense,
so did not add that (e.g., version may be null or may just
be a prefix, while the version in Ident is major.minor.patch).
Change-Id: Ifd3935a998cd4c1cb5113a59c5f36a7d9baf79ff
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-tosca/src/test/java')
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java index 3f0a7b09c..1d393c1d5 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java @@ -39,7 +39,7 @@ public class ToscaPolicyIdentifierOptVersionTest extends ToscaIdentifierTestBase @Test public void testAllArgsConstructor_testIsNullVersion() { assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion(null, VERSION)) - .isInstanceOf(NullPointerException.class); + .isInstanceOf(NullPointerException.class); // with null version ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(NAME, null); @@ -55,7 +55,8 @@ public class ToscaPolicyIdentifierOptVersionTest extends ToscaIdentifierTestBase @Test public void testCopyConstructor() throws Exception { - assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion(null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion((ToscaPolicyIdentifierOptVersion) null)) + .isInstanceOf(NullPointerException.class); ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(); @@ -68,6 +69,26 @@ public class ToscaPolicyIdentifierOptVersionTest extends ToscaIdentifierTestBase } @Test + public void testCopyToscaPolicyIdentifierConstructor() throws Exception { + assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion((ToscaPolicyIdentifier) null)) + .isInstanceOf(NullPointerException.class); + + ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier(); + + // verify with null values + ToscaPolicyIdentifierOptVersion newIdent = new ToscaPolicyIdentifierOptVersion(orig); + assertEquals(null, newIdent.getName()); + assertEquals(null, newIdent.getVersion()); + + // verify with all values + orig.setName(NAME); + orig.setVersion(VERSION); + newIdent = new ToscaPolicyIdentifierOptVersion(orig); + assertEquals(NAME, newIdent.getName()); + assertEquals(VERSION, newIdent.getVersion()); + } + + @Test public void testCompareTo() throws Exception { super.testCompareTo(); } |