aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/vid/automation/test/sections/ViewEditPage.java
blob: e10c872ee5072cba1e07a0c4b8ef312ee35725d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package vid.automation.test.sections;

import org.junit.Assert;
import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import vid.automation.test.Constants;
import vid.automation.test.infra.Features;
import vid.automation.test.infra.Get;
import vid.automation.test.infra.SelectOption;

import static org.hamcrest.core.Is.is;

/**
 * Created by itzikliderman on 13/06/2017.
 */
public class ViewEditPage extends VidBasePage {
    public ViewEditPage selectNodeInstanceToAdd(String vnfName) {
        selectFromDropdownByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + vnfName,
                Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID);
        return this;
    }

    public ViewEditPage selectVfModuleToAdd(String vfModuleName) {
        selectFromDropdownByTestId(Constants.ViewEdit.VF_MODULE_OPTION_TEST_ID_PREFIX + vfModuleName,
                Constants.ViewEdit.ADD_VF_MODULE_BUTTON_TEST_ID);
        return this;
    }

    public ViewEditPage clickResumeButton(String instanceName) {
        //instanceName = "my_vfModule";
        String instanceId = Constants.ViewEdit.VF_MODULE_RESUME_ID_PREFIX + instanceName;
        checkIfExistResumeButton(instanceName,true);
        GeneralUIUtils.clickOnElementByTestId(instanceId);
        return this;
    }


    public ViewEditPage checkIfExistResumeButton(String instanceName, Boolean expected) {
        //instanceName = "my_vfModule";
        String instanceId = Constants.ViewEdit.VF_MODULE_RESUME_ID_PREFIX + instanceName;
        WebElement resumeButton = GeneralUIUtils.getWebElementByTestID(instanceId, 30);
        Assert.assertThat(resumeButton != null, is(expected));
        return this;
    }

    public ViewEditPage selectVolumeGroupToAdd(String volumeGroupName) {
        selectFromDropdownByTestId(Constants.ViewEdit.VOLUME_GROUP_OPTION_TEST_ID_PREFIX + volumeGroupName,
                Constants.ViewEdit.ADD_VOLUME_GROUP_BUTTON_TEST_ID);
        return this;
    }

    public ViewEditPage selectFromDropdownByText(String itemText, String dropdownButtonTestId) {
        GeneralUIUtils.clickOnElementByTestId(dropdownButtonTestId, 30);
        GeneralUIUtils.clickOnElementByText(itemText, 30);
        return this;
    }

    public ViewEditPage selectNetworkToAdd(String networkName) {
        selectFromDropdownByTestId(Constants.ViewEdit.NETWORK_OPTION_TEST_ID_PREFIX + networkName,
                Constants.ViewEdit.ADD_NETWORK_BUTTON_TEST_ID);
        return this;
    }

    public ViewEditPage selectProductFamily(String productFamily){
        SelectOption.byValue(productFamily, Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID);
        return this;
    }

    public ViewEditPage selectLcpRegion(String lcpRegion, String cloudOwner){
        selectLcpRegion(lcpRegion);
        if (Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST.isActive()) {
            String selectedOption = SelectOption.getSelectedOption(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID);
            Assert.assertEquals(lcpRegion + " (" + cloudOwner.toUpperCase() + ")", selectedOption);
        }
        return this;
    }

    public ViewEditPage setLegacyRegion(String legacyRegionName){
        setInputText(Constants.ViewEdit.LEGACY_REGION_INPUT_TESTS_ID, legacyRegionName);
        return this;
    }

    public ViewEditPage selectTenant(String tenant){
        SelectOption.byValue(tenant, Constants.ViewEdit.TENANT_SELECT_TESTS_ID);
       // GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.TENANT_SELECT_TESTS_ID, 60);
        return this;
    }

    public VidBasePage clickActivateButton() {
        GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID, 60);
        return this;
    }

    public VidBasePage clickActivateFabricConfigurationButton() {
        GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ACTIVATE_FABRIC_CONFIGURATION_BUTTON_TEST_ID, 60);
        return this;
    }
    public VidBasePage clickInfoButton() {
        GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.INFOSERVICEBUTTON, 30);
        return this;
    }

    public VidBasePage clickDeleteButton() {
        GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.DELETESERVICEBUTTON, 3);
        return this;
    }


    public WebElement getPnf(String pnfName) {
        WebElement pnfElement = Get.byClassAndText("tree-node", "PNF: " + pnfName);
        Assert.assertNotNull("Pnf "+ pnfName +" not found under service instance", pnfElement);
        return pnfElement;
    }

    public ViewEditPage clickDissociatePnfButton(String pnfName) {
        WebElement pnfToDissociate = getPnf(pnfName);
        WebElement dissociateBtn = pnfToDissociate.findElement(By.className(Constants.ViewEdit.DISSOCIATE_BTN_CLASS));
        Assert.assertNotNull("Dissociate button not found for pnf " + pnfName, dissociateBtn);
        dissociateBtn.click();
        return this;
    }

    public VidBasePage clickDeactivateButton() {
        GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID, 30);
        return this;
    }

    public ViewEditPage selectLineOfBusiness(String lineOfBusiness) {
        try {
            SelectOption.selectFirstTwoOptionsFromMultiselectById(Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID);
        } catch (InterruptedException e) {
            e.printStackTrace();
            return this;
        }
        //TODO multi SelectOption.byValue(lineOfBusiness, Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID);
        return this;
    }

    public ViewEditPage selectPlatform(String platform) {
        SelectOption.byValue(platform, Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
        return this;
    }
}