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