595c43801c9dfd04a9cc69878a873e91ca78af4b
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / OnboardingFlowsUi.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.execute.sanity;
22
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertNotNull;
26 import static org.testng.AssertJUnit.assertTrue;
27 import static org.testng.AssertJUnit.fail;
28
29 import com.aventstack.extentreports.Status;
30 import java.io.File;
31 import java.util.Arrays;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.stream.Collectors;
36 import org.openecomp.sdc.ci.tests.data.providers.OnboardingDataProviders;
37 import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders;
38 import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
39 import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
40 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
42 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
43 import org.openecomp.sdc.ci.tests.datatypes.VendorLicenseModel;
44 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
45 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
46 import org.openecomp.sdc.ci.tests.datatypes.enums.XnfTypeEnum;
47 import org.openecomp.sdc.ci.tests.execute.setup.ArtifactsCorrelationManager;
48 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
49 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
50 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
51 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
52 import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage;
53 import org.openecomp.sdc.ci.tests.pages.HomePage;
54 import org.openecomp.sdc.ci.tests.pages.HomePage.PageElement;
55 import org.openecomp.sdc.ci.tests.pages.OpsOperationPage;
56 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
57 import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage;
58 import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
59 import org.openecomp.sdc.ci.tests.pages.VspValidationPage;
60 import org.openecomp.sdc.ci.tests.pages.VspValidationResultsPage;
61 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
62 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
63 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
64 import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils;
65 import org.openecomp.sdc.ci.tests.utils.Utils;
66 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
67 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils;
68 import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils;
69 import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils;
70 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
71 import org.openqa.selenium.WebElement;
72 import org.slf4j.Logger;
73 import org.slf4j.LoggerFactory;
74 import org.testng.AssertJUnit;
75 import org.testng.annotations.BeforeMethod;
76 import org.testng.annotations.Optional;
77 import org.testng.annotations.Parameters;
78 import org.testng.annotations.Test;
79
80 public class OnboardingFlowsUi extends SetupCDTest {
81
82     private static final Logger LOGGER = LoggerFactory.getLogger(OnboardingFlowsUi.class);
83
84     protected static String filePath = FileHandling.getVnfRepositoryPath();
85     private Boolean makeDistributionValue;
86
87     @Parameters({"makeDistribution"})
88     @BeforeMethod
89     public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
90         LOGGER.debug("makeDistribution parameter is '{}'", makeDistributionReadValue);
91         makeDistributionValue = Boolean.valueOf(makeDistributionReadValue);
92     }
93
94     @Test
95     public void onboardVNFTestSanityOneFile() throws Exception {
96         String vnfFile = "1-VF-vUSP-vCCF-DB_v11.1.zip";
97         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
98         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
99         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
100     }
101
102     @Test
103     public void performanceTest() throws Exception {
104         LOGGER.debug("Start test");
105         Long actualTestRunTime = Utils.getActionDuration(() -> {
106             try {
107                 onboardVNFTestSanityOneFile();
108             } catch (final Exception e) {
109                 LOGGER.debug("An error has occurred during the performance test", e);
110             }
111         });
112         long regularTestRunTime = 400L;
113         double factor = 1.5;
114         assertTrue("Expected test run time should be less from " + regularTestRunTime * factor + ", actual time is " + actualTestRunTime, regularTestRunTime * factor > actualTestRunTime);
115     }
116
117     @Test
118     public void onboardVNFTestSanity() throws Exception {
119         List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF);
120         String vnfFile = fileNamesFromFolder.get(0);
121         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
122         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
123         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
124     }
125
126     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
127     public void onapOnboardVNFflow(String filePath, String vnfFile) throws Exception {
128         setLog(vnfFile);
129         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
130         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
131         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
132     }
133
134     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
135     public void onapOnboardVSPValidationsSanityFlow(String filePath, String vnfFile) throws Exception {
136         setLog(vnfFile);
137         String vspName = createNewVSP(filePath, vnfFile);
138         if (OnboardingUiUtils.getVspValidationCongiguration()) {
139             goToVspScreen(true, vspName);
140
141             //check links are available
142             checkVspValidationLinksVisibility();
143
144             VspValidationPage.navigateToVspValidationPageUsingNavbar();
145             assertTrue("Next Button is enabled, it should have been disabled", VspValidationPage.checkNextButtonDisabled());
146             VspValidationResultsPage.navigateToVspValidationResultsPageUsingNavbar();
147             GeneralUIUtils.ultimateWait();
148             assertNotNull(GeneralUIUtils.findByText("No Validation Checks Performed"));
149         } else {
150             goToVspScreen(true, vspName);
151
152             //check links are not available
153             checkVspValidationLinksInvisibility();
154         }
155     }
156
157     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
158     public void onapOnboardVSPValidationsConfigurationChangeCheck(String filePath, String vnfFile) throws Exception {
159         setLog(vnfFile);
160         String vspName = createNewVSP(filePath, vnfFile);
161         if (OnboardingUiUtils.getVspValidationCongiguration()) {
162             goToVspScreen(true, vspName);
163             //check links are available
164             checkVspValidationLinksVisibility();
165
166             //change config
167             changeVspValidationConfig(false, vspName, OnboardingUiUtils.getVspValidationCongiguration());
168
169             //check links are not available
170             checkVspValidationLinksInvisibility();
171         } else {
172             goToVspScreen(true, vspName);
173             //check links are not available
174             checkVspValidationLinksInvisibility();
175
176             changeVspValidationConfig(false, vspName, OnboardingUiUtils.getVspValidationCongiguration());
177
178             //check links are available
179             checkVspValidationLinksVisibility();
180         }
181     }
182
183     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
184     public void onapOnboardVSPCertificationQueryFlow(String filePath, String vnfFile) throws Exception {
185         setLog(vnfFile);
186         String vspName = createNewVSP(filePath, vnfFile);
187         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
188             //change config to true to test the feature
189             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
190         } else {
191             goToVspScreen(true, vspName);
192         }
193         VspValidationPage.navigateToVspValidationPageUsingNavbar();
194         assertTrue("Next Button is enabled, it should have been disabled", VspValidationPage.checkNextButtonDisabled());
195
196         if (VspValidationPage.checkCertificationQueryExists()) {
197             VspValidationPage.clickCertificationQueryAll();
198             GeneralUIUtils.ultimateWait();
199             assertTrue("Next Button is disabled, it should have been enabled", !VspValidationPage.checkNextButtonDisabled());
200             VspValidationPage.clickOnNextButton();
201             GeneralUIUtils.ultimateWait();
202             VspValidationPage.clickOnSubmitButton();
203             GeneralUIUtils.waitForLoader();
204             assertTrue("Results are not available", VspValidationResultsPage.checkResultsExist());
205         } else {
206             assertNotNull(GeneralUIUtils.findByText("No Certifications Query are Available"));
207         }
208
209     }
210
211     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
212     public void onapOnboardVSPComplianceCheckFlow(String filePath, String vnfFile) throws Exception {
213         setLog(vnfFile);
214         String vspName = createNewVSP(filePath, vnfFile);
215         final String complianceNotAvailableLabel = "No Compliance Checks are Available";
216         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
217             //change config to true to test the feature
218             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
219         } else {
220             goToVspScreen(true, vspName);
221         }
222
223         VspValidationPage.navigateToVspValidationPageUsingNavbar();
224         assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled());
225         if (VspValidationPage.checkComplianceCheckExists()) {
226             VspValidationPage.clickComplianceChecksAll();
227             GeneralUIUtils.ultimateWait();
228             assertFalse("Next Button is disabled, it should have been enabled",
229                 VspValidationPage.checkNextButtonDisabled());
230             VspValidationPage.clickOnNextButton();
231             GeneralUIUtils.ultimateWait();
232             VspValidationPage.clickOnSubmitButton();
233             GeneralUIUtils.ultimateWait();
234             assertTrue("Results are not available", VspValidationResultsPage.checkResultsExist());
235         } else {
236             assertNotNull(GeneralUIUtils.findByText(complianceNotAvailableLabel));
237         }
238
239     }
240
241     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
242     public void onapOnboardVSPComplianceCheckOperations(String filePath, String vnfFile) throws Exception {
243         setLog(vnfFile);
244         String vspName = createNewVSP(filePath, vnfFile);
245         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
246             //change config to true to test the feature
247             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
248         } else {
249             goToVspScreen(true, vspName);
250         }
251
252         VspValidationPage.navigateToVspValidationPageUsingNavbar();
253         assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled());
254         if (VspValidationPage.checkComplianceCheckExists()) {
255             assertFalse("The tests are already selected, the list should initially be empty",
256                 VspValidationPage.checkSelectedComplianceCheckExists());
257             VspValidationPage.clickComplianceChecksAll();
258             GeneralUIUtils.ultimateWait();
259             assertTrue("The selected tests are not populated in the list", VspValidationPage.checkSelectedComplianceCheckExists());
260             VspValidationPage.clickComplianceChecksAll();
261             GeneralUIUtils.ultimateWait();
262             assertFalse("The selected tests are not deleted from the list",
263                 VspValidationPage.checkSelectedComplianceCheckExists());
264         } else {
265             assertNotNull(GeneralUIUtils.findByText("No Compliance Checks are Available"));
266         }
267
268     }
269
270     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
271     public void onapOnboardVSPCertificationQueryOperations(String filePath, String vnfFile) throws Exception {
272         setLog(vnfFile);
273         String vspName = createNewVSP(filePath, vnfFile);
274         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
275             //change config to true to test the feature
276             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
277         } else {
278             goToVspScreen(true, vspName);
279         }
280
281         VspValidationPage.navigateToVspValidationPageUsingNavbar();
282         assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled());
283         if (VspValidationPage.checkCertificationQueryExists()) {
284             assertFalse("The tests are already selected, the list should initially be empty",
285                 VspValidationPage.checkSelectedCertificationQueryExists());
286             VspValidationPage.clickCertificationQueryAll();
287             GeneralUIUtils.ultimateWait();
288             assertTrue("The selected tests are not populated in the list", VspValidationPage.checkSelectedCertificationQueryExists());
289             VspValidationPage.clickCertificationQueryAll();
290             GeneralUIUtils.ultimateWait();
291             assertFalse("The selected tests are not deleted from the list",
292                 VspValidationPage.checkSelectedCertificationQueryExists());
293         } else {
294             assertNotNull(GeneralUIUtils.findByText("No Compliance Checks are Available"));
295         }
296
297     }
298
299     private void checkVspValidationLinksVisibility() {
300         //check links are available
301         assertTrue("Validation Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue()));
302         assertTrue("Validation Results Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue()));
303     }
304
305     private void checkVspValidationLinksInvisibility() {
306         //check links not available
307         assertTrue("Validation Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue()));
308         assertTrue("Validation Results Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue()));
309     }
310
311     private void changeVspValidationConfig(boolean isCurrentScreenCatalogPage, String vspName, boolean vspConfig) throws Exception {
312         //change config
313         OnboardingUiUtils.putVspValidationCongiguration(!vspConfig);
314         assertTrue(String.format("Failed to set Congiguration to %s", !vspConfig), OnboardingUiUtils.getVspValidationCongiguration() != vspConfig);
315
316         if (!isCurrentScreenCatalogPage) {
317             GeneralUIUtils.refreshWebpage();
318             GeneralUIUtils.ultimateWait();
319         }
320
321         goToVspScreen(isCurrentScreenCatalogPage, vspName);
322
323         //revert the config
324         OnboardingUiUtils.putVspValidationCongiguration(vspConfig);
325         assertEquals(String.format("Failed to revert Configuration to %s", vspConfig), vspConfig,
326             OnboardingUiUtils.getVspValidationCongiguration());
327     }
328
329     private void goToVspScreen(boolean isCurrentScreenCatalogPage, String vspName) {
330         if (isCurrentScreenCatalogPage) {
331             GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.ONBOARD_BUTTON.getValue());
332         }
333         GeneralUIUtils.clickOnElementByText(vspName);
334         GeneralUIUtils.ultimateWait();
335     }
336
337     private String createNewVSP(String filePath, String vnfFile) throws Exception {
338         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
339         return OnboardingUiUtils.createVSP(resourceReqDetails, vnfFile, filePath, getUser()).getName();
340     }
341
342     private void runOnboardToDistributionFlow(ResourceReqDetails resourceReqDetails, ServiceReqDetails serviceMetadata, String filePath, String vnfFile) throws Exception {
343         getExtendTest().log(Status.INFO, "Going to create resource with category: " + resourceReqDetails.getCategories().get(0).getName()
344                 + " subCategory: " + resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()
345                 + " and service category: " + serviceMetadata.getCategory());
346         final String vspName = onboardAndCertify(resourceReqDetails, filePath, vnfFile);
347
348         ServiceUIUtils.createService(serviceMetadata);
349
350         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
351         CompositionPage.searchForElement(vspName);
352         final CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
353         final CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName);
354         ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName);
355
356         assertNotNull(vfElement);
357         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
358         ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: ");
359
360         ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
361
362         reloginWithNewRole(UserRoleEnum.TESTER);
363         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
364         TesterOperationPage.certifyComponent(serviceMetadata.getName());
365
366         reloginWithNewRole(UserRoleEnum.GOVERNOR);
367         HomePage.waitForElement(PageElement.COMPONENT_PANEL);
368         HomePage.findComponentAndClick(serviceMetadata.getName());
369         GovernorOperationPage.approveService(serviceMetadata.getName());
370
371         runDistributionFlow(serviceMetadata);
372
373         getExtendTest().log(Status.INFO, String.format("Successfully onboarded the package '%s'", vnfFile));
374     }
375
376     private void runDistributionFlow(final ServiceReqDetails serviceMetadata) throws Exception {
377         if (makeDistributionValue) {
378             reloginWithNewRole(UserRoleEnum.OPS);
379             GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
380             OpsOperationPage.distributeService();
381             OpsOperationPage.displayMonitor();
382
383             final List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
384             AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
385
386             OpsOperationPage.waitUntilArtifactsDistributed(0);
387         }
388     }
389
390     private String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception {
391         VendorSoftwareProductObject onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
392         String vspName = onboardAndValidate.getName();
393
394         DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
395         ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : ");
396
397         DeploymentArtifactPage.clickCertifyButton(vspName);
398         return vspName;
399     }
400
401
402     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
403     public void onboardVNFTest(String filePath, String vnfFile) throws Exception {
404         setLog(vnfFile);
405         ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource();
406         ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService();
407         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
408     }
409
410     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
411     public void onboardVNFShotFlow(String filePath, String vnfFile) throws Exception {
412         setLog(vnfFile);
413         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
414         onboardAndCertify(resourceReqDetails, filePath, vnfFile);
415     }
416
417     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
418     public void onboardRandomVNFsTest(String filePath, String vnfFile) throws Exception {
419         setLog(vnfFile);
420         LOGGER.debug("Vnf File name is: {}", vnfFile);
421         ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource();
422         ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService();
423         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
424     }
425
426
427     @Test
428     public void onboardUpdateVNFTest() throws Exception {
429         List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath);
430         String vnfFile = fileNamesFromFolder.get(0);
431         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
432         VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
433         String vspName = vsp.getName();
434         ResourceGeneralPage.clickCertifyButton(vspName);
435
436         // create service
437         ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
438         ServiceUIUtils.createService(serviceMetadata);
439
440         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
441         CompositionPage.searchForElement(vspName);
442         CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
443         CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName);
444         assertNotNull(vfElement);
445         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
446
447         if (!HomePage.navigateToHomePage()) {
448             fail("Could not go to the home page");
449         }
450
451         ///update flow
452         String updatedVnfFile = fileNamesFromFolder.get(1);
453
454         getExtendTest().log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile));
455         // update VendorSoftwareProduct
456         OnboardingUiUtils.updateVnfAndValidate(filePath, vsp, updatedVnfFile, getUser());
457         ResourceGeneralPage.clickCertifyButton(vspName);
458
459         // replace exiting VFI in service with new updated
460
461         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
462         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
463         serviceCanvasManager = CanvasManager.getCanvasManager();
464         CompositionPage.changeComponentVersion(serviceCanvasManager, vfElement, "2.0");
465         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
466
467         ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
468
469         reloginWithNewRole(UserRoleEnum.TESTER);
470         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
471         TesterOperationPage.certifyComponent(serviceMetadata.getName());
472
473         reloginWithNewRole(UserRoleEnum.GOVERNOR);
474         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
475         GovernorOperationPage.approveService(serviceMetadata.getName());
476
477
478         reloginWithNewRole(UserRoleEnum.OPS);
479         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
480         OpsOperationPage.distributeService();
481         OpsOperationPage.displayMonitor();
482
483         List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
484         AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
485
486         OpsOperationPage.waitUntilArtifactsDistributed(0);
487         getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile));
488     }
489
490
491     @Test
492     public void threeVMMSCsInServiceTest() throws Exception {
493         String pathFile = FileHandling.getFilePath("VmmscArtifacts");
494         final String[] list = new File(pathFile).list();
495         assertNotNull("Did not find vMMSCs", list);
496         assertFalse("Did not find vMMSCs", list.length == 0);
497         List<String> vmmscList = Arrays.stream(list).filter(e -> e.contains("vmmsc") && e.endsWith(".zip"))
498             .collect(Collectors.toList());
499         assertFalse("Did not find vMMSCs", vmmscList.isEmpty());
500
501         Map<String, String> vspNames = new HashMap<>();
502         for (String vnfFile : vmmscList) {
503             String msg = String.format("Going to onboard the VNF %s", vnfFile);
504             getExtendTest().log(Status.INFO, msg);
505             LOGGER.info(msg);
506
507             VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
508             ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
509             VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils
510                 .createVendorSoftwareProduct(resourceReqDetails, vnfFile, pathFile, getUser(), vendorLicenseModel);
511
512             getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile));
513             HomePage.showVspRepository();
514             getExtendTest().log(Status.INFO, String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf("."))));
515             OnboardingUiUtils.importVSP(createVendorSoftwareProduct);
516
517             ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
518             DeploymentArtifactPage.verifyArtifactsExistInTable(pathFile, vnfFile);
519
520             String vspName = createVendorSoftwareProduct.getName();
521             DeploymentArtifactPage.clickCertifyButton(vspName);
522             vspNames.put(vnfFile, vspName);
523         }
524
525         // create service
526         ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
527         ServiceUIUtils.createService(serviceMetadata);
528         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
529         CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
530
531         for (String vsp : vspNames.values()) {
532             CompositionPage.searchForElement(vsp);
533             CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vsp);
534             assertNotNull(vfElement);
535         }
536         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", vspNames.values().size(), getUser());
537         File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Info_" + getExtendTest().getModel().getName());
538         final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath();
539         SetupCDTest.getExtendTest().log(Status.INFO, "Three kinds of vMMSC are in canvas now." + getExtendTest().addScreenCaptureFromPath(absolutePath));
540
541         ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
542
543         reloginWithNewRole(UserRoleEnum.TESTER);
544         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
545         TesterOperationPage.certifyComponent(serviceMetadata.getName());
546
547         reloginWithNewRole(UserRoleEnum.GOVERNOR);
548         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
549         GovernorOperationPage.approveService(serviceMetadata.getName());
550
551         reloginWithNewRole(UserRoleEnum.OPS);
552         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
553         OpsOperationPage.distributeService();
554         OpsOperationPage.displayMonitor();
555
556         List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
557         AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
558
559         OpsOperationPage.waitUntilArtifactsDistributed(0);
560     }
561
562
563     @Override
564     protected UserRoleEnum getRole() {
565         return UserRoleEnum.DESIGNER;
566     }
567
568 }