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