Merge "Add Service Template TOSCA handling"
[policy/models.git] / models-tosca / src / test / java / org / onap / policy / models / tosca / authorative / concepts / ToscaConceptIdentifierOptVersionTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Models
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.models.tosca.authorative.concepts;
23
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
26
27 import org.junit.Test;
28
29 /**
30  * Test the other constructors, as {@link PojosTest} tests the other methods.
31  */
32 public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBase<ToscaConceptIdentifierOptVersion> {
33
34     public ToscaConceptIdentifierOptVersionTest() {
35         super(ToscaConceptIdentifierOptVersion.class, "name", "version");
36     }
37
38     @Test
39     public void testAllArgsConstructor_testIsNullVersion() {
40         assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion(null, VERSION))
41                         .isInstanceOf(NullPointerException.class);
42
43         // with null version
44         ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion(NAME, null);
45         assertEquals(NAME, orig.getName());
46         assertEquals(null, orig.getVersion());
47
48         orig = new ToscaConceptIdentifierOptVersion(NAME, VERSION);
49         assertEquals(NAME, orig.getName());
50         assertEquals(VERSION, orig.getVersion());
51     }
52
53     @Test
54     public void testCopyConstructor() throws Exception {
55         assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifierOptVersion) null))
56                         .isInstanceOf(NullPointerException.class);
57
58         ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion();
59
60         // verify with null values
61         assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString());
62
63         // verify with all values
64         orig = makeIdent(NAME, VERSION);
65         assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString());
66     }
67
68     @Test
69     public void testCopyToscaPolicyIdentifierConstructor() {
70         assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifier) null))
71                         .isInstanceOf(NullPointerException.class);
72
73         ToscaConceptIdentifier orig = new ToscaConceptIdentifier();
74
75         // verify with null values
76         ToscaConceptIdentifierOptVersion newIdent = new ToscaConceptIdentifierOptVersion(orig);
77         assertEquals(null, newIdent.getName());
78         assertEquals(null, newIdent.getVersion());
79
80         // verify with all values
81         orig.setName(NAME);
82         orig.setVersion(VERSION);
83         newIdent = new ToscaConceptIdentifierOptVersion(orig);
84         assertEquals(NAME, newIdent.getName());
85         assertEquals(VERSION, newIdent.getVersion());
86     }
87
88     @Test
89     @Override
90     public void testCompareTo() throws Exception {
91         super.testCompareTo();
92     }
93 }