2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2021 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.tosca.authorative.concepts;
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
27 import org.junit.Test;
30 * Test the other constructors, as {@link PojosTest} tests the other methods.
32 public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBase<ToscaConceptIdentifierOptVersion> {
34 public ToscaConceptIdentifierOptVersionTest() {
35 super(ToscaConceptIdentifierOptVersion.class, "name", "version");
39 public void testAllArgsConstructor_testIsNullVersion() {
40 assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion(null, VERSION))
41 .isInstanceOf(NullPointerException.class);
44 ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion(NAME, null);
45 assertEquals(NAME, orig.getName());
46 assertEquals(null, orig.getVersion());
48 orig = new ToscaConceptIdentifierOptVersion(NAME, VERSION);
49 assertEquals(NAME, orig.getName());
50 assertEquals(VERSION, orig.getVersion());
54 public void testCopyConstructor() throws Exception {
55 assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifierOptVersion) null))
56 .isInstanceOf(NullPointerException.class);
58 ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion();
60 // verify with null values
61 assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString());
63 // verify with all values
64 orig = makeIdent(NAME, VERSION);
65 assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString());
69 public void testCopyToscaPolicyIdentifierConstructor() {
70 assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifier) null))
71 .isInstanceOf(NullPointerException.class);
73 ToscaConceptIdentifier orig = new ToscaConceptIdentifier();
75 // verify with null values
76 ToscaConceptIdentifierOptVersion newIdent = new ToscaConceptIdentifierOptVersion(orig);
77 assertEquals(null, newIdent.getName());
78 assertEquals(null, newIdent.getVersion());
80 // verify with all values
82 orig.setVersion(VERSION);
83 newIdent = new ToscaConceptIdentifierOptVersion(orig);
84 assertEquals(NAME, newIdent.getName());
85 assertEquals(VERSION, newIdent.getVersion());
90 public void testCompareTo() throws Exception {
91 super.testCompareTo();