89e28d7a6c6f2ea5fdc0818798845ce39531be42
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / CreatePortMirroringConfigurationTest.java
1 package vid.automation.test.test;
2
3 import com.google.common.collect.ImmutableMap;
4 import java.util.HashMap;
5 import java.util.Map;
6 import org.junit.Assert;
7 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
8 import org.openqa.selenium.WebElement;
9 import org.testng.annotations.Test;
10 import vid.automation.test.Constants;
11 import vid.automation.test.infra.Exists;
12 import vid.automation.test.infra.Features;
13 import vid.automation.test.infra.Get;
14 import vid.automation.test.infra.Wait;
15 import vid.automation.test.sections.CreateConfigurationPage;
16 import vid.automation.test.sections.ServiceProxyPage;
17 import vid.automation.test.sections.ViewEditPage;
18 import vid.automation.test.services.BulkRegistration;
19 import vid.automation.test.services.SimulatorApi;
20
21 public class CreatePortMirroringConfigurationTest extends VidBaseTestCase {
22
23     private ViewEditPage viewEditPage = new ViewEditPage();
24     private CreateConfigurationPage createConfigurationPage = new CreateConfigurationPage();
25     private ServiceProxyPage serviceProxyPage = new ServiceProxyPage();
26     private String serviceInstanceId = "c187e9fe-40c3-4862-b73e-84ff056205f6";
27     private String serviceInstanceId_vidTest444 = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
28     private String policyConfigurationModelName_0 = "Port Mirroring Configuration 0";
29     private String policyConfigurationModelName_1 = "Port Mirroring Configuration By Policy 1";
30     private String pnfInstanceName = "AS-pnf2-10219--as988q";
31     private String pnfServiceType = "DARREN MCGEE";
32     private String vnfServiceType = "TYLER SILVIA";
33     private String defaultCollectorServiceType = "TYLER SILVIA";
34     private String vnfInstanceName = "zhvf6aepdg01";
35     private String active = "Active";
36     private String desiredCloudRegionId = "mdt1";
37
38
39     private boolean featureFlagLetsSelectingCollector() {
40         return Features.FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY.isActive();
41     }
42
43     private String expectedPnfCollectorServiceType() {
44         return (featureFlagLetsSelectingCollector() ? pnfServiceType : defaultCollectorServiceType).replace(" ", "%20");
45     }
46
47     @Test
48     public void testCreatePolicyConfiguration() {
49         SimulatorApi.clearAll();
50         BulkRegistration.searchExistingServiceInstancePortMirroring("Active", "mdt1");
51         BulkRegistration.getNetworkNodeFormData();
52         BulkRegistration.createPolicyConfiguration(true, expectedPnfCollectorServiceType());
53
54         navigateToViewEditPageOf_test_sssdad();
55         selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata());
56         fillAllFormFields();
57         createConfigurationPage.clickNextButton();
58         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
59         //test back button
60         createConfigurationPage.clickBackButton();
61         assertFormFields();
62         createConfigurationPage.clickNextButton();
63
64         //assert service proxy models (circles) names
65         serviceProxyPage.assertSourceModelName("vflorenceService2 Service Proxy");
66         serviceProxyPage.assertCollectorModelName("pProbeService Service Proxy");
67
68         //assert service proxy models metadata
69         assertMetadataModal(Constants.ConfigurationCreation.SOURCE_INFO_BUTTON_TEST_ID, getSourceServiceProxyExpectedMetadata());
70         assertMetadataModal(Constants.ConfigurationCreation.COLLECTOR_INFO_BUTTON_TEST_ID, getCollectorServiceProxyExpectedMetadata());
71
72         //select source & collector
73         if (featureFlagLetsSelectingCollector()) {
74             serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
75             serviceProxyPage.chooseCollectorServiceType(pnfServiceType);
76         }
77         serviceProxyPage.chooseCollector(pnfInstanceName);
78         serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID);
79
80         serviceProxyPage.chooseSourceServiceType(vnfServiceType);
81         serviceProxyPage.chooseSource(vnfInstanceName);
82         serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.SOURCE_INSTANCE_SELECTED_ICON_TEST_ID);
83
84         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true);
85         serviceProxyPage.clickCreateButton();
86         serviceProxyPage.assertButtonStateEvenIfButtonNotVisible(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
87         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
88         serviceProxyPage.clickCloseButton();
89
90         //assert redirect back to view/edit
91         GeneralUIUtils.ultimateWait();
92         Assert.assertTrue(Exists.byTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID));
93     }
94
95
96     @Test
97     public void testDeletePolicyConfiguration() {
98         SimulatorApi.clearAll();
99         BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
100         BulkRegistration.getNetworkNodeFormData();
101         BulkRegistration.deletePolicyConfiguration(true);
102         navigateToViewEditPageOf_test_sssdad();
103         serviceProxyPage.clickDeleteConfigurationButton();
104         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
105     }
106
107     @Test
108     public void testConfigurationCreatedPortEnabled(){
109         SimulatorApi.clearAll();
110         BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
111         BulkRegistration.getNetworkNodeFormData();
112         BulkRegistration.activateDeactivateConfiguration("deactivate");
113         navigateToViewEditPageOf_test_sssdad();
114         WebElement isPortEnableButtonExists = Get.byTestId("enableDisableButton");
115         Assert.assertNull(isPortEnableButtonExists);
116     }
117
118     @Test
119     public void testDisablePort() {
120         enableDisablePortPresets(active, true);
121         BulkRegistration.enableDisablePort("disablePort");
122         navigateToViewEditPageOf_test_sssdad();
123         serviceProxyPage.clickEnableDisableButton();
124         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
125     }
126
127     @Test
128     public void testEnablePort() {
129         enableDisablePortPresets(active, false);
130         BulkRegistration.enableDisablePort("enablePort");
131         navigateToViewEditPageOf_test_sssdad();
132         serviceProxyPage.clickEnableDisableButton();
133         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
134     }
135
136
137
138
139     private void enableDisablePortPresets(String orchStatus, boolean isMirrored){
140         SimulatorApi.clearAll();
141         BulkRegistration.searchExistingServiceInstancePortMirroring(orchStatus, isMirrored, desiredCloudRegionId);
142         BulkRegistration.getNetworkNodeFormData();
143     }
144
145
146
147     @Test
148     public void testActivateConfigurationTest(){
149         SimulatorApi.clearAll();
150         BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
151         BulkRegistration.getNetworkNodeFormData();
152         BulkRegistration.activateDeactivateConfiguration("activate");
153         navigateToViewEditPageOf_test_sssdad();
154         serviceProxyPage.assertDeleteConfigurationButtonExists(true);
155         serviceProxyPage.clickActivateDeactivateButton();
156         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
157     }
158
159
160     @Test
161     public void testDeleteConfigurationTest(){
162         SimulatorApi.clearAll();
163         BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
164         BulkRegistration.getNetworkNodeFormData();
165         BulkRegistration.deleteConfiguration();
166         navigateToViewEditPageOf_test_sssdad();
167         serviceProxyPage.clickDeleteConfigurationButton();
168         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
169     }
170
171
172     @Test
173     public void testDeactivateConfigurationTest(){
174         SimulatorApi.clearAll();
175         BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId);
176         BulkRegistration.getNetworkNodeFormData();
177         BulkRegistration.activateDeactivateConfiguration("deactivate");
178         navigateToViewEditPageOf_test_sssdad();
179         serviceProxyPage.assertDeleteConfigurationButtonExists(false);
180         serviceProxyPage.clickActivateDeactivateButton();
181         serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
182
183     }
184
185
186     @Test
187     public void testCreatePortMirroringConfiguration() {
188         SimulatorApi.clearAll();
189         BulkRegistration.searchExistingServiceInstance();
190         BulkRegistration.getNetworkNodeFormData();
191         BulkRegistration.createPolicyConfiguration(true, expectedPnfCollectorServiceType());
192         BulkRegistration.createConfiguration("model-version-id=7482279e-5901-492f-a963-6331aa6b995e&model-invariant-id=f2ae9911-95c4-40d0-8908-0175c206ab2d");
193
194         navigateToViewEditPageOfuspVoiceVidTest444("240376de-870e-48df-915a-31f140eedd2c");
195         selectConfigurationNode(policyConfigurationModelName_0, ImmutableMap.<String, String>builder()
196                 .put(Constants.ServiceModelInfo.SERVIICE_NAME_KEY, "Demo Service 1")
197                 .put(Constants.ServiceModelInfo.MODEL_NAME, "Port Mirroring Configuration")
198                 .put(Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME, "vid-test-444")
199                 .put(Constants.ServiceModelInfo.MODEL_INVARIANT_UUID, "5dd839fa-5e09-47d4-aa5c-5ba62161b569")
200                 .put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "SILVIA ROBBINS")
201                 .put(Constants.ServiceModelInfo.MODEL_VERSION, "1.0")
202                 .put(Constants.ServiceModelInfo.MODEL_UUID, "9d6b09b1-7527-49b1-b6cf-398cb67c5523")
203                 .put(Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID, "3db39baa-35bc-4b97-b199-44e758823502")
204                 .put(Constants.ServiceModelInfo.RESOURCE_NAME, policyConfigurationModelName_0)
205                 .build());
206         fillAllFormFields();
207         createConfigurationPage.clickNextButton();
208         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
209         //test back button
210         createConfigurationPage.clickBackButton();
211         assertFormFields();
212         createConfigurationPage.clickNextButton();
213
214         //assert service proxy models (circles) names
215         serviceProxyPage.assertSourceModelName("Service 1 Service Proxy");
216         serviceProxyPage.assertCollectorModelName("Service 1 Service Proxy");
217
218         //assert service proxy models metadata
219         final ImmutableMap<String, String> expectedMetadata = ImmutableMap.<String, String>builder()
220                 .put(Constants.ServiceProxyModelInfo.MODEL_NAME, "Service 1 Service Proxy")
221                 .put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "2.0")
222                 .put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service Service 1")
223                 .put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy")
224                 .put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "0aaefad3-9409-4ab1-be00-a1571e8a0545")
225                 .put(Constants.ServiceProxyModelInfo.MODEL_UUID, "8685fd6a-c0b1-40f7-be94-ab232e4424c1")
226                 .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "7482279e-5901-492f-a963-6331aa6b995e")
227                 .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "f2ae9911-95c4-40d0-8908-0175c206ab2d")
228                 .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "Service 1")
229                 .build();
230         assertMetadataModal(Constants.ConfigurationCreation.SOURCE_INFO_BUTTON_TEST_ID, expectedMetadata);
231         assertMetadataModal(Constants.ConfigurationCreation.COLLECTOR_INFO_BUTTON_TEST_ID, expectedMetadata);
232
233         //select source & collector
234         serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
235         serviceProxyPage.chooseCollectorServiceType(vnfServiceType);
236         serviceProxyPage.chooseCollector(vnfInstanceName);
237         serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID);
238
239         serviceProxyPage.chooseSourceServiceType(vnfServiceType);
240         serviceProxyPage.chooseSource(vnfInstanceName);
241         serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.SOURCE_INSTANCE_SELECTED_ICON_TEST_ID);
242
243         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true);
244     }
245
246     @Test
247     public void testRainyCreatePolicyConfiguration() {
248
249         SimulatorApi.clearAll();
250         BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId);
251         BulkRegistration.getNetworkNodeFormData();
252         BulkRegistration.createPolicyConfiguration(false, expectedPnfCollectorServiceType());
253
254         navigateToViewEditPageOf_test_sssdad();
255         selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata());
256         fillAllFormFields();
257         createConfigurationPage.clickNextButton();
258         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
259
260         //select source & collector
261         if (featureFlagLetsSelectingCollector()) {
262             serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
263             serviceProxyPage.chooseCollectorServiceType(pnfServiceType);
264         }
265         serviceProxyPage.chooseCollector(pnfInstanceName);
266         serviceProxyPage.chooseSourceServiceType(vnfServiceType);
267         serviceProxyPage.chooseSource(vnfInstanceName);
268         serviceProxyPage.clickCreateButton();
269         serviceProxyPage.assertMsoRequestModal("Error");
270         serviceProxyPage.clickCloseButton();
271         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true);
272     }
273
274     @Test
275     public void testRainyNoResultsInDropdowns(){
276         SimulatorApi.clearAll();
277         BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId);
278         BulkRegistration.getNetworkNodeFormData();
279        //not register createPolicyConfiguration for no results in DDLs
280
281         navigateToViewEditPageOf_test_sssdad();
282         selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata());
283         fillAllFormFields();
284         createConfigurationPage.clickNextButton();
285         serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
286         //source & collector should be empty
287         serviceProxyPage.chooseSourceServiceType(vnfServiceType);
288         serviceProxyPage.noOptionDropdownByTestId(Constants.ConfigurationCreation.SOURCE_DROPDOWN_TEST_ID);
289         serviceProxyPage.noOptionDropdownByTestId(Constants.ConfigurationCreation.COLLECTOR_DROPDOWN_TEST_ID);
290         //error message no instance found
291         serviceProxyPage.assertNoResultRequirementsDropDown(Constants.ConfigurationCreation.COLLECTOR_NO_RESULT_MSG_TEST_ID,"pnf");
292         serviceProxyPage.assertNoResultRequirementsDropDown(Constants.ConfigurationCreation.SOURCE_NO_RESULT_MSG_TEST_ID,"vnf");
293     }
294
295     private void selectConfigurationNode(String name, Map<String, String> configurationExpectedMetadata){
296         viewEditPage.selectNodeInstanceToAdd(name);
297         assertModelInfo(configurationExpectedMetadata,true);
298         createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID, false);
299     }
300
301
302     public void assertMetadataModal(String btnTestId, Map<String, String> expectedMetadata) {
303         serviceProxyPage.clickInfoButton(btnTestId);
304         assertModelInfo(expectedMetadata, true);
305         serviceProxyPage.clickCloseButton();
306         Wait.modalToDisappear();
307     }
308
309     private void fillAllFormFields() {
310         createConfigurationPage.setInstanceName("dummy_instance");
311         createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID,false);
312         //WebElement tenantDDL= Get.byTestId(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID);
313
314         createConfigurationPage.chooseRegion("JANET25");
315         GeneralUIUtils.ultimateWait();
316        // Wait.waitByTestId(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID, 30);
317         createConfigurationPage.chooseTenant("USP-SIP-IC-24335-T-01");
318         createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID,true);
319     }
320     private void assertFormFields() {
321         Assert.assertEquals("dummy_instance",createConfigurationPage.getInstanceName());
322         Assert.assertEquals("JANET25", createConfigurationPage.getRegion());
323         Assert.assertEquals("USP-SIP-IC-24335-T-01",createConfigurationPage.getTenant());
324
325         createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID,true);
326     }
327
328     private Map<String, String> getConfigurationExpectedMetadata() {
329         return new HashMap<String, String>(){
330             {
331                 put(Constants.ServiceModelInfo.SERVIICE_NAME_KEY, "ServiceContainerMultiplepProbes");
332                 put(Constants.ServiceModelInfo.MODEL_NAME, "Port Mirroring Configuration By Policy");
333                 put(Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME, "test_sssdad");
334                 put(Constants.ServiceModelInfo.MODEL_INVARIANT_UUID, "c30a024e-a6c6-4670-b73c-3df64eb57ff6");
335                 put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "SILVIA ROBBINS");
336                 put(Constants.ServiceModelInfo.MODEL_VERSION, "1.0");
337                 put(Constants.ServiceModelInfo.MODEL_UUID, "f58d039d-4cfc-40ec-bd75-1f05f0458a6c");
338                 put(Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID, "4b7ebace-bad6-4526-9be6-bf248e20fc5f");
339                 put(Constants.ServiceModelInfo.RESOURCE_NAME, policyConfigurationModelName_1);
340             }
341         };
342     }
343
344     private Map<String, String> getSourceServiceProxyExpectedMetadata() {
345         return new HashMap<String, String>(){
346             {
347                 put(Constants.ServiceProxyModelInfo.MODEL_NAME, "vflorenceService2 Service Proxy");
348                 put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "1.0");
349                 put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service vflorenceService2");
350                 put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy");
351                 put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "2933b574-d28d-45ea-bf22-4df2907e4a10");
352                 put(Constants.ServiceProxyModelInfo.MODEL_UUID, "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee");
353                 put(Constants.ServiceProxyModelInfo.MODEL_CUSTOMIZATION_UUID, "060be63d-5f9c-4fd0-8ef7-830d5e8eca17");
354                 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6");
355                 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "a7eac2b3-8444-40ee-92e3-b3359b32445c");
356                 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "vflorenceService2");
357             }
358         };
359     }
360
361     private Map<String, String> getCollectorServiceProxyExpectedMetadata() {
362         return new HashMap<String, String>(){
363             {
364                 put(Constants.ServiceProxyModelInfo.MODEL_NAME, "pProbeService Service Proxy");
365                 put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "1.0");
366                 put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service pProbeService");
367                 put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy");
368                 put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "2933b574-d28d-45ea-bf22-4df2907e4a10");
369                 put(Constants.ServiceProxyModelInfo.MODEL_UUID, "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee");
370                 put(Constants.ServiceProxyModelInfo.MODEL_CUSTOMIZATION_UUID, "d64623ae-5935-4afd-803e-c86e94d8e740");
371                 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "8a84e59b-45fe-4851-8ff1-34225a0b32c3");
372                 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "83b458fd-5dd3-419b-a9e3-7335814a0911");
373                 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "pProbeService");
374             }
375         };
376     }
377 }