Upgrade SDC from Titan to Janus Graph
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / tosca / CsarUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 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.tosca;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.io.IOException;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Map;
31 import java.util.Map.Entry;
32 import java.util.Set;
33 import java.util.zip.ZipEntry;
34 import java.util.zip.ZipOutputStream;
35
36 import org.apache.commons.io.output.ByteArrayOutputStream;
37 import org.apache.commons.lang3.tuple.ImmutablePair;
38 import org.apache.commons.lang3.tuple.ImmutableTriple;
39 import org.apache.commons.lang3.tuple.Triple;
40 import org.junit.Before;
41 import org.junit.Test;
42 import org.mockito.InjectMocks;
43 import org.mockito.Mock;
44 import org.mockito.Mockito;
45 import org.mockito.MockitoAnnotations;
46 import org.openecomp.sdc.be.components.BeConfDependentTest;
47 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
48 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
49 import org.openecomp.sdc.be.dao.api.ActionStatus;
50 import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
51 import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
52 import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
53 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
54 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
55 import org.openecomp.sdc.be.impl.ComponentsUtils;
56 import org.openecomp.sdc.be.model.ArtifactDefinition;
57 import org.openecomp.sdc.be.model.Component;
58 import org.openecomp.sdc.be.model.ComponentInstance;
59 import org.openecomp.sdc.be.model.LifecycleStateEnum;
60 import org.openecomp.sdc.be.model.Resource;
61 import org.openecomp.sdc.be.model.Service;
62 import org.openecomp.sdc.be.model.User;
63 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
64 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
65 import org.openecomp.sdc.be.resources.data.ESArtifactData;
66 import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
67 import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
68 import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
69 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
70 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
71
72 import fj.data.Either;
73 import mockit.Deencapsulation;
74
75 public class CsarUtilsTest extends BeConfDependentTest {
76
77         @InjectMocks
78         CsarUtils testSubject;
79
80         @Mock
81         private ArtifactCassandraDao artifactCassandraDao;
82
83         @Mock
84         private ComponentsUtils componentsUtils;
85
86         @Mock
87         private ToscaExportHandler toscaExportUtils;
88
89         @Mock
90         private SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao;
91
92         @Mock
93         private ToscaOperationFacade toscaOperationFacade;
94
95         @Mock
96         private ArtifactsBusinessLogic artifactsBusinessLogic;
97
98         @Before
99         public void setUpMock() throws Exception {
100                 MockitoAnnotations.initMocks(this);
101                 
102         }
103
104         private NonMetaArtifactInfo createNonMetaArtifactInfoTestSubject() {
105                 return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL,
106                                 ArtifactGroupTypeEnum.DEPLOYMENT, new byte[0], "mock", true);
107         }
108
109         @Test
110         public void testCreateCsar() {
111                 Component component = new Resource();
112                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
113                 ArtifactDefinition artifact = new ArtifactDefinition();
114                 artifact.setArtifactName("artifactName");
115                 artifact.setEsId("esId");
116                 toscaArtifacts.put("assettoscatemplate", artifact);
117
118                 component.setToscaArtifacts(toscaArtifacts);
119
120                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class)))
121                                 .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
122
123                 Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class)))
124                                 .thenReturn(ActionStatus.GENERAL_ERROR);
125
126                 testSubject.createCsar(component, true, true);
127         }
128
129         @Test
130         public void testCreateCsarWithGenerateCsarZipResponseIsLeft() {
131                 Component component = new Resource();
132                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
133                 ArtifactDefinition artifact = new ArtifactDefinition();
134                 artifact.setArtifactName("artifactName");
135                 artifact.setEsId("esId");
136                 artifact.setArtifactUUID("artifactUUID");
137                 artifact.setArtifactType("YANG");
138                 toscaArtifacts.put("assettoscatemplate", artifact);
139
140                 component.setToscaArtifacts(toscaArtifacts);
141                 component.setDeploymentArtifacts(toscaArtifacts);
142                 component.setArtifacts(toscaArtifacts);
143                 ESArtifactData artifactData = new ESArtifactData();
144                 byte[] data = "value".getBytes();
145                 artifactData.setDataAsArray(data);
146
147                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
148                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
149                 toscaTemplate.setDependencies(dependencies);
150
151                 List<SdcSchemaFilesData> filesData = new ArrayList<>();
152                 SdcSchemaFilesData filedata = new SdcSchemaFilesData();
153                 filedata.setPayloadAsArray(data);
154                 filesData.add(filedata);
155
156                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
157
158                 Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class)))
159                                 .thenReturn(ActionStatus.GENERAL_ERROR);
160
161                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
162                                 .thenReturn(Either.left(toscaTemplate));
163
164                 Mockito.when(
165                                 sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
166                                 .thenReturn(Either.left(filesData));
167
168                 testSubject.createCsar(component, false, true);
169         }
170
171         @Test
172         public void testGenerateCsarZipThrowsIOException() {
173
174                 Deencapsulation.invoke(testSubject, "generateCsarZip", new byte[]{},new  byte[]{}, new Resource(), true, false);
175         }
176
177         @Test
178         public void testPopulateZipWhenGetDependenciesIsRight() {
179                 Component component = new Service();
180                 boolean getFromCS = false;
181
182                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
183                 ArtifactDefinition artifact = new ArtifactDefinition();
184                 artifact.setArtifactName("artifactName");
185                 artifact.setEsId("esId");
186                 artifact.setArtifactUUID("artifactUUID");
187                 artifact.setArtifactType("YANG");
188                 toscaArtifacts.put("assettoscatemplate", artifact);
189
190                 component.setToscaArtifacts(toscaArtifacts);
191                 component.setDeploymentArtifacts(toscaArtifacts);
192                 component.setArtifacts(toscaArtifacts);
193                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
194                 ESArtifactData artifactData = new ESArtifactData();
195                 byte[] data = "value".getBytes();
196                 artifactData.setDataAsArray(data);
197
198                 ToscaRepresentation tosca = new ToscaRepresentation();
199                 tosca.setMainYaml("value");
200
201                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
202
203                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
204
205                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
206                                 .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
207
208                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
209                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, false);
210                 } catch (Exception e) {
211                         e.printStackTrace();
212                 }
213         }
214
215         @Test
216         public void testPopulateZipWhenExportComponentIsRight() {
217                 Component component = new Resource();
218                 boolean getFromCS = false;
219
220                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
221                 ArtifactDefinition artifact = new ArtifactDefinition();
222                 artifact.setArtifactName("artifactName");
223                 artifact.setEsId("esId");
224                 artifact.setArtifactUUID("artifactUUID");
225                 artifact.setArtifactType("YANG");
226                 toscaArtifacts.put("assettoscatemplate", artifact);
227
228                 component.setToscaArtifacts(toscaArtifacts);
229                 component.setDeploymentArtifacts(toscaArtifacts);
230                 component.setArtifacts(toscaArtifacts);
231                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
232                 ESArtifactData artifactData = new ESArtifactData();
233                 byte[] data = "value".getBytes();
234                 artifactData.setDataAsArray(data);
235
236                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class)))
237                                 .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
238
239                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
240                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, false);
241                 } catch (Exception e) {
242                         e.printStackTrace();
243                 }
244         }
245
246         @Test
247         public void testPopulateZipWhenComponentIsServiceAndCollectComponentCsarDefinitionIsRight() {
248                 Component component = new Service();
249                 boolean getFromCS = false;
250
251                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
252                 ArtifactDefinition artifact = new ArtifactDefinition();
253                 artifact.setArtifactName("artifactName");
254                 artifact.setEsId("esId");
255                 artifact.setArtifactUUID("artifactUUID");
256                 artifact.setArtifactType("YANG");
257                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
258                 artifact.setDescription("description");
259                 artifact.setArtifactLabel("artifactLabel");
260                 toscaArtifacts.put("assettoscatemplate", artifact);
261
262                 component.setToscaArtifacts(toscaArtifacts);
263                 component.setDeploymentArtifacts(toscaArtifacts);
264                 component.setArtifacts(toscaArtifacts);
265                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
266                 component.setVersion("1.0");
267                 component.setLastUpdaterUserId("userId");
268                 component.setUniqueId("uid");
269                 ESArtifactData artifactData = new ESArtifactData();
270                 byte[] data = "value".getBytes();
271                 artifactData.setDataAsArray(data);
272
273                 List<SdcSchemaFilesData> filesData = new ArrayList<>();
274                 SdcSchemaFilesData filedata = new SdcSchemaFilesData();
275                 filedata.setPayloadAsArray(data);
276                 filesData.add(filedata);
277
278                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
279                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
280                 Triple<String, String, Component> triple = Triple.of("fileName", "cassandraId", component);
281                 dependencies.add(triple);
282                 toscaTemplate.setDependencies(dependencies);
283
284                 ToscaRepresentation tosca = new ToscaRepresentation();
285                 tosca.setMainYaml("value");
286
287                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
288
289                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
290
291                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
292                                 .thenReturn(Either.left(toscaTemplate));
293
294                 Mockito.when(
295                                 sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
296                                 .thenReturn(Either.left(filesData));
297
298                 Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
299                                 .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
300
301                 Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(String.class), Mockito.any(String.class),
302                                 Mockito.any(Boolean.class))).thenReturn(new User());
303
304                 Mockito.when(artifactsBusinessLogic.validateAndHandleArtifact(Mockito.any(String.class),
305                                 Mockito.any(ComponentTypeEnum.class), Mockito.any(ArtifactOperationInfo.class), Mockito.isNull(),
306                                 Mockito.any(ArtifactDefinition.class), Mockito.any(String.class), Mockito.any(String.class),
307                                 Mockito.isNull(), Mockito.isNull(), Mockito.any(User.class), Mockito.any(Component.class),
308                                 Mockito.any(Boolean.class), Mockito.any(Boolean.class), Mockito.any(Boolean.class)))
309                                 .thenReturn(Either.left(Mockito.any(Either.class)));
310
311                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
312                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true);
313                 } catch (Exception e) {
314                         e.printStackTrace();
315                 }
316         }
317
318         @Test
319         public void testPopulateZipWhenGetEntryDataIsRight() {
320                 Component component = new Service();
321                 boolean getFromCS = true;
322
323                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
324                 ArtifactDefinition artifact = new ArtifactDefinition();
325                 artifact.setArtifactName("artifactName");
326                 artifact.setEsId("esId");
327                 artifact.setArtifactUUID("artifactUUID");
328                 artifact.setArtifactType("YANG");
329                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
330                 artifact.setDescription("description");
331                 artifact.setArtifactLabel("artifactLabel");
332                 toscaArtifacts.put("assettoscatemplate", artifact);
333
334                 component.setToscaArtifacts(toscaArtifacts);
335                 component.setDeploymentArtifacts(toscaArtifacts);
336                 component.setArtifacts(toscaArtifacts);
337                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
338                 component.setVersion("1.0");
339                 component.setLastUpdaterUserId("userId");
340                 component.setUniqueId("uid");
341                 ESArtifactData artifactData = new ESArtifactData();
342                 byte[] data = "value".getBytes();
343                 artifactData.setDataAsArray(data);
344
345                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
346                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
347                 Triple<String, String, Component> triple = Triple.of("fileName", "", component);
348                 dependencies.add(triple);
349                 toscaTemplate.setDependencies(dependencies);
350
351                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
352
353                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class)))
354                                 .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
355
356                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
357                                 .thenReturn(Either.left(toscaTemplate));
358
359                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
360                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true);
361                 } catch (Exception e) {
362                         e.printStackTrace();
363                 }
364         }
365
366         @Test
367         public void testPopulateZipWhenGetEntryDataOfInnerComponentIsRight() {
368                 Component component = new Service();
369                 boolean getFromCS = false;
370
371                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
372                 ArtifactDefinition artifact = new ArtifactDefinition();
373                 artifact.setArtifactName("artifactName");
374                 artifact.setEsId("esId");
375                 artifact.setArtifactUUID("artifactUUID");
376                 artifact.setArtifactType("YANG");
377                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
378                 artifact.setDescription("description");
379                 artifact.setArtifactLabel("artifactLabel");
380                 toscaArtifacts.put("assettoscatemplate", artifact);
381
382                 component.setToscaArtifacts(toscaArtifacts);
383                 component.setDeploymentArtifacts(toscaArtifacts);
384                 component.setArtifacts(toscaArtifacts);
385                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
386                 component.setVersion("1.0");
387                 component.setLastUpdaterUserId("userId");
388                 component.setUniqueId("uid");
389                 ESArtifactData artifactData = new ESArtifactData();
390                 byte[] data = "value".getBytes();
391                 artifactData.setDataAsArray(data);
392
393                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
394                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
395                 Triple<String, String, Component> triple = Triple.of("fileName", "", component);
396                 dependencies.add(triple);
397                 toscaTemplate.setDependencies(dependencies);
398
399                 ToscaRepresentation tosca = new ToscaRepresentation();
400                 tosca.setMainYaml("value");
401
402                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
403
404                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca),
405                                 Either.left(tosca), Either.right(ToscaError.GENERAL_ERROR));
406
407                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
408                                 .thenReturn(Either.left(toscaTemplate));
409
410                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
411                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true);
412                 } catch (Exception e) {
413                         e.printStackTrace();
414                 }
415         }
416
417         @Test
418         public void testPopulateZipWhenLatestSchemaFilesFromCassandraIsRight() {
419                 Component component = new Service();
420                 boolean getFromCS = false;
421
422                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
423                 ArtifactDefinition artifact = new ArtifactDefinition();
424                 artifact.setArtifactName("artifactName");
425                 artifact.setEsId("esId");
426                 artifact.setArtifactUUID("artifactUUID");
427                 artifact.setArtifactType("YANG");
428                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
429                 artifact.setDescription("description");
430                 artifact.setArtifactLabel("artifactLabel");
431                 toscaArtifacts.put("assettoscatemplate", artifact);
432
433                 component.setToscaArtifacts(toscaArtifacts);
434                 component.setDeploymentArtifacts(toscaArtifacts);
435                 component.setArtifacts(toscaArtifacts);
436                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
437                 component.setVersion("1.0");
438                 component.setLastUpdaterUserId("userId");
439                 component.setUniqueId("uid");
440                 ESArtifactData artifactData = new ESArtifactData();
441                 byte[] data = "value".getBytes();
442                 artifactData.setDataAsArray(data);
443
444                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
445                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
446                 Triple<String, String, Component> triple = Triple.of("fileName", "", component);
447                 dependencies.add(triple);
448                 toscaTemplate.setDependencies(dependencies);
449
450                 ToscaRepresentation tosca = new ToscaRepresentation();
451                 tosca.setMainYaml("value");
452
453                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
454
455                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
456
457                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
458                                 .thenReturn(Either.left(toscaTemplate));
459
460                 Mockito.when(
461                                 sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
462                                 .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
463
464                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
465                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true);
466                 } catch (Exception e) {
467                         e.printStackTrace();
468                 }
469         }
470
471         @Test
472         public void testPopulateZipWhenAddSchemaFilesFromCassandraIsRight() {
473                 Component component = new Service();
474                 boolean getFromCS = false;
475
476                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
477                 ArtifactDefinition artifact = new ArtifactDefinition();
478                 artifact.setArtifactName("artifactName");
479                 artifact.setEsId("esId");
480                 artifact.setArtifactUUID("artifactUUID");
481                 artifact.setArtifactType("YANG");
482                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
483                 artifact.setDescription("description");
484                 artifact.setArtifactLabel("artifactLabel");
485                 toscaArtifacts.put("assettoscatemplate", artifact);
486
487                 component.setToscaArtifacts(toscaArtifacts);
488                 component.setDeploymentArtifacts(toscaArtifacts);
489                 component.setArtifacts(toscaArtifacts);
490                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
491                 component.setVersion("1.0");
492                 component.setLastUpdaterUserId("userId");
493                 component.setUniqueId("uid");
494                 ESArtifactData artifactData = new ESArtifactData();
495                 byte[] data = "value".getBytes();
496                 artifactData.setDataAsArray(data);
497
498                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
499                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
500                 Triple<String, String, Component> triple = Triple.of("fileName", "", component);
501                 dependencies.add(triple);
502                 toscaTemplate.setDependencies(dependencies);
503
504                 ToscaRepresentation tosca = new ToscaRepresentation();
505                 tosca.setMainYaml("value");
506
507                 List<SdcSchemaFilesData> schemaList = new ArrayList<>();
508                 SdcSchemaFilesData schemaData = new SdcSchemaFilesData();
509                 schemaData.setPayloadAsArray(null);
510                 schemaList.add(schemaData);
511
512                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
513
514                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
515
516                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
517                                 .thenReturn(Either.left(toscaTemplate));
518
519                 Mockito.when(
520                                 sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
521                                 .thenReturn(Either.left(schemaList));
522
523                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
524                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true);
525                 } catch (Exception e) {
526                         e.printStackTrace();
527                 }
528         }
529
530         @Test
531         public void testPopulateZipWhenHandleAllAAIArtifactsInDataModelIsRight() {
532                 Component component = new Service();
533                 boolean getFromCS = false;
534
535                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
536                 ArtifactDefinition artifact = new ArtifactDefinition();
537                 artifact.setArtifactName("artifactName");
538                 artifact.setEsId("esId");
539                 artifact.setArtifactUUID("artifactUUID");
540                 artifact.setArtifactType("YANG");
541                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
542                 artifact.setDescription("description");
543                 artifact.setArtifactLabel("artifactLabel");
544                 toscaArtifacts.put("assettoscatemplate", artifact);
545
546                 component.setToscaArtifacts(toscaArtifacts);
547                 component.setDeploymentArtifacts(toscaArtifacts);
548                 component.setArtifacts(toscaArtifacts);
549                 component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
550                 component.setVersion("1.0");
551                 component.setLastUpdaterUserId("userId");
552                 component.setUniqueId("uid");
553                 ESArtifactData artifactData = new ESArtifactData();
554                 byte[] data = "value".getBytes();
555                 artifactData.setDataAsArray(data);
556
557                 ToscaTemplate toscaTemplate = new ToscaTemplate("version");
558                 List<Triple<String, String, Component>> dependencies = new ArrayList<>();
559                 Triple<String, String, Component> triple = Triple.of("fileName", "", component);
560                 dependencies.add(triple);
561                 toscaTemplate.setDependencies(dependencies);
562
563                 ToscaRepresentation tosca = new ToscaRepresentation();
564                 tosca.setMainYaml("value");
565
566                 List<SdcSchemaFilesData> schemaList = new ArrayList<>();
567                 SdcSchemaFilesData schemaData = new SdcSchemaFilesData();
568                 schemaData.setPayloadAsArray(data);
569                 schemaList.add(schemaData);
570
571                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
572
573                 Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
574
575                 Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
576                                 .thenReturn(Either.left(toscaTemplate));
577
578                 Mockito.when(
579                                 sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
580                                 .thenReturn(Either.left(schemaList));
581
582                 Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(String.class), Mockito.any(String.class),
583                                 Mockito.any(Boolean.class))).thenReturn(new User());
584
585                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
586                         Deencapsulation.invoke(testSubject, "populateZip", component, getFromCS, zip, true);
587                 } catch (Exception e) {
588                         e.printStackTrace();
589                 }
590         }
591
592         @Test
593         public void testAddSchemaFilesFromCassandra() {
594                 try (ByteArrayOutputStream out = new ByteArrayOutputStream();
595                                 ZipOutputStream zip = new ZipOutputStream(out);
596                                 ByteArrayOutputStream outMockStream = new ByteArrayOutputStream();
597                                 ZipOutputStream outMock = new ZipOutputStream(outMockStream);) {
598
599                         outMock.putNextEntry(new ZipEntry("mock1"));
600                         outMock.write(new byte[1]);
601                         outMock.putNextEntry(new ZipEntry("mock2"));
602                         outMock.write(new byte[3]);
603                         outMock.close();
604                         byte[] byteArray = outMockStream.toByteArray();
605                         Deencapsulation.invoke(testSubject, "addSchemaFilesFromCassandra", zip, byteArray);
606                 } catch (Exception e) {
607                         e.printStackTrace();
608                 }
609
610         }
611
612         @Test
613         public void testAddInnerComponentsToCache() {
614                 Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>();
615                 Component childComponent = new Resource();
616                 Component componentRI = new Service();
617                 List<ComponentInstance> componentInstances = new ArrayList<>();
618                 ComponentInstance instance = new ComponentInstance();
619                 instance.setComponentUid("resourceUid");
620                 componentInstances.add(instance);
621                 childComponent.setComponentInstances(componentInstances);
622
623                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
624                 ArtifactDefinition artifact = new ArtifactDefinition();
625                 artifact.setArtifactName("artifactName");
626                 artifact.setEsId("esId");
627                 artifact.setArtifactUUID("artifactUUID");
628                 artifact.setArtifactType("YANG");
629                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
630                 artifact.setDescription("description");
631                 artifact.setArtifactLabel("artifactLabel");
632                 toscaArtifacts.put("assettoscatemplate", artifact);
633
634                 componentRI.setToscaArtifacts(toscaArtifacts);
635
636                 Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
637                                 .thenReturn(Either.left(componentRI));
638
639                 Deencapsulation.invoke(testSubject, "addInnerComponentsToCache", componentCache, childComponent);
640         }
641
642         @Test
643         public void testAddInnerComponentsToCacheWhenGetToscaElementIsRight() {
644                 Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>();
645                 Component childComponent = new Resource();
646
647                 List<ComponentInstance> componentInstances = new ArrayList<>();
648                 ComponentInstance instance = new ComponentInstance();
649                 componentInstances.add(instance);
650                 childComponent.setComponentInstances(componentInstances);
651
652                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
653                 ArtifactDefinition artifact = new ArtifactDefinition();
654                 artifact.setArtifactName("artifactName");
655                 artifact.setEsId("esId");
656                 artifact.setArtifactUUID("artifactUUID");
657                 artifact.setArtifactType("YANG");
658                 artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
659                 artifact.setDescription("description");
660                 artifact.setArtifactLabel("artifactLabel");
661                 toscaArtifacts.put("assettoscatemplate", artifact);
662
663                 Component componentRI = new Service();
664
665                 componentRI.setToscaArtifacts(toscaArtifacts);
666
667                 Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
668                                 .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
669
670                 Deencapsulation.invoke(testSubject, "addInnerComponentsToCache", componentCache, childComponent);
671         }
672
673         @Test
674         public void testAddComponentToCache() {
675                 Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>();
676                 String id = "id";
677                 String fileName = "fileName";
678                 Component component = new Resource();
679                 component.setInvariantUUID("key");
680                 component.setVersion("1.0");
681
682                 Component cachedComponent = new Resource();
683                 cachedComponent.setVersion("0.3");
684
685                 componentCache.put("key", new ImmutableTriple<String, String, Component>(id, fileName, cachedComponent));
686
687                 Deencapsulation.invoke(testSubject, "addComponentToCache", componentCache, id, fileName, component);
688         }
689
690         @Test
691         public void testWriteComponentInterface() {
692                 String fileName = "name.hello";
693                 ToscaRepresentation tosca = new ToscaRepresentation();
694                 tosca.setMainYaml("value");
695
696                 Mockito.when(toscaExportUtils.exportComponentInterface(Mockito.any(Component.class), Mockito.any(Boolean.class)))
697                                 .thenReturn(Either.left(tosca));
698
699                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
700                         Deencapsulation.invoke(testSubject, "writeComponentInterface", new Resource(), zip, fileName, false);
701                 } catch (IOException e) {
702                         e.printStackTrace();
703                 }
704
705         }
706
707         @Test
708         public void testGetEntryData() {
709                 String cassandraId = "id";
710                 Component childComponent = new Resource();
711
712                 Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class)))
713                                 .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
714
715                 Deencapsulation.invoke(testSubject, "getEntryData", cassandraId, childComponent);
716         }
717
718         @Test
719         public void testGetLatestSchemaFilesFromCassandraWhenListOfSchemasIsEmpty() {
720                 List<SdcSchemaFilesData> filesData = new ArrayList<>();
721
722                 Mockito.when(
723                                 sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
724                                 .thenReturn(Either.left(filesData));
725                 Deencapsulation.invoke(testSubject, "getLatestSchemaFilesFromCassandra");
726         }
727
728         @Test
729         public void testExtractVfcsArtifactsFromCsar() {
730                 String key = "Artifacts/org.openecomp.resource.some/path/to/resource";
731                 byte[] data = "value".getBytes();
732
733                 Map<String, byte[]> csar = new HashMap<>();
734                 csar.put(key, data);
735
736                 CsarUtils.extractVfcsArtifactsFromCsar(csar);
737         }
738
739         @Test
740         public void testAddExtractedVfcArtifactWhenArtifactsContainsExtractedArtifactKey() {
741                 ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>(
742                                 "key", new ArtifactDefinition());
743                 Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>();
744                 artifacts.put("key", new ArrayList<>());
745
746                 Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts);
747         }
748
749         @Test
750         public void testAddExtractedVfcArtifactWhenArtifactsDoesntContainsExtractedArtifactKey() {
751                 ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>(
752                                 "key", new ArtifactDefinition());
753                 Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>();
754                 artifacts.put("key1", new ArrayList<>());
755
756                 Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts);
757         }
758
759         @Test
760         public void testExtractVfcArtifact() {
761                 String path = "path/to/informational/artificat";
762                 Map<String, byte[]> map = new HashMap<>();
763                 map.put(path, "value".getBytes());
764                 Entry<String, byte[]> entry = map.entrySet().iterator().next();
765
766                 Deencapsulation.invoke(testSubject, "extractVfcArtifact", entry, new HashMap<>());
767         }
768
769         @Test
770         public void testDetectArtifactGroupTypeWithExceptionBeingCaught() {
771                 Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", Map.class);
772         }
773
774         @Test
775         public void testDetectArtifactGroupTypeWWhenCollectedWarningMessagesContainesKey() {
776                 Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
777
778                 collectedWarningMessages.put("Warning - unrecognized artifact group type {} was received.", new HashSet<>());
779                 Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", collectedWarningMessages);
780         }
781
782         @Test
783         public void testNonMetaArtifactInfoCtor() {
784                 createNonMetaArtifactInfoTestSubject();
785         }
786
787         @Test
788         public void testNonMetaArtifactInfoGetPath() {
789                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
790
791                 testSubject.getPath();
792         }
793
794         @Test
795         public void testNonMetaArtifactInfoGetArtifactName() {
796                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
797
798                 testSubject.getArtifactName();
799         }
800
801         @Test
802         public void testNonMetaArtifactInfoGetArtifactType() {
803                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
804
805                 testSubject.getArtifactType();
806         }
807
808         @Test
809         public void testNonMetaArtifactInfoGetDisplayName() {
810                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
811
812                 testSubject.getDisplayName();
813         }
814
815         @Test
816         public void testNonMetaArtifactInfoGetArtifactGroupType() {
817                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
818
819                 testSubject.getArtifactGroupType();
820         }
821
822         @Test
823         public void testNonMetaArtifactInfoGetArtifactLabel() {
824                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
825
826                 testSubject.getArtifactLabel();
827         }
828
829         @Test
830         public void testNonMetaArtifactInfoGetIsFromCsar() {
831                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
832
833                 testSubject.isFromCsar();
834         }
835
836         @Test
837         public void testNonMetaArtifactInfoGetPayloadData() {
838                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
839
840                 testSubject.getPayloadData();
841         }
842
843         @Test
844         public void testNonMetaArtifactInfoGetArtifaactChecksum() {
845                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
846
847                 testSubject.getArtifactChecksum();
848         }
849
850         @Test
851         public void testNonMetaArtifactInfoGetArtifactUniqueId() {
852                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
853
854                 testSubject.getArtifactUniqueId();
855         }
856
857         @Test
858         public void testNonMetaArtifactInfosetArtifactUniqueId() {
859                 NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject();
860
861                 testSubject.setArtifactUniqueId("artifactUniqueId");
862         }
863
864         @Test
865         public void testValidateNonMetaArtifactWithExceptionCaught() {
866                 CsarUtils.validateNonMetaArtifact("", new byte[0], new HashMap<>());
867         }
868
869         @Test
870         public void testWriteArtifactDefinition() {
871                 Component component = new Service();
872                 List<ArtifactDefinition> artifactDefinitionList = new ArrayList<>();
873                 String artifactPathAndFolder = "";
874
875                 ArtifactDefinition artifact = new ArtifactDefinition();
876                 artifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.getType());
877                 artifactDefinitionList.add(artifact);
878
879                 try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
880                         Deencapsulation.invoke(testSubject, "writeArtifactDefinition", component, zip, artifactDefinitionList,
881                                         artifactPathAndFolder, false);
882                 } catch (Exception e) {
883                         e.printStackTrace();
884                 }
885         }
886
887         @Test
888         public void testCollectComponentCsarDefinitionWhenComponentIsServiceAndGetToscaElementIsLeft() {
889                 Component component = new Service();
890                 component.setUniqueId("uniqueId");
891                 List<ComponentInstance> resourceInstances = new ArrayList<>();
892                 ComponentInstance instance = new ComponentInstance();
893                 instance.setComponentUid("resourceUid");
894                 instance.setOriginType(OriginTypeEnum.SERVICE);
895                 resourceInstances.add(instance);
896                 component.setComponentInstances(resourceInstances);
897
898                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
899                 ArtifactDefinition artifact = new ArtifactDefinition();
900                 artifact.setArtifactName("artifactName");
901                 artifact.setEsId("esId");
902                 artifact.setArtifactUUID("artifactUUID");
903                 artifact.setArtifactType("YANG");
904                 toscaArtifacts.put("assettoscatemplate", artifact);
905
906                 component.setToscaArtifacts(toscaArtifacts);
907                 component.setDeploymentArtifacts(toscaArtifacts);
908                 component.setArtifacts(toscaArtifacts);
909
910                 Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
911                                 Either.right(StorageOperationStatus.BAD_REQUEST));
912
913                 Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
914
915         }
916
917         @Test
918         public void testCollectComponentTypeArtifactsWhenFetchedComponentHasComponentInstances() {
919                 Component component = new Service();
920                 Component fetchedComponent = new Resource();
921                 component.setUniqueId("uniqueId");
922                 List<ComponentInstance> resourceInstances = new ArrayList<>();
923                 ComponentInstance instance = new ComponentInstance();
924                 instance.setComponentUid("resourceUid");
925                 instance.setOriginType(OriginTypeEnum.SERVICE);
926                 resourceInstances.add(instance);
927                 component.setComponentInstances(resourceInstances);
928                 fetchedComponent.setComponentInstances(resourceInstances);
929
930                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
931                 ArtifactDefinition artifact = new ArtifactDefinition();
932                 artifact.setArtifactName("artifactName");
933                 artifact.setEsId("esId");
934                 artifact.setArtifactUUID("artifactUUID");
935                 artifact.setArtifactType("YANG");
936                 toscaArtifacts.put("assettoscatemplate", artifact);
937
938                 component.setToscaArtifacts(toscaArtifacts);
939                 component.setDeploymentArtifacts(toscaArtifacts);
940                 component.setArtifacts(toscaArtifacts);
941
942                 fetchedComponent.setToscaArtifacts(toscaArtifacts);
943                 fetchedComponent.setDeploymentArtifacts(toscaArtifacts);
944                 fetchedComponent.setArtifacts(toscaArtifacts);
945
946                 Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
947                                 Either.left(fetchedComponent), Either.right(StorageOperationStatus.BAD_REQUEST));
948
949                 Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
950         }
951
952         @Test
953         public void testCollectComponentTypeArtifactsWhenFetchedComponentDontHaveComponentInstances() {
954                 Component component = new Service();
955                 Component fetchedComponent = new Resource();
956                 component.setUniqueId("uniqueId");
957                 List<ComponentInstance> resourceInstances = new ArrayList<>();
958                 ComponentInstance instance = new ComponentInstance();
959                 instance.setComponentUid("resourceUid");
960                 instance.setOriginType(OriginTypeEnum.SERVICE);
961
962                 Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
963                 ArtifactDefinition artifact = new ArtifactDefinition();
964                 artifact.setArtifactName("artifactName");
965                 artifact.setEsId("esId");
966                 artifact.setArtifactUUID("artifactUUID");
967                 artifact.setArtifactType("PLAN");
968                 toscaArtifacts.put("assettoscatemplate", artifact);
969
970                 instance.setDeploymentArtifacts(toscaArtifacts);
971
972                 resourceInstances.add(instance);
973                 component.setComponentInstances(resourceInstances);
974
975                 component.setToscaArtifacts(toscaArtifacts);
976                 component.setDeploymentArtifacts(toscaArtifacts);
977                 component.setArtifacts(toscaArtifacts);
978
979                 fetchedComponent.setToscaArtifacts(toscaArtifacts);
980                 fetchedComponent.setDeploymentArtifacts(toscaArtifacts);
981                 fetchedComponent.setArtifacts(toscaArtifacts);
982
983                 Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
984                                 Either.left(fetchedComponent));
985
986                 Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
987         }
988
989         @Test
990         public void testValidateNonMetaArtifactHappyScenario() {
991                 String artifactPath = "Artifacts/Deployment/YANG_XML/myYang.xml";
992                 byte[] payloadData = "some payload data".getBytes();
993                 Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
994                 Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
995                                 payloadData, collectedWarningMessages);
996                 assertTrue(eitherNonMetaArtifact.isLeft());
997                 assertTrue(collectedWarningMessages.isEmpty());
998
999                 artifactPath = "Artifacts/Informational/OTHER/someArtifact.xml";
1000                 eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
1001                 assertTrue(eitherNonMetaArtifact.isLeft());
1002                 assertTrue(collectedWarningMessages.isEmpty());
1003         }
1004
1005         @Test
1006         public void testValidateNonMetaArtifactScenarioWithWarnnings() {
1007                 String artifactPath = "Artifacts/Deployment/Buga/myYang.xml";
1008                 byte[] payloadData = "some payload data".getBytes();
1009                 Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
1010                 Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
1011                                 payloadData, collectedWarningMessages);
1012                 assertTrue(eitherNonMetaArtifact.isLeft());
1013
1014                 artifactPath = "Artifacts/Informational/Buga2/someArtifact.xml";
1015                 eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
1016                 assertTrue(eitherNonMetaArtifact.isLeft());
1017
1018                 assertTrue(collectedWarningMessages.size() == 1);
1019                 assertTrue(collectedWarningMessages.values().iterator().next().size() == 2);
1020         }
1021
1022         @Test
1023         public void testValidateNonMetaArtifactUnhappyScenario() {
1024                 String artifactPath = "Artifacts/Buga/YANG_XML/myYang.xml";
1025                 byte[] payloadData = "some payload data".getBytes();
1026                 Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
1027                 Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
1028                                 payloadData, collectedWarningMessages);
1029                 assertTrue(eitherNonMetaArtifact.isRight());
1030                 assertTrue(!collectedWarningMessages.isEmpty());
1031         }
1032 }