[MSO-8] Update the maven dependency
[so.git] / packages / arquillian-unit-tests / src / test / java / org / openecomp / mso / global_tests / asdc / ASDCITCase.java
1 package org.openecomp.mso.global_tests.asdc;
2
3 import static org.junit.Assert.*;
4
5 import java.io.File;
6 import java.io.IOException;
7 import java.lang.reflect.Method;
8 import java.net.URISyntaxException;
9 import java.security.NoSuchAlgorithmException;
10 import java.util.HashMap;
11 import java.util.List;
12 import java.util.Map;
13 import java.util.LinkedList;
14
15 import org.jboss.arquillian.container.test.api.Deployment;
16 import org.jboss.arquillian.container.test.api.OperateOnDeployment;
17 import org.jboss.arquillian.container.test.api.Testable;
18 import org.jboss.arquillian.junit.Arquillian;
19 import org.jboss.shrinkwrap.api.Archive;
20 import org.jboss.shrinkwrap.api.ShrinkWrap;
21 import org.jboss.shrinkwrap.api.spec.JavaArchive;
22 import org.jboss.shrinkwrap.api.spec.WebArchive;
23 import org.jboss.shrinkwrap.resolver.api.maven.Maven;
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.BeforeClass;
27 import org.junit.AfterClass;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30
31 import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
32 import org.openecomp.sdc.api.notification.IArtifactInfo;
33 import org.openecomp.sdc.api.notification.IResourceInstance;
34 import org.openecomp.mso.asdc.installer.VfModuleMetaData;
35 import org.openecomp.mso.asdc.installer.IVfModuleData;
36 import org.openecomp.sdc.utils.DistributionStatusEnum;
37 import org.openecomp.mso.asdc.client.ASDCConfiguration;
38 import org.openecomp.mso.asdc.client.ASDCController;
39 import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException;
40 import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException;
41 import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
42 import org.openecomp.mso.db.catalog.CatalogDatabase;
43 import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
44 import org.openecomp.mso.db.catalog.beans.HeatFiles;
45 import org.openecomp.mso.db.catalog.beans.HeatTemplate;
46 import org.openecomp.mso.db.catalog.beans.Service;
47 import org.openecomp.mso.db.catalog.beans.VfModule;
48 import org.openecomp.mso.db.catalog.beans.VnfResource;
49 import org.openecomp.mso.global_tests.ArquillianPackagerForITCases;
50 import org.openecomp.mso.global_tests.asdc.notif_emulator.DistributionClientEmulator;
51 import org.openecomp.mso.global_tests.asdc.notif_emulator.JsonNotificationData;
52
53 @RunWith(Arquillian.class)
54 public class ASDCITCase {
55
56         /**
57          * Add the resources in the right folder of a jar
58          * @param jar The jarArchive
59          * @param dir The main dir containing things that must be added
60          * @throws Exception In case of issues with the files
61          */
62         private static void addFiles(JavaArchive jar, File dir,String destFolder) throws Exception  {
63
64                 if (!dir.isDirectory()) {
65                         throw new Exception("not a directory");
66                 }
67                 for (File f : dir.listFiles()) {
68
69
70                         if (f.isFile()) {
71                                 jar.addAsResource(f, destFolder + "/" + f.getName());
72                         } else {
73
74                                 addFiles(jar, f, destFolder+"/"+f.getName());
75                         }
76                 }
77         }
78
79         @Deployment(name="asdc-controller",testable=true)
80         public static Archive<?> createAsdcControllerWarDeployment () throws Exception {
81                 System.out.println("Deploying ASDC Controller WAR with additional resources on default server");
82
83                 WebArchive warArchive = (WebArchive)ArquillianPackagerForITCases.createPackageFromExistingOne("../../asdc-controller/target/", "asdc-controller*.war", "asdc-controller.war");
84
85                 // Add the current test class
86                 JavaArchive testclasses = ShrinkWrap.create (JavaArchive.class, "testClasses.jar");
87
88                 testclasses.addPackage("org.openecomp.mso.global_tests.asdc.notif_emulator");
89
90                 addFiles(testclasses,new File(Thread.currentThread().getContextClassLoader().getResource("resource-examples/asdc").getFile()),"resource-examples/asdc");
91
92                 System.out.println(testclasses.toString(true));
93                 warArchive.addAsLibraries(testclasses);
94
95
96
97                 // BE CAREFUL a settings.xml file must be located in ${home.user}/.m2/settings.xml
98                 warArchive.addAsLibraries(Maven.resolver()
99                                 .resolve("org.mockito:mockito-all:1.10.19")
100                                 .withoutTransitivity ()
101                                 .asFile ());
102
103                 //warArchive.addPackage("org.openecomp.mso.global_tests.asdc.notif_emulator");
104                 //addFiles(warArchive,new File(ASDCITCase.class.getClassLoader().getResource("resource-examples").getPath()),"resource-examples");
105
106                 // Take one war randomly to make arquilian happy
107                 Testable.archiveToTest(warArchive);
108
109
110                 System.out.println(warArchive.toString(true));
111
112                 return warArchive;
113         }
114
115         @BeforeClass
116         public static final void waitBeforeStart() throws InterruptedException,
117                         IOException,
118                         URISyntaxException,
119                         NoSuchAlgorithmException {
120                 System.out.println("Executing " + ASDCITCase.class.getName());
121         }
122
123         @AfterClass
124         public static final void waitAfterStart() throws InterruptedException,
125                         IOException,
126                         URISyntaxException,
127                         NoSuchAlgorithmException {
128                 System.out.println("Waiting 60000ms " + ASDCITCase.class.getName());
129                 Thread.sleep(60000);
130         }
131
132         /**
133          * Be careful when using that notification fake structure, the UUID of notif artifacts MUST be different.
134          * There is a static Map behind the scene.
135          */
136         private JsonNotificationData notifDataWithoutModuleInfo;
137         private DistributionClientEmulator distribClientWithoutModuleInfo;
138
139         private JsonNotificationData notifDataV1, notifDataV2, notifDataV3, notifDataV4, notifDataV5,notifDataDNS,notifDataVFW;
140         private DistributionClientEmulator distribClientV1, distribClientV2, distribClientV3, distribClientV4, distribClientV5, distribClientV1ForSameNotif, distribClientDNS,distribClientVFW;
141
142
143         @Before
144         public final void beforeEachTest() throws IOException {
145
146                 distribClientV1= new DistributionClientEmulator("/resource-examples/asdc/simpleNotif-V1");
147                 distribClientV1ForSameNotif= new DistributionClientEmulator("/resource-examples/asdc/simpleNotif-V1");
148                 notifDataV1 = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/simpleNotif-V1");
149
150                 // This is a duplicate in version 2 of the version 1
151                 distribClientV2= new DistributionClientEmulator("/resource-examples/asdc/simpleNotif-V2");
152                 notifDataV2 = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/simpleNotif-V2");
153
154                 distribClientV3= new DistributionClientEmulator("/resource-examples/asdc/simpleNotif-V3");
155                 notifDataV3 = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/simpleNotif-V3");
156
157                 // This is a duplicate in version 4 of the version 3
158                 distribClientV4= new DistributionClientEmulator("/resource-examples/asdc/simpleNotif-V4");
159                 notifDataV4 = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/simpleNotif-V4");
160
161                 // This notification is to test the deployment of volume with nested + an artifact not used (should send notification with DEPLOY_ERROR
162                 distribClientV5= new DistributionClientEmulator("/resource-examples/asdc/simpleNotif-V5");
163                 notifDataV5 = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/simpleNotif-V5");
164
165
166                 distribClientWithoutModuleInfo= new DistributionClientEmulator("/resource-examples/asdc/notif-without-modules-metadata");
167                 notifDataWithoutModuleInfo = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/notif-without-modules-metadata");
168
169
170                 distribClientDNS= new DistributionClientEmulator("/resource-examples/asdc/demo-dns-V1");
171                 notifDataDNS = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/demo-dns-V1");
172
173
174                 distribClientVFW= new DistributionClientEmulator("/resource-examples/asdc/demo-vfw-V1");
175                 notifDataVFW = JsonNotificationData.instantiateNotifFromJsonFile("/resource-examples/asdc/demo-vfw-V1");
176
177
178         }
179
180         @Test
181         @OperateOnDeployment("asdc-controller")
182         public void testNotifWithoutModuleInfo () throws NoSuchAlgorithmException,
183                         IOException,
184                         URISyntaxException,
185                         ArtifactInstallerException, ASDCControllerException, ASDCParametersException {
186
187
188
189                 ASDCController asdcController = new ASDCController("asdc-controller1", distribClientWithoutModuleInfo);
190                 asdcController.initASDC();
191                 asdcController.treatNotification(notifDataWithoutModuleInfo);
192
193                 assertTrue(distribClientWithoutModuleInfo.getDistributionMessageReceived().size() > 0);
194
195                 int badDeployment=0;
196                 for (IDistributionStatusMessage message:distribClientWithoutModuleInfo.getDistributionMessageReceived()) {
197                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
198                         if(message.getStatus().equals(DistributionStatusEnum.DEPLOY_ERROR)) {
199                                 badDeployment++;
200                         }
201                 }
202                 assertTrue(badDeployment == 3);
203
204                 // Check if something has been recorder in DB, as it should not
205                 CatalogDatabase catalogDB = new CatalogDatabase();
206
207                 HeatTemplate heatTemplate = catalogDB.getHeatTemplate("Whot-nimbus-oam_v1.0.yaml", "1.0", "resourceName-1");
208                 assertNull(heatTemplate);
209         }
210
211         private void validateVnfResource(JsonNotificationData inputNotification, List<IVfModuleData> moduleList) {
212
213                 CatalogDatabase catalogDB = new CatalogDatabase();
214
215
216                 for (IResourceInstance resource:inputNotification.getResources()) {
217                         VnfResource vnfResourceDB = catalogDB.getVnfResource(inputNotification.getServiceName()+"/"+resource.getResourceInstanceName(), inputNotification.getServiceVersion());
218                         assertNotNull(vnfResourceDB);
219
220                         assertTrue(vnfResourceDB.getAsdcUuid().equals(resource.getResourceUUID()));
221                         assertTrue(vnfResourceDB.getDescription().equals(inputNotification.getServiceDescription()));
222                         assertTrue(vnfResourceDB.getModelInvariantUuid().equals(resource.getResourceInvariantUUID()));
223                         assertTrue(vnfResourceDB.getModelVersion().equals(resource.getResourceVersion()));
224                         assertTrue(vnfResourceDB.getOrchestrationMode().equals("HEAT"));
225                         assertTrue(vnfResourceDB.getVersion().equals(inputNotification.getServiceVersion()));
226                         assertTrue(vnfResourceDB.getVnfType().equals(inputNotification.getServiceName()+"/"+resource.getResourceInstanceName()));
227                         assertTrue(vnfResourceDB.getModelCustomizationName().equals(resource.getResourceInstanceName()));
228                         assertTrue(vnfResourceDB.getModelName().equals(resource.getResourceName()));
229                         assertTrue(vnfResourceDB.getServiceModelInvariantUUID().equals(inputNotification.getServiceInvariantUUID()));
230
231                         for (IVfModuleData module:moduleList) {
232
233                                 VfModule vfModuleDB = catalogDB.getVfModuleModelName(module.getVfModuleModelName(),inputNotification.getServiceVersion());
234                                 assertNotNull(vfModuleDB);
235                                 assertTrue(module.getVfModuleModelName().equals(vfModuleDB.getModelName()));
236
237                                 assertTrue((inputNotification.getServiceName()+"/"+resource.getResourceInstanceName()+"::"+vfModuleDB.getModelName()).equals(vfModuleDB.getType()));
238                                 assertTrue(vnfResourceDB.getId()!=0);
239                                 assertNotNull(vfModuleDB.getVnfResourceId());
240
241                                 assertTrue(vnfResourceDB.getId()==vfModuleDB.getVnfResourceId().intValue());
242
243                                 for (String artifactUUID:module.getArtifacts()) {
244                                         IArtifactInfo artifact = null;
245                                         for (IArtifactInfo artifactTemp:resource.getArtifacts()) {
246                                                 if (artifactTemp.getArtifactUUID().equals(artifactUUID)) {
247                                                         artifact = artifactTemp;
248                                                         break;
249                                                 }
250                                         }
251                                         assertNotNull(artifact);
252
253                                         switch (artifact.getArtifactType()) {
254                                                 case ASDCConfiguration.HEAT:
255                                                         HeatTemplate heatTemplateDB= catalogDB.getHeatTemplate(vfModuleDB.getTemplateId());
256                                                         assertNotNull(heatTemplateDB);
257                                                         assertTrue(heatTemplateDB.getAsdcResourceName().equals(resource.getResourceName()));
258                                                         assertTrue(heatTemplateDB.getAsdcUuid().equals(artifact.getArtifactUUID()));
259                                                         assertTrue(heatTemplateDB.getDescription().equals(artifact.getArtifactDescription()));
260                                                         assertTrue(heatTemplateDB.getTemplateBody() != null && !heatTemplateDB.getTemplateBody().isEmpty());
261                                                         assertTrue(heatTemplateDB.getParameters().size()>0);
262
263                                                         assertTrue(heatTemplateDB.getTemplateName().equals(artifact.getArtifactName()));
264
265                                                         if (artifact.getArtifactTimeout() != null) {
266                                                                 assertTrue(heatTemplateDB.getTimeoutMinutes()== artifact.getArtifactTimeout().intValue());
267                                                         } else {
268                                                                 assertTrue(heatTemplateDB.getTimeoutMinutes()== 240);
269                                                         }
270                                                         assertTrue(heatTemplateDB.getVersion().equals(artifact.getArtifactVersion()));
271
272                                                         assertFalse(heatTemplateDB.getTemplateBody().contains("file:///"));
273                                                         break;
274                                                 case ASDCConfiguration.HEAT_ENV:
275
276                                                         HeatEnvironment heatEnvironmentDB = catalogDB.getHeatEnvironment(artifact.getArtifactName(), artifact.getArtifactVersion(), inputNotification.getServiceName()+"/"+resource.getResourceInstanceName());
277
278                                                         assertNotNull(heatEnvironmentDB);
279                                                         assertTrue((vfModuleDB.getVolEnvironmentId() != null && vfModuleDB.getVolEnvironmentId().intValue() == heatEnvironmentDB.getId())
280                                                                         || (vfModuleDB.getEnvironmentId() != null && vfModuleDB.getEnvironmentId() == heatEnvironmentDB.getId()));
281
282                                                         assertTrue(heatEnvironmentDB.getAsdcResourceName().equals(inputNotification.getServiceName()+"/"+resource.getResourceInstanceName()));
283
284                                                         assertTrue(heatEnvironmentDB.getAsdcUuid().equals(artifact.getArtifactUUID()));
285                                                         assertTrue(heatEnvironmentDB.getDescription().equals(artifact.getArtifactDescription()));
286                                                         assertTrue(heatEnvironmentDB.getVersion().equals(artifact.getArtifactVersion()));
287                                                         assertTrue(heatEnvironmentDB.getName().equals(artifact.getArtifactName()));
288                                                         assertTrue(heatEnvironmentDB.getEnvironment() != null);
289                                                         assertFalse(heatEnvironmentDB.getEnvironment().contains("file:///"));
290
291                                                         break;
292                                                 case ASDCConfiguration.HEAT_NESTED:
293                                                         Map<String,Object> listNestedDBMainHeat=new HashMap<String,Object>();
294                                                         Map<String,Object> listNestedDBVolHeat=new HashMap<String,Object>();
295
296                                                         if (vfModuleDB.getTemplateId() != null) {
297                                                                 listNestedDBMainHeat = catalogDB.getNestedTemplates(vfModuleDB.getTemplateId());
298                                                         }
299                                                         if (vfModuleDB.getVolTemplateId() != null) {
300                                                                 listNestedDBVolHeat = catalogDB.getNestedTemplates(vfModuleDB.getVolTemplateId());
301                                                         }
302
303                                                         assertTrue(listNestedDBMainHeat.size() > 0 || listNestedDBVolHeat.size() > 0);
304
305
306                                                         assertTrue(listNestedDBMainHeat.get(artifact.getArtifactName()) != null
307                                                                         || listNestedDBVolHeat.get(artifact.getArtifactName()) != null);
308
309                                                         HeatTemplate rightNestedTemplateDB = catalogDB.getHeatTemplate(artifact.getArtifactName(), artifact.getArtifactVersion(), resource.getResourceName());
310                                                         assertNotNull(rightNestedTemplateDB);
311                                                         assertTrue(catalogDB.getNestedHeatTemplate(vfModuleDB.getTemplateId(), rightNestedTemplateDB.getId()) != null || catalogDB.getNestedHeatTemplate(vfModuleDB.getVolTemplateId(), rightNestedTemplateDB.getId()) != null);
312
313                                                         assertTrue(rightNestedTemplateDB.getAsdcResourceName().equals(resource.getResourceName()));
314                                                         assertTrue(rightNestedTemplateDB.getAsdcUuid().equals(artifact.getArtifactUUID()));
315                                                         assertTrue(rightNestedTemplateDB.getDescription().equals(artifact.getArtifactDescription()));
316                                                         assertTrue(rightNestedTemplateDB.getTemplateBody() != null && !rightNestedTemplateDB.getTemplateBody().isEmpty());
317                                                         assertTrue(rightNestedTemplateDB.getTemplateName().equals(artifact.getArtifactName()));
318
319                                                         if (artifact.getArtifactTimeout() != null) {
320                                                                 assertTrue(rightNestedTemplateDB.getTimeoutMinutes()== artifact.getArtifactTimeout().intValue());
321                                                         } else {
322                                                                 assertTrue(rightNestedTemplateDB.getTimeoutMinutes()== 240);
323                                                         }
324                                                         assertTrue(rightNestedTemplateDB.getVersion().equals(artifact.getArtifactVersion()));
325                                                         assertFalse(rightNestedTemplateDB.getTemplateBody().contains("file:///"));
326
327                                                         break;
328                                                 case ASDCConfiguration.HEAT_VOL:
329                                                         HeatTemplate heatTemplateVolDB = catalogDB.getHeatTemplate(vfModuleDB.getVolTemplateId());
330                                                         assertNotNull(heatTemplateVolDB);
331
332                                                         assertTrue(heatTemplateVolDB.getAsdcResourceName().equals(resource.getResourceName()));
333                                                         assertTrue(heatTemplateVolDB.getAsdcUuid().equals(artifact.getArtifactUUID()));
334                                                         assertTrue(heatTemplateVolDB.getDescription().equals(artifact.getArtifactDescription()));
335                                                         assertTrue(heatTemplateVolDB.getTemplateBody() != null && !heatTemplateVolDB.getTemplateBody().isEmpty());
336                                                         assertTrue(heatTemplateVolDB.getTemplateName().equals(artifact.getArtifactName()));
337
338                                                         if (artifact.getArtifactTimeout() != null) {
339                                                                 assertTrue(heatTemplateVolDB.getTimeoutMinutes()== artifact.getArtifactTimeout().intValue());
340                                                         } else {
341                                                                 assertTrue(heatTemplateVolDB.getTimeoutMinutes()== 240);
342                                                         }
343                                                         assertTrue(heatTemplateVolDB.getVersion().equals(artifact.getArtifactVersion()));
344                                                         assertFalse(heatTemplateVolDB.getTemplateBody().contains("file:///"));
345
346                                                         break;
347                                                 case ASDCConfiguration.HEAT_ARTIFACT:
348                                                         Map<String,HeatFiles> heatFilesDB= catalogDB.getHeatFilesForVfModule(vfModuleDB.getId());
349                                                         assertTrue(heatFilesDB.size()>0);
350                                                         HeatFiles rightHeatFilesDB=heatFilesDB.get( artifact.getArtifactName());
351                                                         assertNotNull(rightHeatFilesDB);
352
353                                                         assertTrue(rightHeatFilesDB.getAsdcResourceName().equals(resource.getResourceName()));
354                                                         assertTrue(rightHeatFilesDB.getAsdcUuid().equals(artifact.getArtifactUUID()));
355                                                         assertTrue(rightHeatFilesDB.getDescription().equals(artifact.getArtifactDescription()));
356                                                         assertTrue(rightHeatFilesDB.getFileBody() != null && !rightHeatFilesDB.getFileBody().isEmpty());
357                                                         assertTrue(rightHeatFilesDB.getFileName().equals( artifact.getArtifactName()));
358                                                         assertTrue(rightHeatFilesDB.getVersion().equals(artifact.getArtifactVersion()));
359
360                                                         break;
361                                                 default:
362                                                         break;
363
364                                         }
365                                 }
366
367                         }
368
369                 }
370
371                 Service service = catalogDB.getServiceByUUID(inputNotification.getServiceUUID());
372                 assertNotNull(service);
373                 assertTrue(service.getCreated() !=null && service.getCreated().getTime()>0);
374                 assertTrue(service.getDescription().equals(inputNotification.getServiceDescription()));
375                 assertTrue(service.getId()>0);
376                 assertTrue(service.getModelInvariantUUID().equals(inputNotification.getServiceInvariantUUID()));
377                 assertTrue(service.getServiceName().equals(inputNotification.getServiceName()));
378                 assertTrue(service.getServiceNameVersionId().equals(inputNotification.getServiceUUID()));
379                 assertTrue(service.getVersion().equals(inputNotification.getServiceVersion()));
380
381         }
382
383         @Test
384         @OperateOnDeployment("asdc-controller")
385         public void testNotifsDeployment () throws NoSuchAlgorithmException,
386                         IOException,
387                         URISyntaxException,
388                         ArtifactInstallerException, ASDCControllerException, ASDCParametersException {
389
390
391
392                 ASDCController asdcControllerV1 = new ASDCController("asdc-controller1", distribClientV1);
393                 asdcControllerV1.initASDC();
394                 asdcControllerV1.treatNotification(notifDataV1);
395
396                 assertTrue(distribClientV1.getDistributionMessageReceived().size() > 0);
397                 for (IDistributionStatusMessage message:distribClientV1.getDistributionMessageReceived()) {
398                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
399                         assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
400                 }
401
402                 this.validateVnfResource(notifDataV1,distribClientV1.getListVFModuleMetaData());
403
404
405
406                 // Try again to load the same notif
407                 ASDCController asdcControllerNewNotif = new ASDCController("asdc-controller1", distribClientV1ForSameNotif);
408                 asdcControllerNewNotif.initASDC();
409                 asdcControllerNewNotif.treatNotification(notifDataV1);
410
411                 for (IDistributionStatusMessage message:distribClientV1ForSameNotif.getDistributionMessageReceived()) {
412                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
413                         assertTrue(message.getStatus().equals(DistributionStatusEnum.ALREADY_DEPLOYED) || message.getStatus().equals(DistributionStatusEnum.ALREADY_DOWNLOADED));
414                 }
415
416
417                 // Try again to load same notif but in V2
418                 ASDCController asdcControllerV2 = new ASDCController("asdc-controller1", distribClientV2);
419                 asdcControllerV2.initASDC();
420                 asdcControllerV2.treatNotification(notifDataV2);
421
422                 for (IDistributionStatusMessage message:distribClientV2.getDistributionMessageReceived()) {
423                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
424                         assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
425                 }
426
427                 this.validateVnfResource(notifDataV2,distribClientV2.getListVFModuleMetaData());
428
429
430                 // Try again to load same notif + Script + Volume artifacts and in service V3
431                 ASDCController asdcControllerV3 = new ASDCController("asdc-controller1", distribClientV3);
432                 asdcControllerV3.initASDC();
433                 asdcControllerV3.treatNotification(notifDataV3);
434
435                 for (IDistributionStatusMessage message:distribClientV3.getDistributionMessageReceived()) {
436                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
437                         assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
438                 }
439
440                 this.validateVnfResource(notifDataV3,distribClientV3.getListVFModuleMetaData());
441
442                 // Try again to load same notif + Script + Volume artifacts and in service V4
443                 ASDCController asdcControllerV4 = new ASDCController("asdc-controller1", distribClientV4);
444                 asdcControllerV4.initASDC();
445                 asdcControllerV4.treatNotification(notifDataV4);
446
447                 for (IDistributionStatusMessage message:distribClientV4.getDistributionMessageReceived()) {
448                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
449                         assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
450                 }
451
452                 this.validateVnfResource(notifDataV4,distribClientV4.getListVFModuleMetaData());
453
454
455                 // Try again with service V5 (Nested template attached to Volume + HEat artifact not used by module),
456                 //this should force the notification DEPLOY_ERROR to be sent for this artifact
457                 ASDCController asdcControllerV5 = new ASDCController("asdc-controller1", distribClientV5);
458                 asdcControllerV5.initASDC();
459                 asdcControllerV5.treatNotification(notifDataV5);
460
461                 for (IDistributionStatusMessage message:distribClientV5.getDistributionMessageReceived()) {
462                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
463                         if ("cloud-nimbus.sh".equals(message.getArtifactURL())) {
464                                 assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_ERROR) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
465                         } else {
466                                 assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
467                         }
468                 }
469
470                 this.validateVnfResource(notifDataV5,distribClientV5.getListVFModuleMetaData());
471
472
473                 // Try again with demo DNS
474                 ASDCController asdcControllerDNS = new ASDCController("asdc-controller1", distribClientDNS);
475                 asdcControllerDNS.initASDC();
476                 asdcControllerDNS.treatNotification(notifDataDNS);
477
478                 for (IDistributionStatusMessage message:distribClientDNS.getDistributionMessageReceived()) {
479                         System.out.println("Message received, URL:"+message.getArtifactURL()+", Value:"+message.getStatus().name());
480                                 assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK) || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
481                 }
482
483                 this.validateVnfResource(notifDataDNS,distribClientDNS.getListVFModuleMetaData());
484
485                 // Try again with demo VFW
486                 ASDCController asdcControllerVFW = new ASDCController("asdc-controller1", distribClientVFW);
487                 asdcControllerVFW.initASDC();
488                 asdcControllerVFW.treatNotification(notifDataVFW);
489
490                 for (IDistributionStatusMessage message : distribClientVFW.getDistributionMessageReceived()) {
491                         System.out.println("Message received, URL:" + message.getArtifactURL() + ", Value:" + message.getStatus().name());
492                         assertTrue(message.getStatus().equals(DistributionStatusEnum.DEPLOY_OK)
493                                                 || message.getStatus().equals(DistributionStatusEnum.DOWNLOAD_OK));
494                 }
495
496                 this.validateVnfResource(notifDataVFW, distribClientVFW.getListVFModuleMetaData());
497
498         }
499 }