Add collaboration feature
[sdc.git] / common / openecomp-sdc-artifact-generator-lib / openecomp-sdc-artifact-generator-test / src / main / java / org / openecomp / sdc / generator / SampleJUnitTest.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.generator;
22
23 import org.openecomp.sdc.generator.aai.model.Widget;
24 import org.openecomp.sdc.generator.aai.tosca.ToscaTemplate;
25 import org.openecomp.sdc.generator.aai.xml.Model;
26 import org.openecomp.sdc.generator.data.*;
27 import org.openecomp.sdc.generator.impl.ArtifactGenerationServiceImpl;
28
29 import junit.framework.TestCase;
30 import org.junit.Assert;
31 import org.junit.Test;
32
33 import java.io.*;
34 import java.util.*;
35
36 import static org.openecomp.sdc.generator.ArtifactGenerationServiceTest.*;
37 import static org.openecomp.sdc.generator.data.GeneratorConstants.*;
38
39 public class SampleJUnitTest extends TestCase {
40
41     private static final String AAI_ARTIFACT_TYPE = ArtifactType.AAI.name();
42     private static final String AAI_ARTIFACT_GROUP_TYPE = GroupType.DEPLOYMENT.name();
43     private static final String GENERATOR_CONFIG = "{\"artifactTypes\": [\"OTHER\",\"AAI\"]}";
44     private static final String ARTIFACT_GENERATOR_CONFIG = "artifactgenerator.config";
45     private static final String CONFIG_PATH = "/qa-test-repo/jmeter3/apache-jmeter-3" +
46         ".0/lib/junit/";
47     private static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
48         "Cannot generate artifacts. Widget configuration not found for %s";
49     private static final String GENERATOR_AAI_CONFIGFILE_NOT_FOUND =
50         "Cannot generate artifacts. Artifact Generator Configuration file not found at %s";
51     private static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND =
52         "Cannot generate artifacts. artifactgenerator.config system property not configured";
53     private static final String INVALID_VALUE_INVARIANT =
54         "Invalid value for mandatory attribute <invariantUUID> in Artifact";
55     private static final String INVALID_VALUE_UUID =
56         "Invalid value for mandatory attribute <UUID> in Artifact:";
57     static final Map<String, String> additionalParams = new HashMap<>();
58     public static final String ARTIFACT_GENERATOR_PROPERTIES = "Artifact-Generator.properties";
59     public static final String VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML = "vf_vmme_template_NoSystemPropConfigured.yml";
60     public static final String SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML = "service_vmme_template_NoSystemPropConfigured.yml";
61
62     static{
63         additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1.0");
64     }
65
66     public SampleJUnitTest(String name) throws IOException {
67         super(name);
68         System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
69         loadConfig(ArtifactGenerationServiceTest.properties);
70     }
71
72     private void loadConfig(Properties properties) throws IOException {
73         String configLocation = System.getProperty(ARTIFACT_GENERATOR_CONFIG);
74         if (configLocation != null) {
75             File file = new File(configLocation);
76             if (file.exists()) {
77
78                 try (InputStream fis = new FileInputStream(file)) {
79                     properties.load(fis);
80                 }
81             }
82         }
83     }
84
85     public SampleJUnitTest() {
86         super();
87         System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
88     }
89
90     @Test
91     public void testArtifactGenerationSingleVFSingleVFModule() {
92         try {
93             List<Artifact> inputArtifacts = new ArrayList();
94             readPayloadFromResource(inputArtifacts, "vf_vmme_template_SingleVFVFMod.yml");
95
96             readPayloadFromResource(inputArtifacts, "service_vmme_template_SingleVFVFMod.yml");
97             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
98             List<ToscaTemplate> toscas = new LinkedList();
99
100             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
101
102             for (Artifact inputArtifact : inputArtifacts) {
103                 toscas.add(getToscaModel(inputArtifact));
104             }
105             List<Artifact> resultData = data.getResultData();
106
107             Map<String, Model> outputArtifactMap = new HashMap<>();
108             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
109             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
110
111             testResourceTosca(toscas.iterator(), outputArtifactMap);
112
113             Assert.assertEquals(5, data.getResultData().size());
114
115             removeMockArtifact(data.getResultData().iterator());
116
117             ArtifactGenerationServiceTest.validateName(data.getResultData());
118
119
120         } catch (Exception e) {
121             Assert.fail(e.getMessage());
122         }
123     }
124
125     @Test
126     public void testArtifactGenerationMissingVFInServiceTOSCA() {
127         try {
128             List<Artifact> inputArtifacts = new ArrayList();
129             readPayloadFromResource(inputArtifacts, "service_vmme_template_MissingVFInServiceTOSCA.yml");
130             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
131             List<ToscaTemplate> toscas = new LinkedList();
132
133             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
134
135             for (Artifact inputArtifact : inputArtifacts) {
136                 toscas.add(getToscaModel(inputArtifact));
137             }
138             List<Artifact> resultData = data.getResultData();
139
140             Map<String, Model> outputArtifactMap = new HashMap<>();
141             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
142             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
143
144             Assert.assertEquals(3, data.getResultData().size());
145
146             removeMockArtifact(data.getResultData().iterator());
147
148             ArtifactGenerationServiceTest.validateName(data.getResultData());
149
150
151         } catch (Exception e) {
152             Assert.fail(e.getMessage());
153         }
154     }
155
156     @Test
157     public void testArtifactGenerationVerifySameStaticWidgetsForAllServices() {
158         try {
159             List<Artifact> inputArtifacts = new ArrayList();
160             readPayloadFromResource(inputArtifacts, "vf_vmme_template_SameWidgets1.yml");
161
162             readPayloadFromResource(inputArtifacts, "service_vmme_template_SameWidget1.yml");
163             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
164             List<ToscaTemplate> toscas = new LinkedList();
165
166             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
167
168             for (Artifact inputArtifact : inputArtifacts) {
169                 toscas.add(getToscaModel(inputArtifact));
170             }
171             List<Artifact> resultData = data.getResultData();
172
173             Map<String, Model> outputArtifactMap = new HashMap<>();
174             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
175
176             removeMockArtifact(data.getResultData().iterator());
177
178
179             List<Artifact> inputArtifacts2 = new ArrayList();
180             readPayloadFromResource(inputArtifacts2, "vf_vmme_template_SameWidgets2.yml");
181
182             readPayloadFromResource(inputArtifacts2, "service_vmme_template_SameWidget2.yml");
183             ArtifactGenerationServiceImpl obj2 = new ArtifactGenerationServiceImpl();
184
185             GenerationData data2 = obj2.generateArtifact(inputArtifacts2, GENERATOR_CONFIG,additionalParams);
186             List<Artifact> resultData2 = data2.getResultData();
187
188             List<ToscaTemplate> toscas2 = new LinkedList();
189
190             for (Artifact inputArtifact : inputArtifacts2) {
191                 toscas2.add(getToscaModel(inputArtifact));
192             }
193
194             Map<String, Model> outputArtifactMap2 = new HashMap<>();
195             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap2, resultData2);
196             removeMockArtifact(data2.getResultData().iterator());
197
198             Map<String,String> map = new HashMap<>();
199             Iterator<Artifact> itr =  data.getResultData().iterator();
200                     while(itr.hasNext()){
201                         Artifact artifact=itr.next();
202                         if(artifact.getLabel().contains("AAI-widget")){
203                             map.put(artifact.getName(),artifact.getChecksum());
204                         }
205                     }
206             Map<String,String> map2 = new HashMap<>();
207             Iterator<Artifact> itr2 =  data2.getResultData().iterator();
208             while(itr2.hasNext()){
209                 Artifact artifact=itr2.next();
210                 if(artifact.getLabel().contains("AAI-widget")){
211                     map2.put(artifact.getName(),artifact.getChecksum());
212                 }
213             }
214             Assert.assertEquals(map.size(),map2.size());
215             for(Map.Entry<String, String> entry : map.entrySet()){
216                 Assert.assertEquals(entry.getValue(), map2.get(entry.getKey()));
217             }
218
219         } catch (Exception e) {
220             Assert.fail(e.getMessage());
221         }
222     }
223
224     @Test
225     public void testArtifactGenerationMulVFModule() {
226         try {
227             List<Artifact> inputArtifacts = new ArrayList();
228             readPayloadFromResource(inputArtifacts, "vf_vmme_template_MulVFVFMod.yml");
229
230             readPayloadFromResource(inputArtifacts, "service_vmme_template_MulVFVFMod.yml");
231
232             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
233             List<ToscaTemplate> toscas = new LinkedList();
234
235             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
236
237                 for (Artifact inputArtifact : inputArtifacts) {
238                     toscas.add(getToscaModel(inputArtifact));
239                 }
240                 List<Artifact> resultData = data.getResultData();
241
242                 Map<String, Model> outputArtifactMap = new HashMap<>();
243                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
244                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
245                 testResourceTosca(toscas.iterator(), outputArtifactMap);
246
247             Assert.assertEquals(3,data.getResultData().size());
248
249             removeMockArtifact(data.getResultData().iterator());
250
251             ArtifactGenerationServiceTest.validateName(data.getResultData());
252
253         } catch (Exception e) {
254             Assert.fail(e.getMessage());
255         }
256     }
257
258     @Test
259     public void testArtifactGenerationMulVFs() {
260         try {
261             List<Artifact> inputArtifacts = new ArrayList();
262
263             readPayloadFromResource(inputArtifacts, "CMAUI_VF.yaml");
264
265             readPayloadFromResource(inputArtifacts, "ECA_OAM_VF.yaml");
266
267             readPayloadFromResource(inputArtifacts, "MMSC_Sevice_07_25_16.yaml");
268
269             readPayloadFromResource(inputArtifacts, "MMSC_VF.yaml");
270
271             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
272             List<ToscaTemplate> toscas = new LinkedList();
273
274             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
275
276             for (Artifact inputArtifact : inputArtifacts) {
277                 toscas.add(getToscaModel(inputArtifact));
278             }
279             List<Artifact> resultData = data.getResultData();
280
281             Map<String, Model> outputArtifactMap = new HashMap<>();
282             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
283             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
284             testResourceTosca(toscas.iterator(), outputArtifactMap);
285
286             Assert.assertEquals(8,data.getResultData().size());
287
288             removeMockArtifact(data.getResultData().iterator());
289
290             ArtifactGenerationServiceTest.validateName(data.getResultData());
291
292         } catch (Exception e) {
293             Assert.fail(e.getMessage());
294         }
295     }
296
297     @Test
298     public void testArtifactGenerationDupVFUUID() {
299         try {
300             List<Artifact> inputArtifacts = new ArrayList();
301             readPayloadFromResource(inputArtifacts, "vf_vmme_template_DupVFUUID.yml");
302
303             readPayloadFromResource(inputArtifacts, "service_vmme_template_DupVFUUID.yml");
304             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
305             List<ToscaTemplate> toscas = new LinkedList();
306
307             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
308
309                 for (Artifact inputArtifact : inputArtifacts) {
310                     toscas.add(getToscaModel(inputArtifact));
311                 }
312                 List<Artifact> resultData = data.getResultData();
313
314                 Map<String, Model> outputArtifactMap = new HashMap<>();
315                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
316                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
317                 testResourceTosca(toscas.iterator(), outputArtifactMap);
318
319             Assert.assertEquals(5,data.getResultData().size());
320
321             removeMockArtifact(data.getResultData().iterator());
322
323             ArtifactGenerationServiceTest.validateName(data.getResultData());
324
325         } catch (Exception e) {
326             Assert.fail(e.getMessage());
327         }
328     }
329
330     @Test
331     public void testArtifactGenerationDupVFModUUID() {
332         try {
333             List<Artifact> inputArtifacts = new ArrayList();
334             readPayloadFromResource(inputArtifacts, "vf_vmme_template_DupVFModUUID.yml");
335
336             readPayloadFromResource(inputArtifacts, "service_vmme_template_DupVFModUUID.yml");
337             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
338             List<ToscaTemplate> toscas = new LinkedList();
339
340             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
341
342                 for (Artifact inputArtifact : inputArtifacts) {
343                     toscas.add(getToscaModel(inputArtifact));
344                 }
345                 List<Artifact> resultData = data.getResultData();
346
347                 Map<String, Model> outputArtifactMap = new HashMap<>();
348                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
349                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
350                 testResourceTosca(toscas.iterator(), outputArtifactMap);
351
352             Assert.assertEquals(5,data.getResultData().size());
353
354             removeMockArtifact(data.getResultData().iterator());
355
356             ArtifactGenerationServiceTest.validateName(data.getResultData());
357         } catch (Exception e) {
358             Assert.fail(e.getMessage());
359         }
360     }
361
362     @Test
363     public void testArtifactGenerationVerifyVFModWithoutVNFC() {
364         try {
365             List<Artifact> inputArtifacts = new ArrayList();
366             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyVFModWithoutVNFC.yml");
367
368             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyVFModWithoutVNFC.yml");
369             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
370             List<ToscaTemplate> toscas = new LinkedList();
371
372             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
373
374                 for (Artifact inputArtifact : inputArtifacts) {
375                     toscas.add(getToscaModel(inputArtifact));
376                 }
377                 List<Artifact> resultData = data.getResultData();
378
379                 Map<String, Model> outputArtifactMap = new HashMap<>();
380                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
381                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
382                 testResourceTosca(toscas.iterator(), outputArtifactMap);
383
384             Assert.assertEquals(5,data.getResultData().size());
385
386             removeMockArtifact(data.getResultData().iterator());
387
388             ArtifactGenerationServiceTest.validateName(data.getResultData());
389         } catch (Exception e) {
390             Assert.fail(e.getMessage());
391         }
392     }
393
394     @Test
395     public void testArtifactGenerationVerifyVFModWithInvalidMember() {
396         try {
397             List<Artifact> inputArtifacts = new ArrayList();
398             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyVFModWithInvalidNo.yml");
399
400             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyVFModWithInvalidNo.yml");
401             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
402             List<ToscaTemplate> toscas = new LinkedList();
403
404             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
405
406                 for (Artifact inputArtifact : inputArtifacts) {
407                     toscas.add(getToscaModel(inputArtifact));
408                 }
409                 List<Artifact> resultData = data.getResultData();
410
411                 Map<String, Model> outputArtifactMap = new HashMap<>();
412                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
413                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
414                 testResourceTosca(toscas.iterator(), outputArtifactMap);
415
416             Assert.assertEquals(5,data.getResultData().size());
417
418             removeMockArtifact(data.getResultData().iterator());
419
420             ArtifactGenerationServiceTest.validateName(data.getResultData());
421         } catch (Exception e) {
422             Assert.fail(e.getMessage());
423         }
424     }
425
426     @Test
427     public void testArtifactGenerationNullFields() {
428         try {
429             List<Artifact> inputArtifacts = new ArrayList();
430             readPayloadFromResource(inputArtifacts, "vf_vmme_template_NullFields.yml");
431
432             readPayloadFromResource(inputArtifacts, "service_vmme_template_NullFields.yml");
433             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
434
435             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
436             Assert.assertEquals(false,data.getErrorData().isEmpty());
437
438             Assert.assertEquals("Invalid Service/Resource definition mandatory attribute <UUID> missing in Artifact: <"+inputArtifacts.get(0).getName()+">",data.getErrorData().get("AAI").get(0));
439
440             Assert.assertEquals(2,data.getResultData().size());
441
442         } catch (Exception e) {
443             Assert.fail(e.getMessage());
444         }
445     }
446
447     @Test
448     public void testArtifactGenerationInCorrectYmlFormat() {
449         try {
450             List<Artifact> inputArtifacts = new ArrayList();
451
452             readPayloadFromResource(inputArtifacts, "CMAUI_VFInvalidFormat.yaml");
453
454             readPayloadFromResource(inputArtifacts, "ECA_OAM_VFInvalidFormat.yaml");
455
456             readPayloadFromResource(inputArtifacts, "MMSC_Sevice_07_25_16InvalidFormat.yaml");
457
458             readPayloadFromResource(inputArtifacts, "MMSC_VFInvalidFormat.yaml");
459
460             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
461
462             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
463             Assert.assertEquals(false,data.getErrorData().isEmpty());
464
465             Assert.assertEquals("Invalid format for Tosca YML  : "+inputArtifacts.get(1).getName(),data.getErrorData().get("AAI").get(0));
466
467             Assert.assertEquals(2,data.getResultData().size());
468
469         } catch (Exception e) {
470             Assert.fail(e.getMessage());
471         }
472     }
473
474     @Test
475     public void testArtifactGenerationMulComp() {
476         try {
477             List<Artifact> inputArtifacts = new ArrayList();
478             readPayloadFromResource(inputArtifacts, "vf_vmme_template_MulComp.yml");
479
480             readPayloadFromResource(inputArtifacts, "service_vmme_template_MulComp.yml");
481             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
482             List<ToscaTemplate> toscas = new LinkedList();
483
484             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
485
486                 for (Artifact inputArtifact : inputArtifacts) {
487                     toscas.add(getToscaModel(inputArtifact));
488                 }
489                 List<Artifact> resultData = data.getResultData();
490
491                 Map<String, Model> outputArtifactMap = new HashMap<>();
492                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
493                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
494                 testResourceTosca(toscas.iterator(), outputArtifactMap);
495
496             Assert.assertEquals(5,data.getResultData().size());
497
498             removeMockArtifact(data.getResultData().iterator());
499
500             ArtifactGenerationServiceTest.validateName(data.getResultData());
501         } catch (Exception e) {
502             Assert.fail(e.getMessage());
503         }
504     }
505
506     @Test
507     public void testArtifactGenerationOrphan() {
508         try {
509             List<Artifact> inputArtifacts = new ArrayList();
510
511             readPayloadFromResource(inputArtifacts, "vf_vmme_template_Orphan.yml");
512
513             readPayloadFromResource(inputArtifacts, "service_vmme_template_Orphan.yml");
514
515             readPayloadFromResource(inputArtifacts, "ECA_OAM_VFOrphan.yaml");
516
517             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
518             List<ToscaTemplate> toscas = new LinkedList();
519
520             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
521
522                 for (Artifact inputArtifact : inputArtifacts) {
523                     toscas.add(getToscaModel(inputArtifact));
524                 }
525                 List<Artifact> resultData = data.getResultData();
526
527                 Map<String, Model> outputArtifactMap = new HashMap<>();
528                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
529                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
530                 testResourceTosca(toscas.iterator(), outputArtifactMap);
531
532             Assert.assertEquals(5,data.getResultData().size());
533
534             removeMockArtifact(data.getResultData().iterator());
535
536             ArtifactGenerationServiceTest.validateName(data.getResultData());
537         } catch (Exception e) {
538             Assert.fail(e.getMessage());
539         }
540     }
541
542     @Test
543     public void testArtifactGenerationMissingVFTemplate() {
544         try {
545             List<Artifact> inputArtifacts = new ArrayList();
546
547             readPayloadFromResource(inputArtifacts, "service_vmme_template_MissingVFTemplate.yml");
548
549             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
550             List<ToscaTemplate> toscas = new LinkedList();
551
552             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
553
554                 for (Artifact inputArtifact : inputArtifacts) {
555                     toscas.add(getToscaModel(inputArtifact));
556                 }
557                 List<Artifact> resultData = data.getResultData();
558
559                 Map<String, Model> outputArtifactMap = new HashMap<>();
560                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
561                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
562
563
564             Assert.assertEquals(3,data.getResultData().size());
565
566             removeMockArtifact(data.getResultData().iterator());
567
568             ArtifactGenerationServiceTest.validateName(data.getResultData());
569         } catch (Exception e) {
570             Assert.fail(e.getMessage());
571         }
572     }
573
574     @Test
575     public void testArtifactGenerationMissingVFModule() {
576         try {
577             List<Artifact> inputArtifacts = new ArrayList();
578
579             readPayloadFromResource(inputArtifacts, "CMAUI_VFMissingVFModule.yaml");
580
581             readPayloadFromResource(inputArtifacts, "ECA_OAM_VFMissingVFModule.yaml");
582
583             readPayloadFromResource(inputArtifacts, "MMSC_Sevice_07_25_16MissingVFModule.yaml");
584
585             readPayloadFromResource(inputArtifacts, "MMSC_VFMissingVFModule.yaml");
586
587             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
588             List<ToscaTemplate> toscas = new LinkedList();
589
590             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
591
592                 for (Artifact inputArtifact : inputArtifacts) {
593                     toscas.add(getToscaModel(inputArtifact));
594                 }
595                 List<Artifact> resultData = data.getResultData();
596
597                 Map<String, Model> outputArtifactMap = new HashMap<>();
598                 ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
599                 ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
600                 testResourceTosca(toscas.iterator(), outputArtifactMap);
601
602             Assert.assertEquals(8,data.getResultData().size());
603
604             removeMockArtifact(data.getResultData().iterator());
605
606             ArtifactGenerationServiceTest.validateName(data.getResultData());
607
608         } catch (Exception e) {
609             Assert.fail(e.getMessage());
610         }
611     }
612
613     @Test
614     public void testArtifactGenerationEmptyArtifact() {
615         try {
616             List<Artifact> inputArtifacts = new ArrayList();
617
618             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
619
620             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
621             Assert.assertEquals(false,data.getErrorData().isEmpty());
622             Assert.assertEquals("Service tosca missing from list of input artifacts",data.getErrorData().get("AAI").get(0));
623
624             Assert.assertEquals(2,data.getResultData().size());
625
626         } catch (Exception e) {
627             Assert.fail(e.getMessage());
628         }
629     }
630
631     @Test
632     public void testArtifactGenerationMissingConfigFile() {
633         try {
634             List<Artifact> inputArtifacts = new ArrayList();
635
636             readPayloadFromResource(inputArtifacts, "vf_vmme_template_SingleVFVFMod.yml");
637
638             readPayloadFromResource(inputArtifacts, "service_vmme_template_SingleVFVFMod.yml");
639             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
640
641             GenerationData data = obj.generateArtifact(inputArtifacts, "",additionalParams);
642             Assert.assertEquals(false,data.getErrorData().isEmpty());
643             Assert.assertEquals("Invalid Client Configuration",data.getErrorData().get("ARTIFACT_GENERATOR_INVOCATION_ERROR").get(0));
644
645             Assert.assertEquals(0,data.getResultData().size());
646
647         } catch (Exception e) {
648             Assert.fail(e.getMessage());
649         }
650     }
651
652
653     @Test
654     public void testArtifactGenerationWithNodeTemplates() {
655         try {
656             List<Artifact> inputArtifacts = new ArrayList();
657
658             readPayloadFromResource(inputArtifacts, "ServiceWithNodetemplate.yml");
659
660             readPayloadFromResource(inputArtifacts, "Resource0-template.yml");
661
662             readPayloadFromResource(inputArtifacts, "Resource1-template.yml");
663
664             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
665             List<ToscaTemplate> toscas = new LinkedList();
666
667             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
668
669             for (Artifact inputArtifact : inputArtifacts) {
670                 toscas.add(getToscaModel(inputArtifact));
671             }
672             List<Artifact> resultData = data.getResultData();
673
674             Map<String, Model> outputArtifactMap = new HashMap<>();
675             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
676             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
677             testResourceTosca(toscas.iterator(), outputArtifactMap);
678
679             Assert.assertEquals(5,data.getResultData().size());
680
681             removeMockArtifact(data.getResultData().iterator());
682
683             ArtifactGenerationServiceTest.validateName(data.getResultData());
684
685
686         } catch (Exception e) {
687             Assert.fail(e.getMessage());
688         }
689     }
690
691     @Test
692     public void testArtifactGenerationWithoutNodeTemplates() {
693         try {
694             List<Artifact> inputArtifacts = new ArrayList();
695
696             readPayloadFromResource(inputArtifacts, "Service0-template.yml");
697
698             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
699             List<ToscaTemplate> toscas = new LinkedList();
700
701             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
702
703             for (Artifact inputArtifact : inputArtifacts) {
704                 toscas.add(getToscaModel(inputArtifact));
705             }
706             List<Artifact> resultData = data.getResultData();
707
708             Map<String, Model> outputArtifactMap = new HashMap<>();
709             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
710             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
711
712
713             Assert.assertEquals(3,data.getResultData().size());
714
715             removeMockArtifact(data.getResultData().iterator());
716
717             ArtifactGenerationServiceTest.validateName(data.getResultData());
718
719
720         } catch (Exception e) {
721             Assert.fail(e.getMessage());
722         }
723     }
724
725     @Test
726     public void testArtifactGenerationWithArtifactNameAndDescMoreThan256() {
727         try {
728             List<Artifact> inputArtifacts = new ArrayList();
729
730             readPayloadFromResource(inputArtifacts, "Service0-templateMoreThan256.yml");
731
732             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
733             List<ToscaTemplate> toscas = new LinkedList();
734
735             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
736
737             for (Artifact inputArtifact : inputArtifacts) {
738                 toscas.add(getToscaModel(inputArtifact));
739             }
740             List<Artifact> resultData = data.getResultData();
741
742             Map<String, Model> outputArtifactMap = new HashMap<>();
743             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
744             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
745
746
747             Assert.assertEquals(3,data.getResultData().size());
748
749             removeMockArtifact(data.getResultData().iterator());
750
751             for(Artifact artifact : data.getResultData()){
752                 checkArtifactName(artifact.getName());
753                 checkArtifactLabel(artifact.getLabel());
754                 checkArtifactDescription(artifact.getDescription());
755
756             }
757
758         } catch (Exception e) {
759             Assert.fail(e.getMessage());
760         }
761     }
762
763     @Test
764     public void testArtifactGenerationWithDifferentVersionOfSameVF() {
765         try {
766             List<Artifact> inputArtifacts = new ArrayList();
767
768             readPayloadFromResource(inputArtifacts, "service_vmme_template_DiffVerOfSameVF.yml");
769
770             readPayloadFromResource(inputArtifacts, "vf_vmme_template_DiffVerOfSameVF_1.yml");
771
772             readPayloadFromResource(inputArtifacts, "vf_vmme_template_DiffVerOfSameVF_2.yml");
773
774             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
775             List<ToscaTemplate> toscas = new LinkedList();
776
777             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
778
779             for (Artifact inputArtifact : inputArtifacts) {
780                 toscas.add(getToscaModel(inputArtifact));
781             }
782             List<Artifact> resultData = data.getResultData();
783
784             Map<String, Model> outputArtifactMap = new HashMap<>();
785             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
786             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
787             testResourceTosca(toscas.iterator(), outputArtifactMap);
788
789             Assert.assertEquals(6,data.getResultData().size());
790
791             removeMockArtifact(data.getResultData().iterator());
792
793             ArtifactGenerationServiceTest.validateName(data.getResultData());
794
795
796         } catch (Exception e) {
797             Assert.fail(e.getMessage());
798         }
799     }
800
801     @Test
802     public void testArtifactGenerationWithDifferentVersionOfSameVFModWithSameInvId() {
803         try {
804             List<Artifact> inputArtifacts = new ArrayList();
805
806             readPayloadFromResource(inputArtifacts, "service_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
807
808             readPayloadFromResource(inputArtifacts, "vf_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
809
810             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
811             List<ToscaTemplate> toscas = new LinkedList();
812
813             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
814
815             for (Artifact inputArtifact : inputArtifacts) {
816                 toscas.add(getToscaModel(inputArtifact));
817             }
818             List<Artifact> resultData = data.getResultData();
819
820             Map<String, Model> outputArtifactMap = new HashMap<>();
821             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
822             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
823             testResourceTosca(toscas.iterator(), outputArtifactMap);
824
825             Assert.assertEquals(6,data.getResultData().size());
826
827             removeMockArtifact(data.getResultData().iterator());
828
829             ArtifactGenerationServiceTest.validateName(data.getResultData());
830
831
832         } catch (Exception e) {
833             Assert.fail(e.getMessage());
834         }
835     }
836
837     @Test
838     public void testArtifactGenerationWithServiceContainingL3Network() {
839         try {
840             List<Artifact> inputArtifacts = new ArrayList();
841
842             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithL3Network.yml");
843
844             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithL3Network.yml");
845
846             readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithL3Network.yml");
847
848             readPayloadFromResource(inputArtifacts, "resource-Extvl-template_WithL3Network.yml");
849
850             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
851             List<ToscaTemplate> toscas = new LinkedList();
852
853             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
854
855             for (Artifact inputArtifact : inputArtifacts) {
856                 toscas.add(getToscaModel(inputArtifact));
857             }
858             List<Artifact> resultData = data.getResultData();
859
860             Map<String, Model> outputArtifactMap = new HashMap<>();
861             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
862             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
863             testResourceTosca(toscas.iterator(), outputArtifactMap);
864
865             Assert.assertEquals(7,data.getResultData().size());
866
867             removeMockArtifact(data.getResultData().iterator());
868
869             ArtifactGenerationServiceTest.validateName(data.getResultData());
870
871
872         } catch (Exception e) {
873             Assert.fail(e.getMessage());
874         }
875     }
876
877     @Test
878     public void testArtifactGenerationWithServiceContainingDupL3Network() {
879         try {
880             List<Artifact> inputArtifacts = new ArrayList();
881
882             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithDupL3Network.yml");
883
884             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithDupL3Network.yml");
885
886             readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithDupL3Network.yml");
887
888             readPayloadFromResource(inputArtifacts, "resource-Extvl-template_WithDupL3Network.yml");
889
890             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
891             List<ToscaTemplate> toscas = new LinkedList();
892
893             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
894
895             for (Artifact inputArtifact : inputArtifacts) {
896                 toscas.add(getToscaModel(inputArtifact));
897             }
898             List<Artifact> resultData = data.getResultData();
899
900             Map<String, Model> outputArtifactMap = new HashMap<>();
901             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
902             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
903             testResourceTosca(toscas.iterator(), outputArtifactMap);
904
905             Assert.assertEquals(7,data.getResultData().size());
906
907             removeMockArtifact(data.getResultData().iterator());
908
909             ArtifactGenerationServiceTest.validateName(data.getResultData());
910
911
912         } catch (Exception e) {
913             Assert.fail(e.getMessage());
914         }
915     }
916
917     @Test
918     public void testArtifactGenerationWithL3NetworkInVFMod() {
919         try {
920             List<Artifact> inputArtifacts = new ArrayList();
921
922             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithL3NetworkInVFMod.yml");
923
924             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithL3NetworkInVFMod.yml");
925
926             readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithL3NetworkInVFMod.yml");
927
928             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
929             List<ToscaTemplate> toscas = new LinkedList();
930
931             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
932
933             for (Artifact inputArtifact : inputArtifacts) {
934                 toscas.add(getToscaModel(inputArtifact));
935             }
936             List<Artifact> resultData = data.getResultData();
937
938             Map<String, Model> outputArtifactMap = new HashMap<>();
939             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
940             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
941             testResourceTosca(toscas.iterator(), outputArtifactMap);
942
943             Assert.assertEquals(6,data.getResultData().size());
944
945             removeMockArtifact(data.getResultData().iterator());
946
947             ArtifactGenerationServiceTest.validateName(data.getResultData());
948
949
950         } catch (Exception e) {
951             Assert.fail(e.getMessage());
952         }
953     }
954
955     @Test
956     public void testArtifactGenerationWithDiffVersionOfSameL3Network() {
957         try {
958             List<Artifact> inputArtifacts = new ArrayList();
959
960             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithDiffVersionOfSameL3Network.yml");
961
962             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithDiffVersionOfSameL3Network.yml");
963
964             readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithDiffVersionOfSameL3Network.yml");
965
966             readPayloadFromResource(inputArtifacts, "resource-Extvl-template_WithDiffVersionOfSameL3Network.yml");
967
968             readPayloadFromResource(inputArtifacts, "resource-Extvl-template_1_WithDiffVersionOfSameL3Network.yml");
969
970             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
971             List<ToscaTemplate> toscas = new LinkedList();
972
973             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
974
975             for (Artifact inputArtifact : inputArtifacts) {
976                 toscas.add(getToscaModel(inputArtifact));
977             }
978             List<Artifact> resultData = data.getResultData();
979
980             Map<String, Model> outputArtifactMap = new HashMap<>();
981             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap,resultData);
982             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap,toscas);
983             testResourceTosca(toscas.iterator(), outputArtifactMap);
984
985             Assert.assertEquals(8,data.getResultData().size());
986
987             removeMockArtifact(data.getResultData().iterator());
988
989             ArtifactGenerationServiceTest.validateName(data.getResultData());
990
991
992         } catch (Exception e) {
993             Assert.fail(e.getMessage());
994         }
995     }
996
997     @Test
998     public void testArtifactGenerationWithInvIdGreaterThanSpecifiedLimit() {
999         try {
1000             List<Artifact> inputArtifacts = new ArrayList();
1001             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
1002
1003             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
1004             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1005
1006             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1007             Assert.assertEquals(false,data.getErrorData().isEmpty());
1008
1009             Assert.assertEquals(INVALID_VALUE_INVARIANT + ": <" +inputArtifacts.get(1).getName()+">",data.getErrorData().get("AAI").get(0));
1010
1011             Assert.assertEquals(2,data.getResultData().size());
1012
1013         } catch (Exception e) {
1014             Assert.fail(e.getMessage());
1015         }
1016     }
1017
1018     @Test
1019     public void testArtifactGenerationWithInvIdLesserThanSpecifiedLimit() {
1020         try {
1021             List<Artifact> inputArtifacts = new ArrayList();
1022             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
1023
1024             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
1025             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1026
1027             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1028             Assert.assertEquals(false,data.getErrorData().isEmpty());
1029
1030             Assert.assertEquals(INVALID_VALUE_UUID + " <"
1031                 +inputArtifacts.get(1).getName()+">",data.getErrorData().get("AAI").get(0));
1032
1033             Assert.assertEquals(2,data.getResultData().size());
1034
1035         } catch (Exception e) {
1036             Assert.fail(e.getMessage());
1037         }
1038     }
1039
1040
1041     @Test
1042     public void testErrorWhenNoSystemPropConfigured() {
1043         String configLoc = System.getProperty(ARTIFACT_GENERATOR_CONFIG);
1044         try {
1045             List<Artifact> inputArtifacts = new ArrayList();
1046             readPayloadFromResource(inputArtifacts, VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
1047
1048             readPayloadFromResource(inputArtifacts, SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
1049
1050             System.clearProperty(ARTIFACT_GENERATOR_CONFIG);
1051
1052             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1053             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1054             Assert.assertEquals(false,data.getErrorData().isEmpty());
1055             Assert.assertEquals(data.getErrorData().
1056                 get("AAI").get(0), GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND);
1057         } catch (Exception e) {
1058             Assert.fail(e.getMessage());
1059         }
1060         finally{
1061             System.setProperty(ARTIFACT_GENERATOR_CONFIG,configLoc);
1062         }
1063     }
1064
1065     @Test
1066     public void testErrorWhenNoFileAtConfigLocation() {
1067         String configLoc = System.getProperty(ARTIFACT_GENERATOR_CONFIG);
1068         try {
1069             List<Artifact> inputArtifacts = new ArrayList();
1070             readPayloadFromResource(inputArtifacts, VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
1071
1072             readPayloadFromResource(inputArtifacts, SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
1073
1074             System.setProperty(ARTIFACT_GENERATOR_CONFIG,configLoc + File.separator + "testErrorWhenNoFileAtConfigLocation");
1075             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1076             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1077             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1078             Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format(
1079                 GENERATOR_AAI_CONFIGFILE_NOT_FOUND,System.getProperty
1080                 (ARTIFACT_GENERATOR_CONFIG)));
1081         } catch (Exception e) {
1082             Assert.fail(e.getMessage());
1083         }
1084         finally{
1085             System.setProperty(ARTIFACT_GENERATOR_CONFIG,configLoc);
1086         }
1087     }
1088
1089     @Test
1090     public void testErrorWhenNoWidgetInConfig() throws IOException {
1091         System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator1.properties");
1092         loadConfig(ArtifactGenerationServiceTest.properties);
1093         try {
1094             List<Artifact> inputArtifacts = new ArrayList();
1095             readPayloadFromResource(inputArtifacts, VF_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
1096
1097             readPayloadFromResource(inputArtifacts, SERVICE_VMME_TEMPLATE_NO_SYSTEM_PROP_CONFIGURED_YML);
1098
1099             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1100             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1101
1102             String assertMsg = ArtifactType.AAI.name() + ".model-version-id." + Widget.getWidget
1103                 (Widget.Type.SERVICE).getName();
1104
1105             Assert.assertEquals(false,data.getErrorData().isEmpty());
1106             String errMsg = String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,assertMsg);
1107             Assert.assertEquals(data.getErrorData().get("AAI").get(0),errMsg);
1108         } catch (Exception e) {
1109             Assert.fail(e.getMessage());
1110         } finally {
1111             System.setProperty(ARTIFACT_GENERATOR_CONFIG, CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
1112             loadConfig(ArtifactGenerationServiceTest.properties);
1113         }
1114     }
1115
1116     @Test
1117     public void testArtifactGenerationWithUpdatedUUIDInConfig() throws IOException {
1118         try {
1119             List<Artifact> inputArtifacts = new ArrayList();
1120             readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithUpdatedUUIDInConfig.yml");
1121
1122             readPayloadFromResource(inputArtifacts, "service_vmme_template_WithUpdatedUUIDInConfig.yml");
1123
1124             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1125             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1126             List<ToscaTemplate> toscas = new LinkedList();
1127             for (Artifact inputArtifact : inputArtifacts) {
1128                 toscas.add(getToscaModel(inputArtifact));
1129             }
1130             List<Artifact> resultData = data.getResultData();
1131             Map<String, Model> outputArtifactMap = new HashMap<>();
1132             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1133             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1134             testResourceTosca(toscas.iterator(), outputArtifactMap);
1135
1136             System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH+"Artifact-Generator2.properties");
1137             loadConfig(ArtifactGenerationServiceTest.properties);
1138
1139             List<ToscaTemplate> toscas2 = new LinkedList();
1140             for (Artifact inputArtifact : inputArtifacts) {
1141                 toscas2.add(getToscaModel(inputArtifact));
1142             }
1143             GenerationData data2 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1144             Map<String, Model> outputArtifactMap2 = new HashMap<>();
1145             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap2,
1146                 data2.getResultData());
1147             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap2, toscas2);
1148             testResourceTosca(toscas2.iterator(), outputArtifactMap2);
1149
1150         } catch (Exception e) {
1151             Assert.fail(e.getMessage());
1152         } finally {
1153             System.setProperty(ARTIFACT_GENERATOR_CONFIG,CONFIG_PATH + ARTIFACT_GENERATOR_PROPERTIES);
1154             loadConfig(ArtifactGenerationServiceTest.properties);
1155         }
1156     }
1157
1158     @Test
1159     public void testArtifactGenerationVerifyMandatoryParameterServiceVersion() {
1160         try {
1161             List<Artifact> inputArtifacts = new ArrayList();
1162             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
1163
1164             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
1165             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1166
1167             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, new HashMap<String, String>());
1168
1169             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1170             Assert.assertEquals(data.getErrorData().get("AAI").get(0),GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION);
1171         } catch (Exception e) {
1172             Assert.fail(e.getMessage());
1173         }
1174     }
1175
1176     @Test
1177     public void testArtifactGenerationVerifyServiceVersionFormat() {
1178         try {
1179             List<Artifact> inputArtifacts = new ArrayList();
1180             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyServiceVersionFormat.yml");
1181
1182             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyServiceVersionFormat.yml");
1183             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1184
1185             additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1");
1186             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1187             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1188             Assert.assertEquals(data.getErrorData().get("AAI").get(0),GENERATOR_AAI_INVALID_SERVICE_VERSION);
1189
1190             additionalParams.put(AdditionalParams.ServiceVersion.getName(),"0.1");
1191             GenerationData data2 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG,
1192                 additionalParams);
1193             Assert.assertEquals(data2.getErrorData().isEmpty(),false);
1194             Assert.assertEquals(data2.getErrorData().get("AAI").get(0),
1195                 GENERATOR_AAI_INVALID_SERVICE_VERSION);
1196
1197             additionalParams.put(AdditionalParams.ServiceVersion.getName(),"0.0");
1198             GenerationData data3 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG,
1199                 additionalParams);
1200             Assert.assertEquals(data3.getErrorData().isEmpty(),false);
1201             Assert.assertEquals(data3.getErrorData().get("AAI").get(0),
1202                 GENERATOR_AAI_INVALID_SERVICE_VERSION);
1203         } catch (Exception e) {
1204             Assert.fail(e.getMessage());
1205         } finally{
1206             additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1.0");
1207         }
1208     }
1209
1210     @Test
1211     public void testArtifactGenerationVerifyServiceVersion() {
1212         try {
1213             List<Artifact> inputArtifacts = new ArrayList();
1214             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyServiceVersion.yml");
1215
1216             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyServiceVersion.yml");
1217             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1218             List<ToscaTemplate> toscas = new LinkedList();
1219
1220             additionalParams.put(AdditionalParams.ServiceVersion.getName(),"9.0");
1221             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1222
1223             for (Artifact inputArtifact : inputArtifacts) {
1224                 toscas.add(getToscaModel(inputArtifact));
1225             }
1226             List<Artifact> resultData = data.getResultData();
1227
1228             Map<String, Model> outputArtifactMap = new HashMap<>();
1229             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1230             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1231
1232             testResourceTosca(toscas.iterator(), outputArtifactMap);
1233
1234             Assert.assertEquals(5, data.getResultData().size());
1235
1236             removeMockArtifact(data.getResultData().iterator());
1237
1238             ArtifactGenerationServiceTest.validateName(data.getResultData());
1239
1240
1241         } catch (Exception e) {
1242             Assert.fail(e.getMessage());
1243         } finally{
1244             additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1.0");
1245         }
1246     }
1247
1248
1249     @Test
1250     public void testArtifactGenerationVerifyResourceVersionFormat() {
1251         try {
1252             List<Artifact> inputArtifacts = new ArrayList();
1253             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyResourceVersionFormat.yml");
1254
1255             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyResourceVersionFormat1.yml");
1256             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1257
1258             List<ToscaTemplate> toscas = new LinkedList();
1259             for (Artifact inputArtifact : inputArtifacts) {
1260                 toscas.add(getToscaModel(inputArtifact));
1261             }
1262
1263             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1264             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1265             Assert.assertEquals(data.getErrorData().get("AAI").get(0),
1266                 String.format(GENERATOR_AAI_ERROR_INVALID_RESOURCE_VERSION_IN_SERVICE_TOSCA,
1267                     toscas.get(0).getMetadata().get("UUID")));
1268
1269             inputArtifacts.remove(1);
1270
1271             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyResourceVersionFormat2.yml");
1272             GenerationData data2 = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG,
1273                 additionalParams);
1274             Assert.assertEquals(data2.getErrorData().isEmpty(),false);
1275             Assert.assertEquals(data2.getErrorData().get("AAI").get(0),
1276                 String.format(GENERATOR_AAI_ERROR_INVALID_RESOURCE_VERSION_IN_SERVICE_TOSCA,
1277                     toscas.get(0).getMetadata().get("UUID")));
1278
1279         } catch (Exception e) {
1280             Assert.fail(e.getMessage());
1281         }
1282     }
1283
1284     @Test
1285     public void testArtifactGenerationVerifyMandatoryParameterResourceVersion() {
1286         try {
1287             List<Artifact> inputArtifacts = new ArrayList();
1288             readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
1289
1290             readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
1291             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1292             List<ToscaTemplate> toscas = new LinkedList();
1293             for (Artifact inputArtifact : inputArtifacts) {
1294                 toscas.add(getToscaModel(inputArtifact));
1295             }
1296
1297             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1298             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1299             Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format(GENERATOR_AAI_ERROR_NULL_RESOURCE_VERSION_IN_SERVICE_TOSCA,toscas.get(0).getMetadata().get("UUID")));
1300         } catch (Exception e) {
1301             Assert.fail(e.getMessage());
1302         }
1303     }
1304
1305     @Test
1306     public void testArtifactGenerationWithoutAllottedResource() {
1307         try {
1308             List<Artifact> inputArtifacts = new ArrayList();
1309
1310             readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourceIpmux-template.yml");
1311
1312             readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_IpMux.yml");
1313
1314             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1315             List<ToscaTemplate> toscas = new LinkedList();
1316
1317             for (Artifact inputArtifact : inputArtifacts) {
1318                 toscas.add(getToscaModel(inputArtifact));
1319             }
1320             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1321
1322             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1323             Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format
1324                 (GENERATOR_AAI_PROVIDING_SERVICE_MISSING, toscas.get(1).getModelId()));
1325
1326         } catch (Exception e) {
1327             Assert.fail(e.getMessage());
1328         }
1329     }
1330
1331     @Test
1332     public void testArtifactGenerationAllottedResourceIpmuxWithGroups() {
1333         try {
1334             List<Artifact> inputArtifacts = new ArrayList();
1335
1336             readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourceIpmux-template_WithGroups.yml");
1337
1338             readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_IpMux_WithGroups.yml");
1339
1340             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1341             List<ToscaTemplate> toscas = new LinkedList();
1342
1343             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1344
1345             for (Artifact inputArtifact : inputArtifacts) {
1346                 toscas.add(getToscaModel(inputArtifact));
1347             }
1348             List<Artifact> resultData = data.getResultData();
1349
1350             Map<String, Model> outputArtifactMap = new HashMap<>();
1351             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1352             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1353             testResourceTosca(toscas.iterator(), outputArtifactMap);
1354
1355             Assert.assertEquals(5, data.getResultData().size());
1356
1357             removeMockArtifact(data.getResultData().iterator());
1358
1359             ArtifactGenerationServiceTest.validateName(data.getResultData());
1360
1361         } catch (Exception e) {
1362             Assert.fail(e.getMessage());
1363         }
1364     }
1365
1366     @Test
1367     public void testArtifactGenerationAllottedResourceIpmuxSameInvariantDiffVersion() {
1368         try {
1369             List<Artifact> inputArtifacts = new ArrayList();
1370
1371             readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourcesIpMuxSameInvariant-template.yml");
1372
1373             readPayloadFromResource(inputArtifacts, "resource-AllottedResource1SameInvariant-IpMux-template.yml");
1374
1375             readPayloadFromResource(inputArtifacts, "resource-AllottedResource2SameInvariant-IpMux-template.yml");
1376
1377             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1378             List<ToscaTemplate> toscas = new LinkedList();
1379
1380             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1381
1382             for (Artifact inputArtifact : inputArtifacts) {
1383                 toscas.add(getToscaModel(inputArtifact));
1384             }
1385             List<Artifact> resultData = data.getResultData();
1386
1387             Map<String, Model> outputArtifactMap = new HashMap<>();
1388             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1389             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1390             testResourceTosca(toscas.iterator(), outputArtifactMap);
1391
1392             Assert.assertEquals(5, data.getResultData().size());
1393
1394             removeMockArtifact(data.getResultData().iterator());
1395
1396             ArtifactGenerationServiceTest.validateName(data.getResultData());
1397
1398
1399         } catch (Exception e) {
1400             Assert.fail(e.getMessage());
1401         }
1402     }
1403
1404     @Test
1405     public void testArtifactGenerationAllottedResourceIpmuxSameInvariantSameVersion() {
1406         try {
1407             List<Artifact> inputArtifacts = new ArrayList();
1408
1409             readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourcesIpMuxSameInvariantSameVers-template.yml");
1410
1411             readPayloadFromResource(inputArtifacts, "resource-AllottedResourceSameInvariantSameVers-IpMux-template.yml");
1412
1413             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1414             List<ToscaTemplate> toscas = new LinkedList();
1415
1416             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1417
1418             for (Artifact inputArtifact : inputArtifacts) {
1419                 toscas.add(getToscaModel(inputArtifact));
1420             }
1421             List<Artifact> resultData = data.getResultData();
1422
1423             Map<String, Model> outputArtifactMap = new HashMap<>();
1424             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1425             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1426             testResourceTosca(toscas.iterator(), outputArtifactMap);
1427
1428             Assert.assertEquals(4, data.getResultData().size());
1429
1430             removeMockArtifact(data.getResultData().iterator());
1431
1432             ArtifactGenerationServiceTest.validateName(data.getResultData());
1433
1434
1435         } catch (Exception e) {
1436             Assert.fail(e.getMessage());
1437         }
1438     }
1439
1440     @Test
1441     public void testArtifactGenerationAllottedResourceWithIpMuxAndTunnelXConn() {
1442         try {
1443             List<Artifact> inputArtifacts = new ArrayList();
1444
1445             readPayloadFromResource(inputArtifacts, "service-Allottedipmux-template.yml");
1446
1447             readPayloadFromResource(inputArtifacts, "resource-IpMuxDemux-template.yml");
1448
1449             readPayloadFromResource(inputArtifacts, "resource-TunnelXconn-template.yml");
1450
1451             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1452             List<ToscaTemplate> toscas = new LinkedList();
1453
1454             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1455
1456             for (Artifact inputArtifact : inputArtifacts) {
1457                 toscas.add(getToscaModel(inputArtifact));
1458             }
1459             List<Artifact> resultData = data.getResultData();
1460
1461             Map<String, Model> outputArtifactMap = new HashMap<>();
1462             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1463             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1464             testResourceTosca(toscas.iterator(), outputArtifactMap);
1465
1466             Assert.assertEquals(5, data.getResultData().size());
1467
1468             removeMockArtifact(data.getResultData().iterator());
1469
1470             ArtifactGenerationServiceTest.validateName(data.getResultData());
1471
1472         } catch (Exception e) {
1473             Assert.fail(e.getMessage());
1474         }
1475     }
1476
1477     @Test
1478     public void testArtifactGenerationAllottedResourceWithOutProvidingServiceId() {
1479         try {
1480             List<Artifact> inputArtifacts = new ArrayList();
1481
1482             readPayloadFromResource(inputArtifacts, "service-SdWan-template_WithOutDepSerId.yml");
1483
1484             readPayloadFromResource(inputArtifacts, "resource-VhnfNonHeat-template_WithOutDepSerId.yml");
1485
1486             readPayloadFromResource(inputArtifacts, "resource-TunnelXconn-template_WithOutDepSerId.yml");
1487
1488             readPayloadFromResource(inputArtifacts, "resource-ServiceAdmin-template_WithOutDepSerId.yml");
1489
1490             readPayloadFromResource(inputArtifacts, "resource-IpMuxDemux-template_WithOutDepSerId.yml");
1491
1492             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1493             List<ToscaTemplate> toscas = new LinkedList();
1494             for (Artifact inputArtifact : inputArtifacts) {
1495                 toscas.add(getToscaModel(inputArtifact));
1496             }
1497
1498             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1499             Assert.assertEquals(data.getErrorData().isEmpty(),false);
1500             Assert.assertEquals(data.getErrorData().get("AAI").get(0),String.format
1501                 (GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING, toscas.get(2).getModelId()));
1502         } catch (Exception e) {
1503             Assert.fail(e.getMessage());
1504         }
1505     }
1506
1507     @Test
1508     public void testArtifactGenerationAllottedResourceWithVF() {
1509         try {
1510             List<Artifact> inputArtifacts = new ArrayList();
1511
1512             readPayloadFromResource(inputArtifacts, "service-SdWan-template_AllRes_VF.yml");
1513
1514             readPayloadFromResource(inputArtifacts, "resource-VhnfNonHeat-template_AllRes_VF.yml");
1515
1516             readPayloadFromResource(inputArtifacts, "resource-TunnelXconn-template_AllRes_VF.yml");
1517
1518             readPayloadFromResource(inputArtifacts, "resource-ServiceAdmin-template_AllRes_VF.yml");
1519
1520             readPayloadFromResource(inputArtifacts, "resource-IpMuxDemux-template_AllRes_VF.yml");
1521
1522             ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
1523             List<ToscaTemplate> toscas = new LinkedList();
1524
1525             GenerationData data = obj.generateArtifact(inputArtifacts, GENERATOR_CONFIG, additionalParams);
1526             for (Artifact inputArtifact : inputArtifacts) {
1527                 toscas.add(getToscaModel(inputArtifact));
1528             }
1529             List<Artifact> resultData = data.getResultData();
1530
1531             Map<String, Model> outputArtifactMap = new HashMap<>();
1532             ArtifactGenerationServiceTest.populateAAIGeneratedModelStore(outputArtifactMap, resultData);
1533             ArtifactGenerationServiceTest.testServiceTosca(outputArtifactMap, toscas);
1534             testResourceTosca(toscas.iterator(), outputArtifactMap);
1535
1536             Assert.assertEquals(7, data.getResultData().size());
1537
1538             removeMockArtifact(data.getResultData().iterator());
1539
1540             ArtifactGenerationServiceTest.validateName(data.getResultData());
1541         } catch (Exception e) {
1542             Assert.fail(e.getMessage());
1543         }
1544     }
1545
1546     public static void readPayload(List<Artifact> inputArtifacts,InputStream fis, String fileName) throws IOException {
1547         byte[] payload = new byte[fis.available()];
1548         fis.read(payload);
1549         String checksum = GeneratorUtil.checkSum(payload);
1550         byte[] encodedPayload = GeneratorUtil.encode(payload);
1551         Artifact artifact = new Artifact(AAI_ARTIFACT_TYPE, AAI_ARTIFACT_GROUP_TYPE, checksum, encodedPayload);
1552         artifact.setName(fileName);
1553         artifact.setLabel(fileName);
1554         artifact.setDescription(fileName);
1555         inputArtifacts.add(artifact);
1556     }
1557
1558
1559     /**
1560      * Get the tosca java model from the tosca input artifact
1561      *
1562      * @param input Input tosca file and its metadata information as {@link Artifact} object
1563      * @return Translated {@link ToscaTemplate tosca} object
1564      * @throws SecurityException
1565      */
1566     public static ToscaTemplate getToscaModel(Artifact input) {
1567         byte[] decodedInput = GeneratorUtil.decoder(input.getPayload());
1568         String checksum = GeneratorUtil.checkSum(decodedInput);
1569         if (checksum.equals(input.getChecksum())) {
1570             try {
1571                 return GeneratorUtil.translateTosca(new String(decodedInput), ToscaTemplate.class);
1572             } catch (Exception e) {
1573                 throw new IllegalArgumentException(String.format(GENERATOR_AAI_ERROR_INVALID_TOSCA, input.getName()));
1574             }
1575         } else {
1576             throw new SecurityException(String.format(GENERATOR_AAI_ERROR_CHECKSUM_MISMATCH, input.getName()));
1577         }
1578     }
1579
1580     public static void removeMockArtifact(Iterator<Artifact> itr) {
1581         while (itr.hasNext()){
1582             if(itr.next().getType().equals("OTHER")){
1583                 itr.remove();
1584             }
1585         }
1586     }
1587
1588     private void readPayloadFromResource(List<Artifact> inputArtifacts, String fileName) throws IOException {
1589
1590         try (InputStream fis = SampleJUnitTest.class.getResourceAsStream("/" + fileName)) {
1591             readPayload(inputArtifacts, fis, fileName);
1592         }
1593     }
1594 }