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