8c306883bf836c20db4deee1e6aa2bb2fc1bdaf4
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / GroupInstanceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.model;
22
23 import mockit.Deencapsulation;
24 import org.junit.Test;
25 import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
26 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
27
28 import java.util.HashMap;
29 import java.util.LinkedList;
30 import java.util.List;
31 import java.util.Map;
32
33 public class GroupInstanceTest {
34
35         private GroupInstance createTestSubject() {
36                 return new GroupInstance();
37         }
38
39         @Test
40         public void testCtor() throws Exception {
41                 new GroupInstance(new GroupInstanceDataDefinition());
42         }
43         
44         @Test
45         public void testConvertToGroupInstancesProperties() throws Exception {
46                 GroupInstance testSubject;
47                 List<GroupInstanceProperty> result;
48
49                 // default test
50                 testSubject = createTestSubject();
51                 result = testSubject.convertToGroupInstancesProperties();
52                 List<PropertyDataDefinition> properties = new LinkedList<>();
53                 properties.add(new PropertyDataDefinition());
54                 testSubject.setProperties(properties);
55                 result = testSubject.convertToGroupInstancesProperties();
56         }
57
58         @Test
59         public void testConvertFromGroupInstancesProperties() throws Exception {
60                 GroupInstance testSubject;
61                 List<GroupInstanceProperty> groupInstancesProperties = null;
62
63                 // test 1
64                 testSubject = createTestSubject();
65                 groupInstancesProperties = null;
66                 testSubject.convertFromGroupInstancesProperties(groupInstancesProperties);
67                 groupInstancesProperties = new LinkedList<>();
68                 groupInstancesProperties.add(new GroupInstanceProperty());
69                 testSubject.convertFromGroupInstancesProperties(groupInstancesProperties);
70         }
71
72         @Test
73         public void testRemoveArtifactsDuplicates() throws Exception {
74                 GroupInstance testSubject;
75
76                 // default test
77                 testSubject = createTestSubject();
78                 Deencapsulation.invoke(testSubject, "removeArtifactsDuplicates");
79                 LinkedList<String> artifacts = new LinkedList<>();
80                 artifacts.add("mock");
81                 testSubject.setArtifacts(artifacts);
82                 LinkedList<String> groupInstanceArtifacts = new LinkedList<>();
83                 groupInstanceArtifacts.add("mock");
84                 testSubject.setGroupInstanceArtifacts(groupInstanceArtifacts);
85                 Deencapsulation.invoke(testSubject, "removeArtifactsDuplicates");
86         }
87
88         @Test
89         public void testClearArtifactsUuid() throws Exception {
90                 GroupInstance testSubject;
91
92                 // default test
93                 testSubject = createTestSubject();
94                 Deencapsulation.invoke(testSubject, "clearArtifactsUuid");
95         }
96
97         @Test
98         public void testAlignArtifactsUuid() throws Exception {
99                 GroupInstance testSubject;
100                 Map<String, ArtifactDefinition> deploymentArtifacts = null;
101
102                 // default test
103                 testSubject = createTestSubject();
104                 testSubject.alignArtifactsUuid(deploymentArtifacts);
105                 LinkedList<String> artifacts = new LinkedList<>();
106                 artifacts.add("mock");
107                 testSubject.setArtifacts(artifacts);
108                 testSubject.alignArtifactsUuid(deploymentArtifacts);
109                 deploymentArtifacts = new HashMap<>();
110                 deploymentArtifacts.put("mock", new ArtifactDefinition());
111                 testSubject.alignArtifactsUuid(deploymentArtifacts);
112         }
113
114         @Test
115         public void testAddArtifactsIdToCollection() throws Exception {
116                 GroupInstance testSubject;
117                 List<String> artifactUuids = new LinkedList<>();
118                 ArtifactDefinition artifact = new ArtifactDefinition();
119
120                 // default test
121                 testSubject = createTestSubject();
122                 Deencapsulation.invoke(testSubject, "addArtifactsIdToCollection", artifactUuids, artifact);
123                 artifact.setArtifactUUID("mock");
124                 Deencapsulation.invoke(testSubject, "addArtifactsIdToCollection", artifactUuids, artifact);
125         }
126 }