re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / US / Service_Tests_UI.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.US;
22
23 import org.openecomp.sdc.ci.tests.datatypes.*;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum;
25 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
27 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
28 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
29 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
30 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
31 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
32 import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils;
33 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
34 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
35 import org.testng.annotations.Test;
36
37 import java.util.ArrayList;
38 import java.util.List;
39
40 public class Service_Tests_UI extends SetupCDTest{
41
42         public Service_Tests_UI() {
43         }
44         
45         // US839610 - E2E Declare VL / CP properties as inputs in service level
46         @Test
47         public void declareVL_CP_InputsInServiceLevel() throws Exception {
48                 String vnfFile = "FDNT.zip";
49                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
50                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser());
51                 ServiceReqDetails servicemetadata = ElementFactory.getDefaultService(getUser());
52                 ServiceUIUtils.createService(servicemetadata, getUser());
53                 GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION);
54                 CanvasManager service_CanvasManager = CanvasManager.getCanvasManager();
55                 CompositionPage.searchForElement(vendorSoftwareProductObject.getName());
56                 GeneralUIUtils.waitForLoader();
57                 CanvasElement vfi_Element = service_CanvasManager.createElementOnCanvas(vendorSoftwareProductObject.getName());
58                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue())
59                                 .click();
60                 GeneralUIUtils.findComponentAndClick(servicemetadata.getName());
61                 GeneralUIUtils.moveToStep(StepsEnum.INPUTS);
62                 GeneralUIUtils.getWebElementByTestID("inputs-vf-instance-1").click();
63 //              GeneralUIUtils.onNameClicked(input);
64         }
65         @Test
66         public void CreateServiceWithCpInstance() throws Exception {
67                 String vnfFile = "FDNT.zip";
68                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
69                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser());
70                 ServiceReqDetails servicemetadata = ElementFactory.getDefaultService(getUser());
71                 ServiceUIUtils.createService(servicemetadata, getUser());
72                 GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION);
73                 CanvasManager service_CanvasManager = CanvasManager.getCanvasManager();
74                 CompositionPage.searchForElement(vendorSoftwareProductObject.getName());
75                 GeneralUIUtils.waitForLoader();
76                 CanvasElement vfi_Element = service_CanvasManager.createElementOnCanvas(vendorSoftwareProductObject.getName());
77                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue())
78                                 .click();
79                 GeneralUIUtils.findComponentAndClick(servicemetadata.getName());
80                 GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_VIEW);
81                 String version = GeneralUIUtils.getWebElementByTestID("versionHeader").getText();
82                 RestResponse service = ServiceRestUtils.getServiceByNameAndVersion(getUser(), servicemetadata.getName(),
83                                 version.substring(1));
84                 List<String> serviceResponseArray = new ArrayList<>();
85                 serviceResponseArray =LocalGeneralUtilities.getValuesFromJsonArray(service);
86                 servicemetadata.setUniqueId(serviceResponseArray.get(0));
87                 RestResponse serviceResponse = ServiceRestUtils.getService(servicemetadata, getUser());
88                 if (serviceResponseArray.get(0).contains("VL")) {
89                         System.out.println("OK");
90                 }
91
92         }
93
94         @Override
95         protected UserRoleEnum getRole() {
96                 return UserRoleEnum.DESIGNER;
97         }
98         
99
100 }