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.components.distribution.engine;
23 import mockit.Deencapsulation;
24 import org.junit.Assert;
25 import org.junit.Test;
26 import org.openecomp.sdc.be.components.BeConfDependentTest;
27 import org.openecomp.sdc.be.model.ArtifactDefinition;
28 import org.openecomp.sdc.be.model.ComponentInstance;
29 import org.openecomp.sdc.be.model.Service;
30 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
32 import java.util.Collection;
33 import java.util.HashMap;
34 import java.util.LinkedList;
35 import java.util.List;
38 public class ArtifactInfoImplTest extends BeConfDependentTest {
40 private ArtifactInfoImpl createTestSubject() {
41 return new ArtifactInfoImpl();
45 public void testConvertToArtifactInfoImpl() throws Exception {
46 Service service = new Service();
47 ComponentInstance resourceInstance = new ComponentInstance();
48 Collection<ArtifactDefinition> list = new LinkedList<>();
49 ArtifactDefinition artifactDefinition = new ArtifactDefinition();
50 List<ArtifactInfoImpl> result;
53 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
54 Assert.assertEquals(new LinkedList<>(), result);
57 artifactDefinition.setUniqueId("mock");
58 list.add(artifactDefinition);
59 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
60 Assert.assertFalse(result.isEmpty());
63 artifactDefinition.setGeneratedFromId("mock");
64 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
65 Assert.assertFalse(result.isEmpty());
69 public void testConvertServiceArtifactToArtifactInfoImpl() throws Exception {
70 Service service = new Service();
71 Collection<ArtifactDefinition> list = new LinkedList<>();
72 ArtifactDefinition artifactDefinition = new ArtifactDefinition();
73 List<ArtifactInfoImpl> result = new LinkedList<>();
76 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
77 Assert.assertEquals(new LinkedList<>(), result);
80 artifactDefinition.setUniqueId("mock");
81 list.add(artifactDefinition);
83 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
84 Assert.assertFalse(result.isEmpty());
87 artifactDefinition.setGeneratedFromId("mock");
89 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
90 Assert.assertFalse(result.isEmpty());
94 public void testGetUpdatedRequiredArtifactsFromNamesToUuids() throws Exception {
95 ArtifactDefinition artifactDefinition = null;
96 Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();
100 artifactDefinition = null;
101 result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids",
102 new Object[] { ArtifactDefinition.class, artifacts.getClass() });
103 Assert.assertEquals(null, result);
106 artifactDefinition = new ArtifactDefinition();
107 result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids",
108 new Object[] { ArtifactDefinition.class, artifacts.getClass() });
109 Assert.assertEquals(null, result);
113 public void testGetArtifactName() throws Exception {
114 ArtifactInfoImpl testSubject;
118 testSubject = createTestSubject();
119 result = testSubject.getArtifactName();
123 public void testSetArtifactName() throws Exception {
124 ArtifactInfoImpl testSubject;
125 String artifactName = "";
128 testSubject = createTestSubject();
129 testSubject.setArtifactName(artifactName);
133 public void testGetArtifactType() throws Exception {
134 ArtifactInfoImpl testSubject;
135 ArtifactTypeEnum result;
138 testSubject = createTestSubject();
139 result = testSubject.getArtifactType();
143 public void testSetArtifactType() throws Exception {
144 ArtifactInfoImpl testSubject;
145 ArtifactTypeEnum artifactType = null;
148 testSubject = createTestSubject();
149 testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL);
153 public void testGetArtifactURL() throws Exception {
154 ArtifactInfoImpl testSubject;
158 testSubject = createTestSubject();
159 result = testSubject.getArtifactURL();
163 public void testSetArtifactURL() throws Exception {
164 ArtifactInfoImpl testSubject;
165 String artifactURL = "";
168 testSubject = createTestSubject();
169 testSubject.setArtifactURL(artifactURL);
173 public void testGetArtifactChecksum() throws Exception {
174 ArtifactInfoImpl testSubject;
178 testSubject = createTestSubject();
179 result = testSubject.getArtifactChecksum();
183 public void testSetArtifactChecksum() throws Exception {
184 ArtifactInfoImpl testSubject;
185 String artifactChecksum = "";
188 testSubject = createTestSubject();
189 testSubject.setArtifactChecksum(artifactChecksum);
193 public void testGetArtifactDescription() throws Exception {
194 ArtifactInfoImpl testSubject;
198 testSubject = createTestSubject();
199 result = testSubject.getArtifactDescription();
203 public void testSetArtifactDescription() throws Exception {
204 ArtifactInfoImpl testSubject;
205 String artifactDescription = "";
208 testSubject = createTestSubject();
209 testSubject.setArtifactDescription(artifactDescription);
213 public void testGetArtifactTimeout() throws Exception {
214 ArtifactInfoImpl testSubject;
218 testSubject = createTestSubject();
219 result = testSubject.getArtifactTimeout();
223 public void testSetArtifactTimeout() throws Exception {
224 ArtifactInfoImpl testSubject;
225 Integer artifactTimeout = 0;
228 testSubject = createTestSubject();
229 testSubject.setArtifactTimeout(artifactTimeout);
233 public void testGetRelatedArtifacts() throws Exception {
234 ArtifactInfoImpl testSubject;
238 testSubject = createTestSubject();
239 result = testSubject.getRelatedArtifacts();
243 public void testSetRelatedArtifacts() throws Exception {
244 ArtifactInfoImpl testSubject;
245 List<String> relatedArtifacts = null;
248 testSubject = createTestSubject();
249 testSubject.setRelatedArtifacts(relatedArtifacts);
253 public void testToString() throws Exception {
254 ArtifactInfoImpl testSubject;
258 testSubject = createTestSubject();
259 result = testSubject.toString();
263 public void testGetArtifactUUID() throws Exception {
264 ArtifactInfoImpl testSubject;
268 testSubject = createTestSubject();
269 result = testSubject.getArtifactUUID();
273 public void testSetArtifactUUID() throws Exception {
274 ArtifactInfoImpl testSubject;
275 String artifactUUID = "";
278 testSubject = createTestSubject();
279 testSubject.setArtifactUUID(artifactUUID);
283 public void testGetArtifactVersion() throws Exception {
284 ArtifactInfoImpl testSubject;
288 testSubject = createTestSubject();
289 result = testSubject.getArtifactVersion();
293 public void testSetArtifactVersion() throws Exception {
294 ArtifactInfoImpl testSubject;
295 String artifactVersion = "";
298 testSubject = createTestSubject();
299 testSubject.setArtifactVersion(artifactVersion);
303 public void testGetGeneratedFromUUID() throws Exception {
304 ArtifactInfoImpl testSubject;
308 testSubject = createTestSubject();
309 result = testSubject.getGeneratedFromUUID();
313 public void testSetGeneratedFromUUID() throws Exception {
314 ArtifactInfoImpl testSubject;
315 String generatedFromUUID = "";
318 testSubject = createTestSubject();
319 testSubject.setGeneratedFromUUID(generatedFromUUID);