2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.model;
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;
28 import java.util.HashMap;
29 import java.util.LinkedList;
30 import java.util.List;
33 public class GroupInstanceTest {
35 private GroupInstance createTestSubject() {
36 return new GroupInstance();
40 public void testCtor() throws Exception {
41 new GroupInstance(new GroupInstanceDataDefinition());
45 public void testConvertToGroupInstancesProperties() throws Exception {
46 GroupInstance testSubject;
47 List<GroupInstanceProperty> result;
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();
59 public void testConvertFromGroupInstancesProperties() throws Exception {
60 GroupInstance testSubject;
61 List<GroupInstanceProperty> groupInstancesProperties = null;
64 testSubject = createTestSubject();
65 groupInstancesProperties = null;
66 testSubject.convertFromGroupInstancesProperties(groupInstancesProperties);
67 groupInstancesProperties = new LinkedList<>();
68 groupInstancesProperties.add(new GroupInstanceProperty());
69 testSubject.convertFromGroupInstancesProperties(groupInstancesProperties);
73 public void testRemoveArtifactsDuplicates() throws Exception {
74 GroupInstance testSubject;
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");
89 public void testClearArtifactsUuid() throws Exception {
90 GroupInstance testSubject;
93 testSubject = createTestSubject();
94 Deencapsulation.invoke(testSubject, "clearArtifactsUuid");
98 public void testAlignArtifactsUuid() throws Exception {
99 GroupInstance testSubject;
100 Map<String, ArtifactDefinition> deploymentArtifacts = null;
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);
115 public void testAddArtifactsIdToCollection() throws Exception {
116 GroupInstance testSubject;
117 List<String> artifactUuids = new LinkedList<>();
118 ArtifactDefinition artifact = new ArtifactDefinition();
121 testSubject = createTestSubject();
122 Deencapsulation.invoke(testSubject, "addArtifactsIdToCollection", artifactUuids, artifact);
123 artifact.setArtifactUUID("mock");
124 Deencapsulation.invoke(testSubject, "addArtifactsIdToCollection", artifactUuids, artifact);