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