Refresh option in validation result page
[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     private static final String NO_TESTS_ARE_AVAILABLE = "No Tests are Available";
84     private static final String NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_ENABLED =
85             "Next Button is enabled, it should have been enabled";
86     private static final String NEXT_BUTTON_IS_DISABLED_IT_SHOULD_HAVE_BEEN_ENABLED =
87             "Next Button is disabled, it should have been enabled";
88     private static final String RESULTS_ARE_NOT_AVAILABLE = "Results are not available";
89     private static final String THE_TESTS_ARE_ALREADY_SELECTED_THE_LIST_SHOULD_INITIALLY_BE_EMPTY =
90             "The tests are already selected, the list should initially be empty";
91     private static final String THE_SELECTED_TESTS_ARE_NOT_POPULATED_IN_THE_LIST =
92             "The selected tests are not populated in the list";
93     private static final String THE_SELECTED_TESTS_ARE_NOT_DELETED_FROM_THE_LIST =
94             "The selected tests are not deleted from the list";
95     private static final String NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_DISABLED =
96             "Next Button is enabled, it should have been disabled";
97
98     protected static String filePath = FileHandling.getVnfRepositoryPath();
99     private Boolean makeDistributionValue;
100
101     @Parameters({"makeDistribution"})
102     @BeforeMethod
103     public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
104         LOGGER.debug("makeDistribution parameter is '{}'", makeDistributionReadValue);
105         makeDistributionValue = Boolean.valueOf(makeDistributionReadValue);
106     }
107
108     @Test
109     public void onboardVNFTestSanityOneFile() throws Exception {
110         String vnfFile = "1-VF-vUSP-vCCF-DB_v11.1.zip";
111         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
112         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
113         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
114     }
115
116     @Test
117     public void performanceTest() throws Exception {
118         LOGGER.debug("Start test");
119         Long actualTestRunTime = Utils.getActionDuration(() -> {
120             try {
121                 onboardVNFTestSanityOneFile();
122             } catch (final Exception e) {
123                 LOGGER.debug("An error has occurred during the performance test", e);
124             }
125         });
126         long regularTestRunTime = 400L;
127         double factor = 1.5;
128         assertTrue("Expected test run time should be less from " + regularTestRunTime * factor + ", actual time is " + actualTestRunTime, regularTestRunTime * factor > actualTestRunTime);
129     }
130
131     @Test
132     public void onboardVNFTestSanity() throws Exception {
133         List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF);
134         String vnfFile = fileNamesFromFolder.get(0);
135         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
136         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
137         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
138     }
139
140     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
141     public void onapOnboardVNFflow(String filePath, String vnfFile) throws Exception {
142         setLog(vnfFile);
143         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
144         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
145         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
146     }
147
148     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
149     public void onapOnboardVSPValidationsSanityFlow(String filePath, String vnfFile) throws Exception {
150         setLog(vnfFile);
151         String vspName = createNewVSP(filePath, vnfFile);
152         if (OnboardingUiUtils.getVspValidationCongiguration()) {
153             goToVspScreen(true, vspName);
154
155             //check links are available
156             checkVspValidationLinksVisibility();
157
158             VspValidationPage.navigateToVspValidationPageUsingNavbar();
159             assertTrue(NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_DISABLED,
160                     VspValidationPage.checkNextButtonDisabled());
161             VspValidationResultsPage.navigateToVspValidationResultsPageUsingNavbar();
162             GeneralUIUtils.ultimateWait();
163             assertNotNull(GeneralUIUtils.findByText("No Test Performed"));
164         } else {
165             goToVspScreen(true, vspName);
166
167             //check links are not available
168             checkVspValidationLinksInvisibility();
169         }
170     }
171
172     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
173     public void onapOnboardVSPValidationsConfigurationChangeCheck(String filePath, String vnfFile) throws Exception {
174         setLog(vnfFile);
175         String vspName = createNewVSP(filePath, vnfFile);
176         if (OnboardingUiUtils.getVspValidationCongiguration()) {
177             goToVspScreen(true, vspName);
178             //check links are available
179             checkVspValidationLinksVisibility();
180
181             //change config
182             changeVspValidationConfig(false, vspName, OnboardingUiUtils.getVspValidationCongiguration());
183
184             //check links are not available
185             checkVspValidationLinksInvisibility();
186         } else {
187             goToVspScreen(true, vspName);
188             //check links are not available
189             checkVspValidationLinksInvisibility();
190
191             changeVspValidationConfig(false, vspName, OnboardingUiUtils.getVspValidationCongiguration());
192
193             //check links are available
194             checkVspValidationLinksVisibility();
195         }
196     }
197
198     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
199     public void onapOnboardVSPCertificationQueryFlow(String filePath, String vnfFile) throws Exception {
200         setLog(vnfFile);
201         String vspName = createNewVSP(filePath, vnfFile);
202         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
203             //change config to true to test the feature
204             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
205         } else {
206             goToVspScreen(true, vspName);
207         }
208         VspValidationPage.navigateToVspValidationPageUsingNavbar();
209         assertTrue(NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_DISABLED, VspValidationPage.checkNextButtonDisabled());
210
211         if (VspValidationPage.checkCertificationQueryExists()) {
212             VspValidationPage.clickCertificationQueryAll();
213             GeneralUIUtils.ultimateWait();
214             assertTrue(NEXT_BUTTON_IS_DISABLED_IT_SHOULD_HAVE_BEEN_ENABLED,
215                     !VspValidationPage.checkNextButtonDisabled());
216             VspValidationPage.clickOnNextButton();
217             GeneralUIUtils.ultimateWait();
218             VspValidationPage.clickOnSubmitButton();
219             GeneralUIUtils.waitForLoader();
220             assertTrue(RESULTS_ARE_NOT_AVAILABLE, VspValidationResultsPage.checkResultsExist());
221         } else {
222             assertNotNull(GeneralUIUtils.findByText("No Certifications Query are Available"));
223         }
224
225     }
226
227     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "Single_Vsp_Test_Csar")
228     public void onapOnboardVSPComplianceCheckFlow(String filePath, String vnfFile) throws Exception {
229         setLog(vnfFile);
230         String vspName = createNewVSP(filePath, vnfFile);
231         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
232             //change config to true to test the feature
233             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
234         } else {
235             goToVspScreen(true, vspName);
236         }
237
238         VspValidationPage.navigateToVspValidationPageUsingNavbar();
239         assertTrue(NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_ENABLED, VspValidationPage.checkNextButtonDisabled());
240         if (VspValidationPage.checkComplianceCheckExists()) {
241             VspValidationPage.clickComplianceChecksAll();
242             GeneralUIUtils.ultimateWait();
243             assertFalse(NEXT_BUTTON_IS_DISABLED_IT_SHOULD_HAVE_BEEN_ENABLED,
244                     VspValidationPage.checkNextButtonDisabled());
245             VspValidationPage.clickOnNextButton();
246             GeneralUIUtils.ultimateWait();
247             VspValidationPage.loadVSPFile(filePath, vnfFile);
248             VspValidationPage.clickOnSubmitButton();
249             GeneralUIUtils.ultimateWait();
250             assertTrue(RESULTS_ARE_NOT_AVAILABLE, VspValidationResultsPage.checkResultsExist());
251         } else {
252             assertNotNull(GeneralUIUtils.findByText(NO_TESTS_ARE_AVAILABLE));
253         }
254
255     }
256
257     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
258     public void onapOnboardVSPComplianceCheckOperations(String filePath, String vnfFile) throws Exception {
259         setLog(vnfFile);
260         String vspName = createNewVSP(filePath, vnfFile);
261         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
262             //change config to true to test the feature
263             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
264         } else {
265             goToVspScreen(true, vspName);
266         }
267
268         VspValidationPage.navigateToVspValidationPageUsingNavbar();
269         assertTrue(NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_ENABLED, VspValidationPage.checkNextButtonDisabled());
270         if (VspValidationPage.checkComplianceCheckExists()) {
271             assertFalse(THE_TESTS_ARE_ALREADY_SELECTED_THE_LIST_SHOULD_INITIALLY_BE_EMPTY,
272                     VspValidationPage.checkSelectedComplianceCheckExists());
273             VspValidationPage.clickComplianceChecksAll();
274             GeneralUIUtils.ultimateWait();
275             assertTrue(THE_SELECTED_TESTS_ARE_NOT_POPULATED_IN_THE_LIST,
276                     VspValidationPage.checkSelectedComplianceCheckExists());
277             VspValidationPage.clickComplianceChecksAll();
278             GeneralUIUtils.ultimateWait();
279             assertFalse(THE_SELECTED_TESTS_ARE_NOT_DELETED_FROM_THE_LIST,
280                     VspValidationPage.checkSelectedComplianceCheckExists());
281         } else {
282             assertNotNull(GeneralUIUtils.findByText(NO_TESTS_ARE_AVAILABLE));
283         }
284
285     }
286
287     @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Single_VNF")
288     public void onapOnboardVSPCertificationQueryOperations(String filePath, String vnfFile) throws Exception {
289         setLog(vnfFile);
290         String vspName = createNewVSP(filePath, vnfFile);
291         if (!OnboardingUiUtils.getVspValidationCongiguration()) {
292             //change config to true to test the feature
293             changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
294         } else {
295             goToVspScreen(true, vspName);
296         }
297
298         VspValidationPage.navigateToVspValidationPageUsingNavbar();
299         assertTrue(NEXT_BUTTON_IS_ENABLED_IT_SHOULD_HAVE_BEEN_ENABLED, VspValidationPage.checkNextButtonDisabled());
300         if (VspValidationPage.checkCertificationQueryExists()) {
301             assertFalse(THE_TESTS_ARE_ALREADY_SELECTED_THE_LIST_SHOULD_INITIALLY_BE_EMPTY,
302                 VspValidationPage.checkSelectedCertificationQueryExists());
303             VspValidationPage.clickCertificationQueryAll();
304             GeneralUIUtils.ultimateWait();
305             assertTrue(THE_SELECTED_TESTS_ARE_NOT_POPULATED_IN_THE_LIST, VspValidationPage.checkSelectedCertificationQueryExists());
306             VspValidationPage.clickCertificationQueryAll();
307             GeneralUIUtils.ultimateWait();
308             assertFalse(THE_SELECTED_TESTS_ARE_NOT_DELETED_FROM_THE_LIST,
309                 VspValidationPage.checkSelectedCertificationQueryExists());
310         } else {
311             assertNotNull(GeneralUIUtils.findByText(NO_TESTS_ARE_AVAILABLE));
312         }
313
314     }
315
316     private void checkVspValidationLinksVisibility() {
317         //check links are available
318         assertTrue("Validation Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue()));
319         assertTrue("Validation Results Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue()));
320     }
321
322     private void checkVspValidationLinksInvisibility() {
323         //check links not available
324         assertTrue("Validation Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue()));
325         assertTrue("Validation Results Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue()));
326     }
327
328     private void changeVspValidationConfig(boolean isCurrentScreenCatalogPage, String vspName, boolean vspConfig) throws Exception {
329         //change config
330         OnboardingUiUtils.putVspValidationCongiguration(!vspConfig);
331         assertTrue(String.format("Failed to set Congiguration to %s", !vspConfig), OnboardingUiUtils.getVspValidationCongiguration() != vspConfig);
332
333         if (!isCurrentScreenCatalogPage) {
334             GeneralUIUtils.refreshWebpage();
335             GeneralUIUtils.ultimateWait();
336         }
337
338         goToVspScreen(isCurrentScreenCatalogPage, vspName);
339
340         //revert the config
341         OnboardingUiUtils.putVspValidationCongiguration(vspConfig);
342         assertEquals(String.format("Failed to revert Configuration to %s", vspConfig), vspConfig,
343             OnboardingUiUtils.getVspValidationCongiguration());
344     }
345
346     private void goToVspScreen(boolean isCurrentScreenCatalogPage, String vspName) {
347         if (isCurrentScreenCatalogPage) {
348             GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.ONBOARD_BUTTON.getValue());
349         }
350         GeneralUIUtils.clickOnElementByText(vspName);
351         GeneralUIUtils.ultimateWait();
352     }
353
354     private String createNewVSP(String filePath, String vnfFile) throws Exception {
355         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
356         return OnboardingUiUtils.createVSP(resourceReqDetails, vnfFile, filePath, getUser()).getName();
357     }
358
359     private void runOnboardToDistributionFlow(ResourceReqDetails resourceReqDetails, ServiceReqDetails serviceMetadata, String filePath, String vnfFile) throws Exception {
360         getExtendTest().log(Status.INFO, "Going to create resource with category: " + resourceReqDetails.getCategories().get(0).getName()
361                 + " subCategory: " + resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()
362                 + " and service category: " + serviceMetadata.getCategory());
363         final String vspName = onboardAndCertify(resourceReqDetails, filePath, vnfFile);
364
365         ServiceUIUtils.createService(serviceMetadata);
366
367         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
368         CompositionPage.searchForElement(vspName);
369         final CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
370         final CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName);
371         ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName);
372
373         assertNotNull(vfElement);
374         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
375         ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: ");
376
377         ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
378
379         reloginWithNewRole(UserRoleEnum.TESTER);
380         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
381         TesterOperationPage.certifyComponent(serviceMetadata.getName());
382
383         reloginWithNewRole(UserRoleEnum.GOVERNOR);
384         HomePage.waitForElement(PageElement.COMPONENT_PANEL);
385         HomePage.findComponentAndClick(serviceMetadata.getName());
386         GovernorOperationPage.approveService(serviceMetadata.getName());
387
388         runDistributionFlow(serviceMetadata);
389
390         getExtendTest().log(Status.INFO, String.format("Successfully onboarded the package '%s'", vnfFile));
391     }
392
393     private void runDistributionFlow(final ServiceReqDetails serviceMetadata) throws Exception {
394         if (makeDistributionValue) {
395             reloginWithNewRole(UserRoleEnum.OPS);
396             GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
397             OpsOperationPage.distributeService();
398             OpsOperationPage.displayMonitor();
399
400             final List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
401             AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
402
403             OpsOperationPage.waitUntilArtifactsDistributed(0);
404         }
405     }
406
407     private String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception {
408         VendorSoftwareProductObject onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
409         String vspName = onboardAndValidate.getName();
410
411         DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
412         ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : ");
413
414         DeploymentArtifactPage.clickCertifyButton(vspName);
415         return vspName;
416     }
417
418
419     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
420     public void onboardVNFTest(String filePath, String vnfFile) throws Exception {
421         setLog(vnfFile);
422         ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource();
423         ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService();
424         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
425     }
426
427     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
428     public void onboardVNFShotFlow(String filePath, String vnfFile) throws Exception {
429         setLog(vnfFile);
430         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
431         onboardAndCertify(resourceReqDetails, filePath, vnfFile);
432     }
433
434     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
435     public void onboardRandomVNFsTest(String filePath, String vnfFile) throws Exception {
436         setLog(vnfFile);
437         LOGGER.debug("Vnf File name is: {}", vnfFile);
438         ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource();
439         ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService();
440         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
441     }
442
443
444     @Test
445     public void onboardUpdateVNFTest() throws Exception {
446         List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath);
447         String vnfFile = fileNamesFromFolder.get(0);
448         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
449         VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
450         String vspName = vsp.getName();
451         ResourceGeneralPage.clickCertifyButton(vspName);
452
453         // create service
454         ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
455         ServiceUIUtils.createService(serviceMetadata);
456
457         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
458         CompositionPage.searchForElement(vspName);
459         CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
460         CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName);
461         assertNotNull(vfElement);
462         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
463
464         if (!HomePage.navigateToHomePage()) {
465             fail("Could not go to the home page");
466         }
467
468         ///update flow
469         String updatedVnfFile = fileNamesFromFolder.get(1);
470
471         getExtendTest().log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile));
472         // update VendorSoftwareProduct
473         OnboardingUiUtils.updateVnfAndValidate(filePath, vsp, updatedVnfFile, getUser());
474         ResourceGeneralPage.clickCertifyButton(vspName);
475
476         // replace exiting VFI in service with new updated
477
478         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
479         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
480         serviceCanvasManager = CanvasManager.getCanvasManager();
481         CompositionPage.changeComponentVersion(serviceCanvasManager, vfElement, "2.0");
482         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser());
483
484         ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
485
486         reloginWithNewRole(UserRoleEnum.TESTER);
487         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
488         TesterOperationPage.certifyComponent(serviceMetadata.getName());
489
490         reloginWithNewRole(UserRoleEnum.GOVERNOR);
491         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
492         GovernorOperationPage.approveService(serviceMetadata.getName());
493
494
495         reloginWithNewRole(UserRoleEnum.OPS);
496         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
497         OpsOperationPage.distributeService();
498         OpsOperationPage.displayMonitor();
499
500         List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
501         AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
502
503         OpsOperationPage.waitUntilArtifactsDistributed(0);
504         getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile));
505     }
506
507
508     @Test
509     public void threeVMMSCsInServiceTest() throws Exception {
510         String pathFile = FileHandling.getFilePath("VmmscArtifacts");
511         final String[] list = new File(pathFile).list();
512         assertNotNull("Did not find vMMSCs", list);
513         assertFalse("Did not find vMMSCs", list.length == 0);
514         List<String> vmmscList = Arrays.stream(list).filter(e -> e.contains("vmmsc") && e.endsWith(".zip"))
515             .collect(Collectors.toList());
516         assertFalse("Did not find vMMSCs", vmmscList.isEmpty());
517
518         Map<String, String> vspNames = new HashMap<>();
519         for (String vnfFile : vmmscList) {
520             String msg = String.format("Going to onboard the VNF %s", vnfFile);
521             getExtendTest().log(Status.INFO, msg);
522             LOGGER.info(msg);
523
524             VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
525             ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
526             VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils
527                 .createVendorSoftwareProduct(resourceReqDetails, vnfFile, pathFile, getUser(), vendorLicenseModel);
528
529             getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile));
530             HomePage.showVspRepository();
531             getExtendTest().log(Status.INFO, String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf("."))));
532             OnboardingUiUtils.importVSP(createVendorSoftwareProduct);
533
534             ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
535             DeploymentArtifactPage.verifyArtifactsExistInTable(pathFile, vnfFile);
536
537             String vspName = createVendorSoftwareProduct.getName();
538             DeploymentArtifactPage.clickCertifyButton(vspName);
539             vspNames.put(vnfFile, vspName);
540         }
541
542         // create service
543         ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
544         ServiceUIUtils.createService(serviceMetadata);
545         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
546         CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager();
547
548         for (String vsp : vspNames.values()) {
549             CompositionPage.searchForElement(vsp);
550             CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vsp);
551             assertNotNull(vfElement);
552         }
553         ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", vspNames.values().size(), getUser());
554         File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Info_" + getExtendTest().getModel().getName());
555         final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath();
556         SetupCDTest.getExtendTest().log(Status.INFO, "Three kinds of vMMSC are in canvas now." + getExtendTest().addScreenCaptureFromPath(absolutePath));
557
558         ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
559
560         reloginWithNewRole(UserRoleEnum.TESTER);
561         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
562         TesterOperationPage.certifyComponent(serviceMetadata.getName());
563
564         reloginWithNewRole(UserRoleEnum.GOVERNOR);
565         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
566         GovernorOperationPage.approveService(serviceMetadata.getName());
567
568         reloginWithNewRole(UserRoleEnum.OPS);
569         GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
570         OpsOperationPage.distributeService();
571         OpsOperationPage.displayMonitor();
572
573         List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable();
574         AssertJUnit.assertEquals(1, rowsFromMonitorTable.size());
575
576         OpsOperationPage.waitUntilArtifactsDistributed(0);
577     }
578
579
580     @Override
581     protected UserRoleEnum getRole() {
582         return UserRoleEnum.DESIGNER;
583     }
584
585 }