From f2b0318f53abf9f2345a5cdca74f3dd635aa9b60 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 4 Jan 2021 12:15:18 +0000 Subject: Changed identifiers to concept identifiers The policy models tosca classes ToscaPolicyIdentifier and ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA concept, not just TOSCA policies so they are renamed to ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion respectively. The class ToscaPolicyTypeIdentifier is redundant and is replaced by ToscaConceptIdentifier. Issue-ID: POLICY-2900 Change-Id: Id0a37c42ea4e74f07b47e1694c4f8291c35879c9 Signed-off-by: liamfallon --- .../ToscaConceptIdentifierOptVersionTest.java | 93 ++++++++++++++++++++++ .../concepts/ToscaPolicyConceptIdentifierTest.java | 93 ++++++++++++++++++++++ .../ToscaPolicyIdentifierOptVersionTest.java | 92 --------------------- .../concepts/ToscaPolicyIdentifierTest.java | 92 --------------------- .../authorative/concepts/ToscaPolicyTest.java | 6 +- .../ToscaPolicyTypeConceptIdentifierTest.java | 93 ++++++++++++++++++++++ .../concepts/ToscaPolicyTypeIdentifierTest.java | 92 --------------------- 7 files changed, 282 insertions(+), 279 deletions(-) create mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java create mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyConceptIdentifierTest.java delete mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java delete mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierTest.java create mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeConceptIdentifierTest.java delete mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifierTest.java (limited to 'models-tosca/src/test') diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java new file mode 100644 index 000000000..aedf5cb15 --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java @@ -0,0 +1,93 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Test the other constructors, as {@link PojosTest} tests the other methods. + */ +public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBase { + + public ToscaConceptIdentifierOptVersionTest() { + super(ToscaConceptIdentifierOptVersion.class, "name", "version"); + } + + @Test + public void testAllArgsConstructor_testIsNullVersion() { + assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion(null, VERSION)) + .isInstanceOf(NullPointerException.class); + + // with null version + ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion(NAME, null); + assertEquals(NAME, orig.getName()); + assertEquals(null, orig.getVersion()); + + orig = new ToscaConceptIdentifierOptVersion(NAME, VERSION); + assertEquals(NAME, orig.getName()); + assertEquals(VERSION, orig.getVersion()); + } + + @Test + public void testCopyConstructor() throws Exception { + assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifierOptVersion) null)) + .isInstanceOf(NullPointerException.class); + + ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion(); + + // verify with null values + assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString()); + + // verify with all values + orig = makeIdent(NAME, VERSION); + assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString()); + } + + @Test + public void testCopyToscaPolicyIdentifierConstructor() { + assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifier) null)) + .isInstanceOf(NullPointerException.class); + + ToscaConceptIdentifier orig = new ToscaConceptIdentifier(); + + // verify with null values + ToscaConceptIdentifierOptVersion newIdent = new ToscaConceptIdentifierOptVersion(orig); + assertEquals(null, newIdent.getName()); + assertEquals(null, newIdent.getVersion()); + + // verify with all values + orig.setName(NAME); + orig.setVersion(VERSION); + newIdent = new ToscaConceptIdentifierOptVersion(orig); + assertEquals(NAME, newIdent.getName()); + assertEquals(VERSION, newIdent.getVersion()); + } + + @Test + @Override + public void testCompareTo() throws Exception { + super.testCompareTo(); + } +} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyConceptIdentifierTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyConceptIdentifierTest.java new file mode 100644 index 000000000..6f49fd433 --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyConceptIdentifierTest.java @@ -0,0 +1,93 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.policy.common.parameters.ValidationResult; + +/** + * Test methods not tested by {@link PojosTest}. + */ +public class ToscaPolicyConceptIdentifierTest extends ToscaIdentifierTestBase { + + public ToscaPolicyConceptIdentifierTest() { + super(ToscaConceptIdentifier.class, "name", "version"); + } + + @Test + public void testAllArgsConstructor() { + assertThatThrownBy(() -> new ToscaConceptIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaConceptIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); + + ToscaConceptIdentifier orig = new ToscaConceptIdentifier(NAME, VERSION); + assertEquals(NAME, orig.getName()); + assertEquals(VERSION, orig.getVersion()); + } + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new ToscaConceptIdentifier(null)).isInstanceOf(NullPointerException.class); + + ToscaConceptIdentifier orig = new ToscaConceptIdentifier(); + + // verify with null values + assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString()); + + // verify with all values + orig = new ToscaConceptIdentifier(NAME, VERSION); + assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString()); + } + + @Test + public void testValidatePapRest() throws Exception { + ToscaConceptIdentifier ident = new ToscaConceptIdentifier(NAME, VERSION); + ValidationResult result = ident.validatePapRest(); + assertNotNull(result); + assertTrue(result.isValid()); + assertNull(result.getResult()); + + ident = makeIdent(NAME, null); + result = ident.validatePapRest(); + assertNotNull(result); + assertFalse(result.isValid()); + assertNotNull(result.getResult()); + + ident = makeIdent(null, VERSION); + result = ident.validatePapRest(); + assertNotNull(result); + assertFalse(result.isValid()); + assertNotNull(result.getResult()); + } + + @Test + @Override + public void testCompareTo() throws Exception { + super.testCompareTo(); + } +} 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 deleted file mode 100644 index 0b43173ad..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersionTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.authorative.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Test the other constructors, as {@link PojosTest} tests the other methods. - */ -public class ToscaPolicyIdentifierOptVersionTest extends ToscaIdentifierTestBase { - - public ToscaPolicyIdentifierOptVersionTest() { - super(ToscaPolicyIdentifierOptVersion.class, "policy-id", "policy-version"); - } - - @Test - public void testAllArgsConstructor_testIsNullVersion() { - assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion(null, VERSION)) - .isInstanceOf(NullPointerException.class); - - // with null version - ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(NAME, null); - assertEquals(NAME, orig.getName()); - assertEquals(null, orig.getVersion()); - - orig = new ToscaPolicyIdentifierOptVersion(NAME, VERSION); - assertEquals(NAME, orig.getName()); - assertEquals(VERSION, orig.getVersion()); - } - - @Test - public void testCopyConstructor() throws Exception { - assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion((ToscaPolicyIdentifierOptVersion) null)) - .isInstanceOf(NullPointerException.class); - - ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(); - - // verify with null values - assertEquals(orig.toString(), new ToscaPolicyIdentifierOptVersion(orig).toString()); - - // verify with all values - orig = makeIdent(NAME, VERSION); - assertEquals(orig.toString(), new ToscaPolicyIdentifierOptVersion(orig).toString()); - } - - @Test - public void testCopyToscaPolicyIdentifierConstructor() { - 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 - @Override - public void testCompareTo() throws Exception { - super.testCompareTo(); - } -} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierTest.java deleted file mode 100644 index cc40e2410..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.authorative.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.common.parameters.ValidationResult; - -/** - * Test methods not tested by {@link PojosTest}. - */ -public class ToscaPolicyIdentifierTest extends ToscaIdentifierTestBase { - - public ToscaPolicyIdentifierTest() { - super(ToscaPolicyIdentifier.class, "name", "version"); - } - - @Test - public void testAllArgsConstructor() { - assertThatThrownBy(() -> new ToscaPolicyIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> new ToscaPolicyIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); - - ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier(NAME, VERSION); - assertEquals(NAME, orig.getName()); - assertEquals(VERSION, orig.getVersion()); - } - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new ToscaPolicyIdentifier(null)).isInstanceOf(NullPointerException.class); - - ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier(); - - // verify with null values - assertEquals(orig.toString(), new ToscaPolicyIdentifier(orig).toString()); - - // verify with all values - orig = new ToscaPolicyIdentifier(NAME, VERSION); - assertEquals(orig.toString(), new ToscaPolicyIdentifier(orig).toString()); - } - - @Test - public void testValidatePapRest() throws Exception { - ToscaPolicyIdentifier ident = new ToscaPolicyIdentifier(NAME, VERSION); - ValidationResult result = ident.validatePapRest(); - assertNotNull(result); - assertTrue(result.isValid()); - assertNull(result.getResult()); - - ident = makeIdent(NAME, null); - result = ident.validatePapRest(); - assertNotNull(result); - assertFalse(result.isValid()); - assertNotNull(result.getResult()); - - ident = makeIdent(null, VERSION); - result = ident.validatePapRest(); - assertNotNull(result); - assertFalse(result.isValid()); - assertNotNull(result.getResult()); - } - - @Test - @Override - public void testCompareTo() throws Exception { - super.testCompareTo(); - } -} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java index 9fd559392..59f471ae8 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,11 +47,11 @@ public class ToscaPolicyTest { assertEquals("ToscaEntityKey(name=my_name, version=1.2.3)", policy.getKey().toString()); - ToscaPolicyIdentifier ident = policy.getIdentifier(); + ToscaConceptIdentifier ident = policy.getIdentifier(); assertEquals("my_name", ident.getName()); assertEquals("1.2.3", ident.getVersion()); - ToscaPolicyTypeIdentifier type = policy.getTypeIdentifier(); + ToscaConceptIdentifier type = policy.getTypeIdentifier(); assertEquals("my_type", type.getName()); assertEquals("3.2.1", type.getVersion()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeConceptIdentifierTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeConceptIdentifierTest.java new file mode 100644 index 000000000..7845a1f32 --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeConceptIdentifierTest.java @@ -0,0 +1,93 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.policy.common.parameters.ValidationResult; + +/** + * Test methods not tested by {@link PojosTest}. + */ +public class ToscaPolicyTypeConceptIdentifierTest extends ToscaIdentifierTestBase { + + public ToscaPolicyTypeConceptIdentifierTest() { + super(ToscaConceptIdentifier.class, "name", "version"); + } + + @Test + public void testAllArgsConstructor() { + assertThatThrownBy(() -> new ToscaConceptIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new ToscaConceptIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); + + ToscaConceptIdentifier orig = new ToscaConceptIdentifier(NAME, VERSION); + assertEquals(NAME, orig.getName()); + assertEquals(VERSION, orig.getVersion()); + } + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new ToscaConceptIdentifier(null)).isInstanceOf(NullPointerException.class); + + ToscaConceptIdentifier orig = new ToscaConceptIdentifier(); + + // verify with null values + assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString()); + + // verify with all values + orig = new ToscaConceptIdentifier(NAME, VERSION); + assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString()); + } + + @Test + public void testValidatePapRest() throws Exception { + ToscaConceptIdentifier ident = new ToscaConceptIdentifier(NAME, VERSION); + ValidationResult result = ident.validatePapRest(); + assertNotNull(result); + assertTrue(result.isValid()); + assertNull(result.getResult()); + + ident = makeIdent(NAME, null); + result = ident.validatePapRest(); + assertNotNull(result); + assertFalse(result.isValid()); + assertNotNull(result.getResult()); + + ident = makeIdent(null, VERSION); + result = ident.validatePapRest(); + assertNotNull(result); + assertFalse(result.isValid()); + assertNotNull(result.getResult()); + } + + @Test + @Override + public void testCompareTo() throws Exception { + super.testCompareTo(); + } +} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifierTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifierTest.java deleted file mode 100644 index a5e0431b2..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifierTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.authorative.concepts; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.common.parameters.ValidationResult; - -/** - * Test methods not tested by {@link PojosTest}. - */ -public class ToscaPolicyTypeIdentifierTest extends ToscaIdentifierTestBase { - - public ToscaPolicyTypeIdentifierTest() { - super(ToscaPolicyTypeIdentifier.class, "name", "version"); - } - - @Test - public void testAllArgsConstructor() { - assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); - - ToscaPolicyTypeIdentifier orig = new ToscaPolicyTypeIdentifier(NAME, VERSION); - assertEquals(NAME, orig.getName()); - assertEquals(VERSION, orig.getVersion()); - } - - @Test - public void testCopyConstructor() { - assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(null)).isInstanceOf(NullPointerException.class); - - ToscaPolicyTypeIdentifier orig = new ToscaPolicyTypeIdentifier(); - - // verify with null values - assertEquals(orig.toString(), new ToscaPolicyTypeIdentifier(orig).toString()); - - // verify with all values - orig = new ToscaPolicyTypeIdentifier(NAME, VERSION); - assertEquals(orig.toString(), new ToscaPolicyTypeIdentifier(orig).toString()); - } - - @Test - public void testValidatePapRest() throws Exception { - ToscaPolicyTypeIdentifier ident = new ToscaPolicyTypeIdentifier(NAME, VERSION); - ValidationResult result = ident.validatePapRest(); - assertNotNull(result); - assertTrue(result.isValid()); - assertNull(result.getResult()); - - ident = makeIdent(NAME, null); - result = ident.validatePapRest(); - assertNotNull(result); - assertFalse(result.isValid()); - assertNotNull(result.getResult()); - - ident = makeIdent(null, VERSION); - result = ident.validatePapRest(); - assertNotNull(result); - assertFalse(result.isValid()); - assertNotNull(result.getResult()); - } - - @Test - @Override - public void testCompareTo() throws Exception { - super.testCompareTo(); - } -} -- cgit 1.2.3-korg