Added oparent to sdc main
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / distribution / engine / ArtifactInfoImplTest.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.components.distribution.engine;
22
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;
31
32 import java.util.*;
33
34 public class ArtifactInfoImplTest extends BeConfDependentTest {
35
36         private ArtifactInfoImpl createTestSubject() {
37                 return new ArtifactInfoImpl();
38         }
39
40         @Test
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;
47
48                 // test 1
49                 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
50                 Assert.assertEquals(new LinkedList<>(), result);
51
52                 // test 2
53                 artifactDefinition.setUniqueId("mock");
54                 list.add(artifactDefinition);
55                 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
56                 Assert.assertFalse(result.isEmpty());
57
58                 // test 3
59                 artifactDefinition.setGeneratedFromId("mock");
60                 result = ArtifactInfoImpl.convertToArtifactInfoImpl(service, resourceInstance, list);
61                 Assert.assertFalse(result.isEmpty());
62         }
63
64         @Test
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<>();
70
71                 // test 1
72                 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
73                 Assert.assertEquals(new LinkedList<>(), result);
74
75                 // test 2
76                 artifactDefinition.setUniqueId("mock");
77                 list.add(artifactDefinition);
78
79                 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
80                 Assert.assertFalse(result.isEmpty());
81
82                 // test 3
83                 artifactDefinition.setGeneratedFromId("mock");
84
85                 result = ArtifactInfoImpl.convertServiceArtifactToArtifactInfoImpl(service, list);
86                 Assert.assertFalse(result.isEmpty());
87         }
88
89         @Test
90         public void testGetUpdatedRequiredArtifactsFromNamesToUuids() throws Exception {
91                 ArtifactDefinition artifactDefinition = null;
92                 Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();
93                 List<String> result;
94
95                 // test 1
96                 artifactDefinition = null;
97                 result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids",
98                                 new Object[] { ArtifactDefinition.class, artifacts.getClass() });
99                 Assert.assertEquals(null, result);
100
101                 // test 2
102                 artifactDefinition = new ArtifactDefinition();
103                 result = Deencapsulation.invoke(ArtifactInfoImpl.class, "getUpdatedRequiredArtifactsFromNamesToUuids",
104                                 new Object[] { ArtifactDefinition.class, artifacts.getClass() });
105                 Assert.assertEquals(null, result);
106         }
107
108         @Test
109         public void testGetArtifactName() throws Exception {
110                 ArtifactInfoImpl testSubject;
111                 String result;
112
113                 // default test
114                 testSubject = createTestSubject();
115                 result = testSubject.getArtifactName();
116         }
117
118         @Test
119         public void testSetArtifactName() throws Exception {
120                 ArtifactInfoImpl testSubject;
121                 String artifactName = "";
122
123                 // default test
124                 testSubject = createTestSubject();
125                 testSubject.setArtifactName(artifactName);
126         }
127
128         @Test
129         public void testGetArtifactType() throws Exception {
130                 ArtifactInfoImpl testSubject;
131                 ArtifactTypeEnum result;
132
133                 // default test
134                 testSubject = createTestSubject();
135                 result = testSubject.getArtifactType();
136         }
137
138         @Test
139         public void testSetArtifactType() throws Exception {
140                 ArtifactInfoImpl testSubject;
141                 ArtifactTypeEnum artifactType = null;
142
143                 // default test
144                 testSubject = createTestSubject();
145                 testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL);
146         }
147
148         @Test
149         public void testGetArtifactURL() throws Exception {
150                 ArtifactInfoImpl testSubject;
151                 String result;
152
153                 // default test
154                 testSubject = createTestSubject();
155                 result = testSubject.getArtifactURL();
156         }
157
158         @Test
159         public void testSetArtifactURL() throws Exception {
160                 ArtifactInfoImpl testSubject;
161                 String artifactURL = "";
162
163                 // default test
164                 testSubject = createTestSubject();
165                 testSubject.setArtifactURL(artifactURL);
166         }
167
168         @Test
169         public void testGetArtifactChecksum() throws Exception {
170                 ArtifactInfoImpl testSubject;
171                 String result;
172
173                 // default test
174                 testSubject = createTestSubject();
175                 result = testSubject.getArtifactChecksum();
176         }
177
178         @Test
179         public void testSetArtifactChecksum() throws Exception {
180                 ArtifactInfoImpl testSubject;
181                 String artifactChecksum = "";
182
183                 // default test
184                 testSubject = createTestSubject();
185                 testSubject.setArtifactChecksum(artifactChecksum);
186         }
187
188         @Test
189         public void testGetArtifactDescription() throws Exception {
190                 ArtifactInfoImpl testSubject;
191                 String result;
192
193                 // default test
194                 testSubject = createTestSubject();
195                 result = testSubject.getArtifactDescription();
196         }
197
198         @Test
199         public void testSetArtifactDescription() throws Exception {
200                 ArtifactInfoImpl testSubject;
201                 String artifactDescription = "";
202
203                 // default test
204                 testSubject = createTestSubject();
205                 testSubject.setArtifactDescription(artifactDescription);
206         }
207
208         @Test
209         public void testGetArtifactTimeout() throws Exception {
210                 ArtifactInfoImpl testSubject;
211                 Integer result;
212
213                 // default test
214                 testSubject = createTestSubject();
215                 result = testSubject.getArtifactTimeout();
216         }
217
218         @Test
219         public void testSetArtifactTimeout() throws Exception {
220                 ArtifactInfoImpl testSubject;
221                 Integer artifactTimeout = 0;
222
223                 // default test
224                 testSubject = createTestSubject();
225                 testSubject.setArtifactTimeout(artifactTimeout);
226         }
227
228         @Test
229         public void testGetRelatedArtifacts() throws Exception {
230                 ArtifactInfoImpl testSubject;
231                 List<String> result;
232
233                 // default test
234                 testSubject = createTestSubject();
235                 result = testSubject.getRelatedArtifacts();
236         }
237
238         @Test
239         public void testSetRelatedArtifacts() throws Exception {
240                 ArtifactInfoImpl testSubject;
241                 List<String> relatedArtifacts = null;
242
243                 // default test
244                 testSubject = createTestSubject();
245                 testSubject.setRelatedArtifacts(relatedArtifacts);
246         }
247
248         @Test
249         public void testToString() throws Exception {
250                 ArtifactInfoImpl testSubject;
251                 String result;
252
253                 // default test
254                 testSubject = createTestSubject();
255                 result = testSubject.toString();
256         }
257
258         @Test
259         public void testGetArtifactUUID() throws Exception {
260                 ArtifactInfoImpl testSubject;
261                 String result;
262
263                 // default test
264                 testSubject = createTestSubject();
265                 result = testSubject.getArtifactUUID();
266         }
267
268         @Test
269         public void testSetArtifactUUID() throws Exception {
270                 ArtifactInfoImpl testSubject;
271                 String artifactUUID = "";
272
273                 // default test
274                 testSubject = createTestSubject();
275                 testSubject.setArtifactUUID(artifactUUID);
276         }
277
278         @Test
279         public void testGetArtifactVersion() throws Exception {
280                 ArtifactInfoImpl testSubject;
281                 String result;
282
283                 // default test
284                 testSubject = createTestSubject();
285                 result = testSubject.getArtifactVersion();
286         }
287
288         @Test
289         public void testSetArtifactVersion() throws Exception {
290                 ArtifactInfoImpl testSubject;
291                 String artifactVersion = "";
292
293                 // default test
294                 testSubject = createTestSubject();
295                 testSubject.setArtifactVersion(artifactVersion);
296         }
297
298         @Test
299         public void testGetGeneratedFromUUID() throws Exception {
300                 ArtifactInfoImpl testSubject;
301                 String result;
302
303                 // default test
304                 testSubject = createTestSubject();
305                 result = testSubject.getGeneratedFromUUID();
306         }
307
308         @Test
309         public void testSetGeneratedFromUUID() throws Exception {
310                 ArtifactInfoImpl testSubject;
311                 String generatedFromUUID = "";
312
313                 // default test
314                 testSubject = createTestSubject();
315                 testSubject.setGeneratedFromUUID(generatedFromUUID);
316         }
317
318         @Test
319         public void testUpdateArtifactTimeout() throws Exception {
320                 ArtifactInfoImpl testSubject;
321
322                 // default test
323                 testSubject = createTestSubject();
324                 testSubject.updateArtifactTimeout();
325         }
326 }