7bec56013aae44bcdd9743da4ba963604d3c3c25
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / AssociatePnfTest.java
1 package vid.automation.test.test;
2
3 import org.junit.Assert;
4 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
5 import org.openqa.selenium.WebElement;
6 import org.testng.annotations.BeforeMethod;
7 import org.testng.annotations.Test;
8 import vid.automation.test.Constants;
9 import vid.automation.test.infra.Wait;
10 import vid.automation.test.sections.PnfSearchAssociationPage;
11 import vid.automation.test.sections.SideMenu;
12 import vid.automation.test.sections.VidBasePage;
13 import vid.automation.test.sections.ViewEditPage;
14 import vid.automation.test.services.BulkRegistration;
15 import vid.automation.test.services.SimulatorApi;
16
17 public class AssociatePnfTest extends VidBaseTestCase {
18
19     private VidBasePage vidBasePage = new VidBasePage();
20     private ViewEditPage viewEditPage = new ViewEditPage();
21     private PnfSearchAssociationPage pnfSearchAssociationPage =  new PnfSearchAssociationPage();
22     private String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
23     private String pnfInstanceName = "MX_960-F722";
24     private String pnfModelName = "pnf 0";
25
26     @BeforeMethod
27     public void navigateToWelcomePage() {
28         SideMenu.navigateToWelcomePage();
29     }
30
31     @Test
32     public void testAssociatePnf() throws Exception {
33         SimulatorApi.clearAll();
34         BulkRegistration.searchExistingServiceInstance();
35         BulkRegistration.associatePnf();
36
37         goToExistingInstanceById(serviceInstanceId);//vid-test-444
38         addPNF(pnfModelName);//vid-test-444
39         searchPNF(pnfInstanceName);
40         testResultSearchPNF();
41         associatePNF();
42         vidBasePage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
43         vidBasePage.clickCloseButton();
44     }
45
46     @Test
47     public void testRainyAssociatePnf() throws Exception {
48         SimulatorApi.clearAll();
49         BulkRegistration.searchExistingServiceInstance();
50         BulkRegistration.associatePnfError();
51
52         goToExistingInstanceById(serviceInstanceId);
53         addPNF(pnfModelName);
54         searchPNF(pnfInstanceName);
55         associatePNF();
56         vidBasePage.assertMsoRequestModal("Error");
57         vidBasePage.clickCloseButton();
58     }
59     @Test
60     public void testRainyChoosePnf() throws Exception {
61         SimulatorApi.clearAll();
62         BulkRegistration.searchExistingServiceInstance();
63         BulkRegistration.associatePnfError();
64
65         goToExistingInstanceById(serviceInstanceId);
66         String pnfName= "pnf 1";
67         GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID, 60);
68         String message = String.format(Constants.ViewEdit.OPTION_IN_DROPDOWN_NOT_EXISTS,
69                 Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID,"Add network instance");
70         boolean waitForElementResult = Wait.waitByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + pnfName, 60);
71         Assert.assertTrue(message, !waitForElementResult);
72     }
73     @Test
74     public void testRainySearchPnfInstance() throws Exception {
75         SimulatorApi.clearAll();
76         BulkRegistration.searchExistingServiceInstance();
77         BulkRegistration.associatePnfError();
78
79         goToExistingInstanceById(serviceInstanceId);
80         addPNF(pnfModelName);
81         searchPNF("AAAAA");
82         Wait.angularHttpRequestsLoaded();
83         WebElement errorMessageWebElement = GeneralUIUtils.getWebElementByTestID(Constants.PnfAssociation.NOT_FOUND_ERROR_TEST_ID, 60);
84         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" +
85                 "Please note: A&AI is case sensitive",errorMessageWebElement.getText());
86         Assert.assertTrue(Constants.PnfAssociation.NOT_FOUND_ERROR_MESSAGE, errorMessageWebElement!=null);
87         assertAssociateButtonState(false);
88     }
89
90     private void assertAssociateButtonState(boolean shouldBeEnabled) {
91         WebElement associateWebElement = GeneralUIUtils.getWebElementByTestID(Constants.PnfAssociation.ASSOCIATE_PNF_TEST_ID, 60);
92         boolean enabledAssociate=associateWebElement.isEnabled();
93
94         if(shouldBeEnabled) {
95             Assert.assertTrue(Constants.PnfAssociation.PNF_ENABLE_ASSOCIATE_ERROR_MESSAGE, enabledAssociate);
96         }else{
97             Assert.assertTrue(Constants.PnfAssociation.PNF_DISABLE_ASSOCIATE_ERROR_MESSAGE, !enabledAssociate);
98         }
99         GeneralUIUtils.ultimateWait();
100     }
101     private void associatePNF() throws InterruptedException {
102         pnfSearchAssociationPage.clickAssociateButton();
103     }
104
105     private void addPNF(String name){
106         viewEditPage.selectNodeInstanceToAdd(name);
107         checkServiceModelInfo();
108         assertAssociateButtonState(false);
109     }
110
111     private void searchPNF(String name){
112         pnfSearchAssociationPage.setPnfName(name);
113         pnfSearchAssociationPage.clickSearchButton();
114     }
115
116     private void testResultSearchPNF(){
117         checkPnfProperties();
118         Wait.angularHttpRequestsLoaded();
119         assertAssociateButtonState(true);
120     }
121     private void checkServiceModelInfo() {
122         Wait.angularHttpRequestsLoaded();
123         //Service name
124         String elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SERVIICE_NAME_KEY;
125         String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
126         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"Demo Service 1");
127         //model name
128         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_NAME;
129         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
130         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"Test Pnf");
131         //service instance name
132         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME;
133         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
134         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"vid-test-444");
135         //Model Invariant UUID
136         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_INVARIANT_UUID;
137         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
138         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"61eba322-c758-48f6-8942-1a7625aaaffb");
139         //ubscriber NameModel Invariant UUID
140         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY;
141         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
142         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"SILVIA ROBBINS");
143         //Model Version
144         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_VERSION;
145         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
146         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"0.1");
147         //Model UUID
148         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_UUID;
149         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
150         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"089b1c03-ff6b-4914-8c20-a7de3d375e8d");
151         //Model Customization UUID
152         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID;
153         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
154         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"cabf6d26-c362-4444-ba06-f850e8af2d35");
155         //Resource Name
156         elementTestId = Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX + Constants.ServiceModelInfo.RESOURCE_NAME;
157         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
158         Assert.assertEquals(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,pnfModelName);
159      }
160
161     private void checkPnfProperties() {
162         //Pnf Instance unique name
163         String elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME_TEST_ID;
164         String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
165         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,pnfInstanceName);
166         //Pnf Instance name2
167         elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME2_TEST_ID;
168         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
169         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-name-2");
170         //Pnf Instance name2 source
171         elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME2_SOURCE_TEST_ID;
172         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
173         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-name-2-source");
174         //Pnf Instance Id
175         elementTestId = Constants.PnfAssociation.PNF_INSTANCE_ID_TEST_ID;
176         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
177         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-id");
178         //Pnf Instance Equipment type
179         elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_TYPE_TEST_ID;
180         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
181         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"Switch");
182         //Pnf Instance Equipment vendor
183         elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_VENDOR_TEST_ID;
184         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
185         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"Cisco");
186         //Pnf Instance Equipment model
187         elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_MODEL_TEST_ID;
188         infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
189         Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"ASR1002-X");
190     }
191
192
193
194 }