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;
34 public class ArtifactInfoImplTest extends BeConfDependentTest {
36 private ArtifactInfoImpl createTestSubject() {
37 return new ArtifactInfoImpl();
41 public void testConvertToArtifactInfoImpl() throws Exception {
42 Service service = new Service();
43 ComponentInstance resourceInstance = new ComponentInstance();
44 Collection<ArtifactDefinition> list = new LinkedList<>();
45 ArtifactDefinition artifactDefinition = new ArtifactDefinition();
46 List<ArtifactInfoImpl> result;
49 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
50 Assert.assertEquals(new LinkedList<>(), result);
53 artifactDefinition.setUniqueId("mock");
54 list.add(artifactDefinition);
55 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
56 Assert.assertFalse(result.isEmpty());
59 artifactDefinition.setGeneratedFromId("mock");
60 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
61 Assert.assertFalse(result.isEmpty());
65 public void testConvertServiceArtifactToArtifactInfoImpl() throws Exception {
66 Service service = new Service();
67 Collection<ArtifactDefinition> list = new LinkedList<>();
68 ArtifactDefinition artifactDefinition = new ArtifactDefinition();
69 List<ArtifactInfoImpl> result = new LinkedList<>();
72 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
73 Assert.assertEquals(new LinkedList<>(), result);
76 artifactDefinition.setUniqueId("mock");
77 list.add(artifactDefinition);
79 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
80 Assert.assertFalse(result.isEmpty());
83 artifactDefinition.setGeneratedFromId("mock");
85 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
86 Assert.assertFalse(result.isEmpty());
90 public void testGetUpdatedRequiredArtifactsFromNamesToUuids() throws Exception {
91 ArtifactDefinition artifactDefinition = null;
92 Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();
96 artifactDefinition = null;
97 result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids",
98 new Object[] { ArtifactDefinition.class, artifacts.getClass() });
99 Assert.assertEquals(null, result);
102 artifactDefinition = new ArtifactDefinition();
103 result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids",
104 new Object[] { ArtifactDefinition.class, artifacts.getClass() });
105 Assert.assertEquals(null, result);
109 public void testGetArtifactName() throws Exception {
110 ArtifactInfoImpl testSubject;
114 testSubject = createTestSubject();
115 result = testSubject.getArtifactName();
119 public void testSetArtifactName() throws Exception {
120 ArtifactInfoImpl testSubject;
121 String artifactName = "";
124 testSubject = createTestSubject();
125 testSubject.setArtifactName(artifactName);
129 public void testGetArtifactType() throws Exception {
130 ArtifactInfoImpl testSubject;
131 ArtifactTypeEnum result;
134 testSubject = createTestSubject();
135 result = testSubject.getArtifactType();
139 public void testSetArtifactType() throws Exception {
140 ArtifactInfoImpl testSubject;
141 ArtifactTypeEnum artifactType = null;
144 testSubject = createTestSubject();
145 testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL);
149 public void testGetArtifactURL() throws Exception {
150 ArtifactInfoImpl testSubject;
154 testSubject = createTestSubject();
155 result = testSubject.getArtifactURL();
159 public void testSetArtifactURL() throws Exception {
160 ArtifactInfoImpl testSubject;
161 String artifactURL = "";
164 testSubject = createTestSubject();
165 testSubject.setArtifactURL(artifactURL);
169 public void testGetArtifactChecksum() throws Exception {
170 ArtifactInfoImpl testSubject;
174 testSubject = createTestSubject();
175 result = testSubject.getArtifactChecksum();
179 public void testSetArtifactChecksum() throws Exception {
180 ArtifactInfoImpl testSubject;
181 String artifactChecksum = "";
184 testSubject = createTestSubject();
185 testSubject.setArtifactChecksum(artifactChecksum);
189 public void testGetArtifactDescription() throws Exception {
190 ArtifactInfoImpl testSubject;
194 testSubject = createTestSubject();
195 result = testSubject.getArtifactDescription();
199 public void testSetArtifactDescription() throws Exception {
200 ArtifactInfoImpl testSubject;
201 String artifactDescription = "";
204 testSubject = createTestSubject();
205 testSubject.setArtifactDescription(artifactDescription);
209 public void testGetArtifactTimeout() throws Exception {
210 ArtifactInfoImpl testSubject;
214 testSubject = createTestSubject();
215 result = testSubject.getArtifactTimeout();
219 public void testSetArtifactTimeout() throws Exception {
220 ArtifactInfoImpl testSubject;
221 Integer artifactTimeout = 0;
224 testSubject = createTestSubject();
225 testSubject.setArtifactTimeout(artifactTimeout);
229 public void testGetRelatedArtifacts() throws Exception {
230 ArtifactInfoImpl testSubject;
234 testSubject = createTestSubject();
235 result = testSubject.getRelatedArtifacts();
239 public void testSetRelatedArtifacts() throws Exception {
240 ArtifactInfoImpl testSubject;
241 List<String> relatedArtifacts = null;
244 testSubject = createTestSubject();
245 testSubject.setRelatedArtifacts(relatedArtifacts);
249 public void testToString() throws Exception {
250 ArtifactInfoImpl testSubject;
254 testSubject = createTestSubject();
255 result = testSubject.toString();
259 public void testGetArtifactUUID() throws Exception {
260 ArtifactInfoImpl testSubject;
264 testSubject = createTestSubject();
265 result = testSubject.getArtifactUUID();
269 public void testSetArtifactUUID() throws Exception {
270 ArtifactInfoImpl testSubject;
271 String artifactUUID = "";
274 testSubject = createTestSubject();
275 testSubject.setArtifactUUID(artifactUUID);
279 public void testGetArtifactVersion() throws Exception {
280 ArtifactInfoImpl testSubject;
284 testSubject = createTestSubject();
285 result = testSubject.getArtifactVersion();
289 public void testSetArtifactVersion() throws Exception {
290 ArtifactInfoImpl testSubject;
291 String artifactVersion = "";
294 testSubject = createTestSubject();
295 testSubject.setArtifactVersion(artifactVersion);
299 public void testGetGeneratedFromUUID() throws Exception {
300 ArtifactInfoImpl testSubject;
304 testSubject = createTestSubject();
305 result = testSubject.getGeneratedFromUUID();
309 public void testSetGeneratedFromUUID() throws Exception {
310 ArtifactInfoImpl testSubject;
311 String generatedFromUUID = "";
314 testSubject = createTestSubject();
315 testSubject.setGeneratedFromUUID(generatedFromUUID);
319 public void testUpdateArtifactTimeout() throws Exception {
320 ArtifactInfoImpl testSubject;
323 testSubject = createTestSubject();
324 testSubject.updateArtifactTimeout();