Containerization feature of SO
[so.git] / asdc-controller / src / test / java / org / onap / so / asdc / installer / heat / ToscaResourceInstallerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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.onap.so.asdc.installer.heat;
22
23 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
24 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
25 import static org.junit.Assert.assertEquals;
26
27 import static org.junit.Assert.assertNull;
28 import static org.mockito.Matchers.any;
29 import static org.mockito.Mockito.doNothing;
30 import static org.mockito.Mockito.doReturn;
31 import static org.mockito.Mockito.doThrow;
32 import static org.mockito.Mockito.mock;
33 import static org.mockito.Mockito.spy;
34 import static org.mockito.Mockito.times;
35 import static org.mockito.Mockito.verify;
36 import static org.mockito.Mockito.when;
37
38 import java.io.File;
39 import java.io.FileInputStream;
40 import java.util.ArrayList;
41 import java.util.Collection;
42 import java.util.HashMap;
43 import java.util.Iterator;
44 import java.util.List;
45
46 import javax.transaction.Transactional;
47
48 import org.apache.commons.io.IOUtils;
49 import org.hibernate.exception.LockAcquisitionException;
50 import org.junit.Before;
51 import org.junit.Ignore;
52 import org.junit.Rule;
53 import org.junit.Test;
54 import org.junit.rules.ExpectedException;
55 import org.mockito.Mock;
56 import org.mockito.MockitoAnnotations;
57 import org.onap.sdc.api.notification.IResourceInstance;
58 import org.onap.sdc.api.results.IDistributionClientDownloadResult;
59 import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl;
60 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
61 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
62 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
63 import org.onap.sdc.toscaparser.api.Group;
64 import org.onap.sdc.toscaparser.api.NodeTemplate;
65 import org.onap.sdc.toscaparser.api.elements.Metadata;
66 import org.onap.sdc.utils.DistributionStatusEnum;
67 import org.onap.so.asdc.BaseTest;
68 import org.onap.so.asdc.client.ASDCConfiguration;
69 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
70 import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl;
71 import org.onap.so.asdc.client.test.emulators.JsonStatusData;
72 import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
73 import org.onap.so.asdc.installer.VfModuleArtifact;
74 import org.onap.so.asdc.installer.VfResourceStructure;
75 import org.onap.so.db.catalog.beans.AllottedResource;
76 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
77 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
78 import org.onap.so.db.catalog.beans.HeatTemplate;
79 import org.onap.so.db.catalog.beans.NetworkResource;
80 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
81 import org.onap.so.db.catalog.beans.Service;
82 import org.onap.so.db.catalog.beans.VnfResource;
83 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
84 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
85 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
86 import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
87 import org.onap.so.db.catalog.data.repository.ServiceRepository;
88 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
89 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
90 import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
91 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
92 import org.springframework.beans.factory.annotation.Autowired;
93
94 public class ToscaResourceInstallerTest extends BaseTest {
95         @Autowired
96         private ToscaResourceInstaller toscaInstaller;
97         @Autowired
98         private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
99         @Autowired
100         private AllottedResourceRepository allottedRepo;
101         @Autowired
102         private AllottedResourceCustomizationRepository allottedCustomizationRepo;
103         @Autowired
104         private ServiceRepository serviceRepo;
105         @Autowired
106         private ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
107         @Mock
108         private SdcCsarHelperImpl sdcCsarHelper;
109         @Mock
110         private Metadata metadata;
111         @Mock
112         private ArtifactInfoImpl artifactInfo;
113         @Mock
114         private List<Group> vfGroups;
115         @Mock
116         private IResourceInstance resourceInstance;
117         @Rule
118         public ExpectedException expectedException = ExpectedException.none();
119
120         private NotificationDataImpl notificationData;
121         private JsonStatusData statusData;
122         private static final String MSO = "SO";
123
124         private AllottedResource allottedResource;
125         private AllottedResourceCustomization allottedResourceCustomization;
126         private Service catalogService;
127
128         @Before
129         public void before() {
130                 MockitoAnnotations.initMocks(this);
131                 
132                 notificationData = new NotificationDataImpl();
133                 statusData = new JsonStatusData();
134         }
135         
136         @Test
137         public void isResourceAlreadyDeployedTest() throws Exception {
138                 notificationData.setServiceName("serviceName");
139                 notificationData.setServiceVersion("123456");
140                 notificationData.setServiceUUID("serviceUUID");
141                 notificationData.setDistributionID("testStatusSuccessTosca");
142                 
143                 WatchdogComponentDistributionStatus expectedComponentDistributionStatus = 
144                                 new WatchdogComponentDistributionStatus(notificationData.getDistributionID(), MSO);
145                 expectedComponentDistributionStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
146                 
147                 doReturn(true).when(vfResourceStructure).isDeployedSuccessfully();
148                 doReturn(notificationData).when(vfResourceStructure).getNotification();
149                 doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
150                 doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
151                 doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
152                 doReturn("resourceName").when(resourceInstance).getResourceName();
153                 
154                 toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
155                 
156                 WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
157                 
158                 verify(vfResourceStructure, times(3)).getResourceInstance();
159                 verify(vfResourceStructure, times(5)).getNotification();
160                 assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedComponentDistributionStatus)
161                                 .ignoring("createTime")
162                                 .ignoring("modifyTime"));
163         }
164         
165         @Test
166         public void isResourceAlreadyDeployedFalseTest() throws Exception {
167                 notificationData.setServiceName("serviceName");
168                 notificationData.setServiceVersion("123456");
169                 notificationData.setServiceUUID("serviceUUID");
170                 notificationData.setDistributionID("testStatusSuccess");
171                 
172                 doThrow(RuntimeException.class).when(vfResourceStructure).isDeployedSuccessfully();
173                 doReturn(notificationData).when(vfResourceStructure).getNotification();
174                 doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
175                 doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
176                 doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
177                 doReturn("resourceName").when(resourceInstance).getResourceName();
178                 
179                 toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
180                 
181                 verify(vfResourceStructure, times(3)).getResourceInstance();
182                 verify(vfResourceStructure, times(4)).getNotification();
183         }
184         
185         @Test
186         public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
187                 expectedException.expect(ArtifactInstallerException.class);
188                 
189                 toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
190         }
191         
192         @Test
193         public void installTheComponentStatusTest() throws Exception {
194                 String distributionId = "testStatusSuccessTosca";
195                 String componentName = "testComponentName";
196                 
197                 statusData = spy(JsonStatusData.class);
198                 doReturn(distributionId).when(statusData).getDistributionID();
199                 doReturn(componentName).when(statusData).getComponentName();
200                 
201                 WatchdogComponentDistributionStatus expectedWatchdogComponentDistributionStatus = 
202                                 new WatchdogComponentDistributionStatus(distributionId, componentName);
203                 expectedWatchdogComponentDistributionStatus.setComponentDistributionStatus(statusData.getStatus().toString());
204                 
205                 WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(statusData.getDistributionID(),
206                                 statusData.getComponentName());
207                 
208                 toscaInstaller.installTheComponentStatus(statusData);
209                 
210                 WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId("testStatusSuccessTosca"), statusData.getComponentName());
211                 
212                 assertEquals(statusData.getDistributionID(), cdStatus.getDistributionId());
213                 assertEquals(statusData.getComponentName(), cdStatus.getComponentName());
214                 assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedWatchdogComponentDistributionStatus)
215                                 .ignoring("createTime")
216                                 .ignoring("modifyTime"));
217         }
218         
219         @Test
220         public void installTheComponentStatusExceptionTest() throws ArtifactInstallerException {
221                 expectedException.expect(ArtifactInstallerException.class);
222                 
223                 statusData = spy(JsonStatusData.class);
224                 doReturn(null).when(statusData).getStatus();
225                 
226                 toscaInstaller.installTheComponentStatus(statusData);
227         }
228         
229         @Test
230         @Ignore
231         @Transactional
232         public void installTheResourceTest() throws Exception {
233                 notificationData.setDistributionID("testStatusSuccessTosca");
234                 notificationData.setServiceVersion("123456");
235                 notificationData.setServiceUUID("5df8b6de-2083-11e7-93ae-92361f002671");
236                 notificationData.setWorkloadContext("workloadContext");
237                 
238                 HashMap<String, VfModuleArtifact> vfModuleArtifacts = mock(HashMap.class);
239                 CapabilityAssignments capabilityAssignments = mock(CapabilityAssignments.class);
240                 CapabilityAssignment capabilityAssignment = mock(CapabilityAssignment.class);
241                 
242                 vfResourceStructure = spy(new VfResourceStructure(notificationData, resourceInstance));
243                 
244                 VnfResource vnfResource = new VnfResource();
245                 vnfResource.setModelName("modelName");
246                 vnfResource.setModelVersion("1.1");
247                 vnfResource.setModelUUID("modelUUID");
248                 vnfResource.setOrchestrationMode("orchestrationMode");
249                 
250                 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
251                 vnfResourceCustomization.setVnfResources(vnfResource);
252                 vnfResourceCustomization.setModelCustomizationUUID("vnfResCustModelCustomizationUUID");
253                 vnfResourceCustomization.setModelInstanceName("modelInstanceName");
254                 
255                 AllottedResource allottedResource = new AllottedResource();
256                 allottedResource.setModelUUID("serviceMetadataValue");
257                 allottedResource.setModelInvariantUUID("modelInvariantUUID");
258                 allottedResource.setModelName("modelName");
259                 allottedResource.setModelVersion("1.1");
260                 
261                 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
262                 allottedResourceCustomization.setAllottedResource(allottedResource);
263                 allottedResourceCustomization.setModelCustomizationUUID("modelCustomizationUUID");
264                 allottedResourceCustomization.setModelInstanceName("modelInstanceName");
265                 
266                 Service catalogService = new Service();
267                 catalogService.setServiceType("serviceType");
268                 catalogService.setModelUUID("5df8b6de-2083-11e7-93ae-92361f002672");
269                 catalogService.setModelInvariantUUID("modelInvariantUUID");
270                 catalogService.setModelName("modelName");
271                 catalogService.setModelVersion("modelVersion");
272                 catalogService.getVnfCustomizations().add(vnfResourceCustomization);
273                 
274                 Iterator artifactIterator = mock(Iterator.class);
275                 Iterator nodeTemplateIterator = mock(Iterator.class);
276                 IDistributionClientDownloadResult clientResult = mock(IDistributionClientDownloadResult.class);
277                 doReturn(IOUtils.toByteArray(
278                                 new FileInputStream(
279                                         new File(
280                                                         getClass().getClassLoader().getResource("resource-examples/simpleTest.yaml").getFile())
281                                 ))).when(clientResult).getArtifactPayload();
282                 VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactInfo, clientResult);
283                 Collection<VfModuleArtifact> vfModuleArtifactsValues = mock(Collection.class);
284                 
285                 NodeTemplate nodeTemplate = mock(NodeTemplate.class);
286                 List<NodeTemplate> nodeTemplateList = new ArrayList<>();
287                 nodeTemplateList.add(nodeTemplate);
288                 
289                 HeatTemplate heatTemplate = new HeatTemplate();
290                 heatTemplate.setArtifactUuid("ff874603-4222-11e7-9252-005056850d2e");
291                 heatTemplate.setArtifactChecksum("MANUAL RECORD");
292                 heatTemplate.setTemplateBody("templateBody");
293                 heatTemplate.setTemplateName("module_mns_zrdm3frwl01exn_01_rgvm_1.yml");
294                 heatTemplate.setVersion("1");
295                 
296                 NetworkResource networkResource = new NetworkResource();
297                 networkResource.setAicVersionMin("aicVersionMin");
298                 networkResource.setModelUUID("modelUUID");
299                 networkResource.setOrchestrationMode("orchestrationMode");
300                 networkResource.setModelVersion("modelVersion");
301                 networkResource.setNeutronNetworkType("neutronNetworkType");
302                 networkResource.setAicVersionMax("aicVersionMax");
303                 networkResource.setModelName("CONTRAIL30_GNDIRECT");
304                 networkResource.setModelInvariantUUID("modelInvariantUUID");
305                 networkResource.setHeatTemplate(heatTemplate);
306                 
307                 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
308                 networkResourceCustomization.setModelCustomizationUUID("modelCustomizationUUID");
309                 networkResourceCustomization.setModelInstanceName("modelInstanceName");
310                 networkResourceCustomization.setNetworkResource(networkResource);
311                 
312                 WatchdogServiceModVerIdLookup expectedModVerIdLookup = new WatchdogServiceModVerIdLookup(notificationData.getDistributionID(), notificationData.getServiceUUID());
313                 WatchdogDistributionStatus expectedDistributionStatus = new WatchdogDistributionStatus(notificationData.getDistributionID());
314                 WatchdogComponentDistributionStatus expectedComponentDistributionStatus = new WatchdogComponentDistributionStatus(notificationData.getDistributionID(), MSO);
315                 expectedComponentDistributionStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
316                 
317                 doReturn(sdcCsarHelper).when(toscaResourceStruct).getSdcCsarHelper();
318                 doReturn("metadataPropertyValue").when(sdcCsarHelper).getMetadataPropertyValue(any(Metadata.class), any(String.class));
319                 doReturn("ntPropertyLeafValue").when(sdcCsarHelper).getNodeTemplatePropertyLeafValue(any(NodeTemplate.class), any(String.class));
320                 doReturn("true").when(sdcCsarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
321                 doReturn("1").when(sdcCsarHelper).getCapabilityPropertyLeafValue(any(CapabilityAssignment.class), any(String.class));
322                 doReturn(vfGroups).when(sdcCsarHelper).getVfModulesByVf(any(String.class));
323                 doReturn(capabilityAssignments).when(sdcCsarHelper).getCapabilitiesOf(any(NodeTemplate.class));
324                 doReturn(capabilityAssignment).when(capabilityAssignments).getCapabilityByName(any(String.class));
325                 
326                 doReturn(catalogService).when(toscaResourceStruct).getCatalogService();
327                 
328                 doReturn(artifactInfo).when(toscaResourceStruct).getToscaArtifact();
329                 doReturn("artifactChecksum").when(artifactInfo).getArtifactChecksum();
330                 doReturn("artifactUUID").when(artifactInfo).getArtifactUUID();
331                 doReturn("artifactName").when(artifactInfo).getArtifactName();
332                 doReturn("1.0").when(artifactInfo).getArtifactVersion();
333                 doReturn("artifactDescription").when(artifactInfo).getArtifactDescription();
334                 doReturn("artifactURL").when(artifactInfo).getArtifactURL();
335                 
336                 doReturn(metadata).when(toscaResourceStruct).getServiceMetadata();
337                 doReturn("serviceMetadataValue").when(metadata).getValue(any(String.class));
338                 doReturn("CONTRAIL30_GNDIRECT").when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
339                 
340                 doReturn("serviceVersion").when(toscaResourceStruct).getServiceVersion();
341                 doReturn(nodeTemplateList).when(sdcCsarHelper).getServiceVfList();
342                 doReturn(nodeTemplateList).when(sdcCsarHelper).getServiceVlList();
343                 doReturn(nodeTemplateList).when(sdcCsarHelper).getAllottedResources();
344                 doReturn(metadata).when(nodeTemplate).getMetaData();
345                 doReturn("model_instance_name").when(nodeTemplate).getName();
346                 doReturn(false).when(toscaResourceStruct).isVnfAlreadyInstalled();
347                 doReturn(vnfResourceCustomization).when(toscaResourceStruct).getCatalogVnfResourceCustomization();
348                 doReturn(allottedResource).when(toscaResourceStruct).getAllottedResource();
349                 doReturn(allottedResourceCustomization).when(toscaResourceStruct).getCatalogAllottedResourceCustomization();
350                 
351                 doReturn(vfModuleArtifacts).when(vfResourceStructure).getArtifactsMapByUUID();
352                 when(vfModuleArtifacts.values()).thenReturn(vfModuleArtifactsValues);
353                 when(vfModuleArtifactsValues.iterator()).thenReturn(artifactIterator);
354                 when(artifactIterator.hasNext()).thenReturn(true, false);
355                 when(artifactIterator.next()).thenReturn(vfModuleArtifact);
356                 when(artifactInfo.getArtifactType()).thenReturn(ASDCConfiguration.OTHER);
357                 when(nodeTemplateIterator.hasNext()).thenReturn(true, false);
358                 
359                 doReturn(networkResource).when(toscaResourceStruct).getCatalogNetworkResource();
360                 doReturn(networkResourceCustomization).when(toscaResourceStruct).getCatalogNetworkResourceCustomization();
361                 
362                 doNothing().when(toscaResourceStruct).setSuccessfulDeployment();
363                 
364                 toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
365                 
366                 AllottedResource actualAllottedResource = allottedRepo.findResourceByModelUUID(allottedResource.getModelUUID());
367                 AllottedResourceCustomization actualAllottedResourceCustomization = allottedCustomizationRepo.findOne(allottedResourceCustomization.getModelCustomizationUUID());
368                 Service actualService = serviceRepo.findByServiceType(catalogService.getServiceType());
369                 WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
370                 
371                 verify(toscaResourceStruct, times(1)).setSuccessfulDeployment();
372                 assertThat(actualAllottedResource, 
373                                 sameBeanAs(allottedResource));
374                 assertThat(actualAllottedResourceCustomization, sameBeanAs(allottedResourceCustomization)
375                                 .ignoring("created"));
376                 assertThat(actualService, sameBeanAs(catalogService)
377                                 .ignoring("created")
378                                 .ignoring("networkCustomizations.0x1.created")
379                                 .ignoring("networkCustomizations.0x1.networkResource.created"));
380                 assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedComponentDistributionStatus)
381                                 .ignoring("createTime")
382                                 .ignoring("modifyTime"));
383         }
384
385         
386         @Test
387         public void installTheResourceExceptionTest() throws Exception {
388                 expectedException.expect(ArtifactInstallerException.class);
389                 
390                 notificationData.setDistributionID("testStatusFailureTosca");
391                 notificationData.setServiceVersion("123456");
392                 notificationData.setServiceUUID("serviceUUID");
393                 notificationData.setWorkloadContext("workloadContext");
394                 
395                 doReturn(notificationData).when(vfResourceStructure).getNotification();
396                 doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
397                 
398                 toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
399         }
400         
401         @Test
402         public void installTheResourceDBExceptionTest() throws Exception {
403                 notificationData.setDistributionID("testStatusSuccessTosca");
404                 notificationData.setServiceVersion("123456");
405                 notificationData.setServiceUUID("serviceUUID");
406                 notificationData.setWorkloadContext("workloadContext");
407                 
408                 doReturn(notificationData).when(vfResourceStructure).getNotification();
409                 doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
410                 doThrow(LockAcquisitionException.class).when(toscaResourceStruct).getToscaArtifact();
411                 
412                 toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
413         }
414         
415         @Test
416         public void verifyTheFilePrefixInStringTest() {
417                 String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
418                 String filenameToVerify = "testfile.txt";
419                 String expectedFileBody = "abcabcabctestfile.txtabcbabacbcabc";
420                 
421                 String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
422                 
423                 assertEquals(expectedFileBody, newFileBody);
424         }
425         
426         @Test
427         public void verifyTheFilePrefixInStringNullBodyTest() {
428                 String body = null;
429                 String filenameToVerify = "testfile.txt";
430                 
431                 String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
432                 
433                 assertEquals(body, newFileBody);
434         }
435         
436         @Test
437         public void verifyTheFilePrefixInStringEmptyBodyTest() {
438                 String body = "";
439                 String filenameToVerify = "testfile.txt";
440                 
441                 String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
442                 
443                 assertEquals(body, newFileBody);
444         }
445         
446         @Test
447         public void verifyTheFilePrefixInStringNullFilenameTest() {
448                 String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
449                 String filenameToVerify = null;
450                 
451                 String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
452                 
453                 assertEquals(body, newFileBody);
454         }
455         
456         @Test
457         public void verifyTheFilePrefixInStringEmptyFilenameTest() {
458                 String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
459                 String filenameToVerify = "";
460                 
461                 String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
462                 
463                 assertEquals(body, newFileBody);
464         }
465         
466         private WatchdogComponentDistributionStatus getWatchdogCDStatusWithName(List<WatchdogComponentDistributionStatus> watchdogComponentDistributionStatuses, String componentName) {
467                 WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = new WatchdogComponentDistributionStatus();
468                 for(WatchdogComponentDistributionStatus watchdogComponentDistributionStatus : watchdogComponentDistributionStatuses) {
469                         if(componentName.equals(watchdogComponentDistributionStatus.getComponentName())) {
470                                 actualWatchdogComponentDistributionStatus = watchdogComponentDistributionStatus;
471                                 break;
472                         }
473                 }
474                 return actualWatchdogComponentDistributionStatus;
475         }
476
477
478         
479 }