aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java
blob: 7bec56013aae44bcdd9743da4ba963604d3c3c25 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package vid.automation.test.test;

import org.junit.Assert;
import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import vid.automation.test.Constants;
import vid.automation.test.infra.Wait;
import vid.automation.test.sections.PnfSearchAssociationPage;
import vid.automation.test.sections.SideMenu;
import vid.automation.test.sections.VidBasePage;
import vid.automation.test.sections.ViewEditPage;
import vid.automation.test.services.BulkRegistration;
import vid.automation.test.services.SimulatorApi;

public class AssociatePnfTest extends VidBaseTestCase {

    private VidBasePage vidBasePage = new VidBasePage();
    private ViewEditPage viewEditPage = new ViewEditPage();
    private PnfSearchAssociationPage pnfSearchAssociationPage =  new PnfSearchAssociationPage();
    private String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
    private String pnfInstanceName = "MX_960-F722";
    private String pnfModelName = "pnf 0";

    @BeforeMethod
    public void navigateToWelcomePage() {
        SideMenu.navigateToWelcomePage();
    }

    @Test
    public void testAssociatePnf() throws Exception {
        SimulatorApi.clearAll();
        BulkRegistration.searchExistingServiceInstance();
        BulkRegistration.associatePnf();

        goToExistingInstanceById(serviceInstanceId);//vid-test-444
        addPNF(pnfModelName);//vid-test-444
        searchPNF(pnfInstanceName);
        testResultSearchPNF();
        associatePNF();
        vidBasePage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
        vidBasePage.clickCloseButton();
    }

    @Test
    public void testRainyAssociatePnf() throws Exception {
        SimulatorApi.clearAll();
        BulkRegistration.searchExistingServiceInstance();
        BulkRegistration.associatePnfError();

        goToExistingInstanceById(serviceInstanceId);
        addPNF(pnfModelName);
        searchPNF(pnfInstanceName);
        associatePNF();
        vidBasePage.assertMsoRequestModal("Error");
        vidBasePage.clickCloseButton();
    }
    @Test
    public void testRainyChoosePnf() throws Exception {
        SimulatorApi.clearAll();
        BulkRegistration.searchExistingServiceInstance();
        BulkRegistration.associatePnfError();

        goToExistingInstanceById(serviceInstanceId);
        String pnfName= "pnf 1";
        GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID, 60);
        String message = String.format(Constants.ViewEdit.OPTION_IN_DROPDOWN_NOT_EXISTS,
                Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID,"Add network instance");
        boolean waitForElementResult = Wait.waitByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + pnfName, 60);
        Assert.assertTrue(message, !waitForElementResult);
    }
    @Test
    public void testRainySearchPnfInstance() throws Exception {
        SimulatorApi.clearAll();
        BulkRegistration.searchExistingServiceInstance();
        BulkRegistration.associatePnfError();

        goToExistingInstanceById(serviceInstanceId);
        addPNF(pnfModelName);
        searchPNF("AAAAA");
        Wait.angularHttpRequestsLoaded();
        WebElement errorMessageWebElement = GeneralUIUtils.getWebElementByTestID(Constants.PnfAssociation.NOT_FOUND_ERROR_TEST_ID, 60);
        Assert.assertEquals("not found PNF instance, error message not equals the expected message","The specified PNF instance AAAAA does not exist in A&AI.\n" +
                "Please note: A&AI is case sensitive",errorMessageWebElement.getText());
        Assert.assertTrue(Constants.PnfAssociation.NOT_FOUND_ERROR_MESSAGE, errorMessageWebElement!=null);
        assertAssociateButtonState(false);
    }

    private void assertAssociateButtonState(boolean shouldBeEnabled) {
        WebElement associateWebElement = GeneralUIUtils.getWebElementByTestID(Constants.PnfAssociation.ASSOCIATE_PNF_TEST_ID, 60);
        boolean enabledAssociate=associateWebElement.isEnabled();

        if(shouldBeEnabled) {
            Assert.assertTrue(Constants.PnfAssociation.PNF_ENABLE_ASSOCIATE_ERROR_MESSAGE, enabledAssociate);
        }else{
            Assert.assertTrue(Constants.PnfAssociation.PNF_DISABLE_ASSOCIATE_ERROR_MESSAGE, !enabledAssociate);
        }
        GeneralUIUtils.ultimateWait();
    }
    private void associatePNF() throws InterruptedException {
        pnfSearchAssociationPage.clickAssociateButton();
    }

    private void addPNF(String name){
        viewEditPage.selectNodeInstanceToAdd(name);
        checkServiceModelInfo();
        assertAssociateButtonState(false);
    }

    private void searchPNF(String name){
        pnfSearchAssociationPage.setPnfName(name);
        pnfSearchAssociationPage.clickSearchButton();
    }

    private void testResultSearchPNF(){
        checkPnfProperties();
        Wait.angularHttpRequestsLoaded();
        assertAssociateButtonState(true);
    }
    private void checkServiceModelInfo() {
        Wait.angularHttpRequestsLoaded();
        //Service name
        String elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SERVIICE_NAME_KEY;
        String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"Demo Service 1");
        //model name
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_NAME;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"Test Pnf");
        //service instance name
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"vid-test-444");
        //Model Invariant UUID
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_INVARIANT_UUID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"61eba322-c758-48f6-8942-1a7625aaaffb");
        //ubscriber NameModel Invariant UUID
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"SILVIA ROBBINS");
        //Model Version
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_VERSION;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"0.1");
        //Model UUID
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_UUID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"089b1c03-ff6b-4914-8c20-a7de3d375e8d");
        //Model Customization UUID
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"cabf6d26-c362-4444-ba06-f850e8af2d35");
        //Resource Name
        elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.RESOURCE_NAME;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,pnfModelName);
     }

    private void checkPnfProperties() {
        //Pnf Instance unique name
        String elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME_TEST_ID;
        String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,pnfInstanceName);
        //Pnf Instance name2
        elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME2_TEST_ID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-name-2");
        //Pnf Instance name2 source
        elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME2_SOURCE_TEST_ID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-name-2-source");
        //Pnf Instance Id
        elementTestId = Constants.PnfAssociation.PNF_INSTANCE_ID_TEST_ID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-id");
        //Pnf Instance Equipment type
        elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_TYPE_TEST_ID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"Switch");
        //Pnf Instance Equipment vendor
        elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_VENDOR_TEST_ID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"Cisco");
        //Pnf Instance Equipment model
        elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_MODEL_TEST_ID;
        infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
        Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"ASR1002-X");
    }



}