1 package vid.automation.test.test;
3 import com.google.common.collect.*;
4 import org.apache.commons.lang3.RandomStringUtils;
5 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateServiceInstancePost;
6 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2;
7 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
8 import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
9 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
10 import org.openqa.selenium.By;
11 import org.openqa.selenium.WebElement;
12 import org.testng.Assert;
13 import org.testng.annotations.*;
14 import vid.automation.test.Constants;
15 import vid.automation.test.Constants.BrowseASDC.NewServicePopup;
16 import vid.automation.test.infra.*;
17 import vid.automation.test.model.Service;
18 import vid.automation.test.model.User;
19 import vid.automation.test.sections.*;
20 import vid.automation.test.services.AsyncJobsService;
21 import vid.automation.test.services.ServicesService;
22 import vid.automation.test.services.SimulatorApi;
24 import java.text.ParseException;
25 import java.text.SimpleDateFormat;
27 import java.util.function.Consumer;
28 import java.util.function.Predicate;
29 import java.util.stream.Collectors;
31 import static junit.framework.TestCase.assertNull;
32 import static org.hamcrest.CoreMatchers.is;
33 import static org.hamcrest.MatcherAssert.assertThat;
34 import static org.testng.Assert.assertEquals;
35 import static org.testng.AssertJUnit.assertTrue;
36 import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION;
37 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
39 @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION)
40 public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
42 private ServicesService servicesService = new ServicesService();
43 private DrawingBoardPage drawingBoardPage = new DrawingBoardPage();
44 List<String> serviceModelLabelList = Arrays.asList("Model version", "Description", "Category", "UUID",
45 "Invariant UUID", "Service type", "Service role");
46 List<String> mandatoryServiceModelLabelList = Arrays.asList("Model version", "UUID", "Invariant UUID");
47 private final String defaultServiceModelForMostTests = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
48 private final VidBasePage vidBasePage = new VidBasePage();
51 protected void dropAllAsyncJobs() {
52 AsyncJobsService asyncJobsService = new AsyncJobsService();
53 asyncJobsService.dropAllAsyncJobs();
57 protected void muteAllAsyncJobs() {
58 AsyncJobsService asyncJobsService = new AsyncJobsService();
59 asyncJobsService.muteAllAsyncJobs();
63 protected void refreshPage() {
64 GeneralUIUtils.ultimateWait();
66 vidBasePage.refreshPage();
70 protected UserCredentials getUserCredentials() {
71 String userName = Constants.Users.USP_VOICE_VIRTUAL_USP;
72 User user = usersService.getUser(userName);
73 return new UserCredentials(user.credentials.userId, user.credentials.password, userName, "", "");
77 public void createNewServiceInstance_fullModelData_LeftPaneLabelsCorrect() throws Exception {
78 loadMacroServicePopup_noDynamicFields_fullModelDetails_ecompNamingFalse();
79 assertServiceModelLabelsCorrect(serviceModelLabelList);
83 public void createNewServiceInstance_partialModelData_LeftPaneLabelsCorrect() throws Exception {
84 loadMacroServicePopup_withDynamicFields_partialModelDetails_ecompNamingTrue();
85 assertServiceModelLabelsCorrect(mandatoryServiceModelLabelList);
89 * asserts that the provided labels list is visible and that no other detail item appears in the model details panel.
91 protected void assertServiceModelLabelsCorrect(List<String> serviceModelLabelList) throws Exception {
92 WebElement modelInformation = getDriver().findElement(By.id("model-information"));
93 List<WebElement> modelInformationItems = modelInformation.findElements(By.xpath("./div"));
94 assertEquals(modelInformationItems.size(), serviceModelLabelList.size());
95 serviceModelLabelList.forEach(label -> {
96 WebElement webElement = Get.byTestId("model-item-" + label);
97 WebElement itemWarpper = webElement.findElements(By.className("wrapper")).get(0);
98 assertEquals(itemWarpper.findElements(By.tagName("label")).get(0).getText(), label, "model details item label is incorrect.");
103 public void createNewServiceInstance_leftPane_serviceModelDataCorrect() {
104 Service service = servicesService.getService(NewServicePopup.SERVICE_UUID);
105 String prefix = NewServicePopup.SERVICE_MODEL_DATA_TEST_ID_VALUE_PREFIX;
106 loadMacroServicePopup_noDynamicFields_fullModelDetails_ecompNamingFalse();
107 setNewInstance_leftPane_assertModelDataCorrect(NewServicePopup.SERVICE_MODEL_FIELD_TO_DATA_TESTS_ID, prefix, service);
111 public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingFalse() {
113 ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip",
114 "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
116 false, true, true, true,
117 "2017-488_ADIOD-vPE 0",
118 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, ImmutableList.of("Bandwidth", "Bandwidth units"));
120 String serviceInstanceName = deployServiceInstance(serviceData, false);
121 vidBasePage.screenshotDeployDialog(serviceInstanceName);
122 deployAndVerifyModuleInPendingTable(serviceInstanceName);
123 verifyOpenAuditInfo(serviceInstanceName);
124 verifyOpenViewEdit(serviceInstanceName);
125 verifyDeleteJob(serviceInstanceName);
126 verifyHideJob(serviceInstanceName);
130 public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfTrue_vgNameFalse() {
131 ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip",
132 "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
134 false, true, false, true,
135 "2017-488_ADIOD-vPE 0",
136 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", 1, 1, new ArrayList<>());
138 deployServiceInstance(serviceData);
142 public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfFalse_vgNameFalse() {
143 ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596-vnfEcompNamingFalse.zip",
144 "4a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
146 false, false, false, false,
147 "2017-488_ADIOD-vPE 0",
148 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", 1, 1, new ArrayList<>());
150 deployServiceInstance(serviceData);
154 public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingServiceFalseVnfFalse_vgNameTrue() {
155 ServiceData serviceData = new ServiceData("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596-vnfEcompNamingFalse.zip",
156 "4a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
158 false, false, true, false,
159 "2017-488_ADIOD-vPE 0",
160 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>());
162 deployServiceInstance(serviceData);
165 private void deployServiceInstance(ServiceData serviceData) {
166 deployServiceInstance(serviceData, true);
169 private String deployServiceInstance(ServiceData serviceData, boolean tryCancelsAndReentries) {
170 User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP);
172 final String serviceInstanceName = createSriovService(
173 user, serviceData.dynamicFields, serviceData.csarName, serviceData.modelUuid,
174 serviceData.isGeneratedNaming, serviceData.multiStageDesign,
175 tryCancelsAndReentries);
177 createVnf(serviceData.vnfData.isGeneratedNaming, serviceData.vnfData.vnfName, serviceInstanceName, tryCancelsAndReentries);
180 serviceData.vfData.vfName, serviceData.vnfData.isGeneratedNaming,
181 serviceData.vfData.vgEnabled, serviceData.vfData.vfMin, serviceData.vfData.vfMax,
182 serviceData.vfData.dynamicFields, serviceInstanceName);
184 return serviceInstanceName;
189 public void createNewServiceInstance_macro_validPopupDataAndUI__ecompNamingTrue() {
191 List<String> serviceDynamicFields = Arrays.asList("2017488 adiodvpe0 asn:");
192 ServiceData serviceData = new ServiceData("csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip",
193 "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
194 serviceDynamicFields,
195 true, true, false, false,
196 "2017-488_ADIOD-vPE 0",
197 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>());
199 deployServiceInstance(serviceData);
203 private void deployAndVerifyModuleInPendingTable(String serviceInstanceName) {
204 drawingBoardPage.clickDeployButton();
206 boolean simulatorUpdated = false;
208 vidBasePage.goToIframe();
209 GeneralUIUtils.ultimateWait();
210 int[] ids = {1, 1, 2, 3};
211 String[] statuses = {"IN_PROGRESS", "COMPLETED", "IN_PROGRESS", "PENDING"};
212 for (int i = 0; i < ids.length; i++) {
213 String actualInstanceName = getActualInstanceName(serviceInstanceName, ids[i], statuses[i]);
215 final Set<String> expectedStatuses = ImmutableSet.of(statuses[i]);
216 ServiceStatusChecker serviceStatusChecker = new ServiceStatusChecker(actualInstanceName, expectedStatuses);
217 boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 20, 2);
218 final String assertionMessage = String.format("service %s: none of rowClasses [%s] is in expectedStatuses: [%s] ",
220 String.join(",", serviceStatusChecker.getColumnClassesSet()),
221 String.join(",", expectedStatuses));
223 assertTrue(assertionMessage, statusIsShown);
225 InstantiationStatusPage.assertInstantiationStatusRow(
226 actualInstanceName, expectedRowFields(actualInstanceName));
228 if (!simulatorUpdated) {
229 simulatorUpdated = true;
230 final String request1 = PresetMSOBaseCreateServiceInstancePost.DEFAULT_REQUEST_ID;
231 final String request2 = "ce010256-3fdd-4cb5-aed7-37112a2c6e93";
232 SimulatorApi.registerExpectationFromPreset(new PresetMSOCreateServiceInstanceGen2(request2), APPEND);
233 SimulatorApi.registerExpectationFromPreset(new PresetMSOOrchestrationRequestGet("IN_PROGRESS", request2), APPEND);
234 SimulatorApi.registerExpectationFromPreset(new PresetMSOOrchestrationRequestGet("COMPLETE", request1), APPEND);
237 vidBasePage.screenshotDeployDialog(serviceInstanceName);
240 private String getActualInstanceName(String serviceInstanceName, Integer i, String status) {
241 return "PENDING".equals(status) ? serviceInstanceName : serviceInstanceName + "_00" + i;
244 private void verifyOpenViewEdit(String serviceInstanceName) {
245 boolean[] openEnabled = {true, false, false};
246 String[] statuses = {"COMPLETED", "IN_PROGRESS", "PENDING"};
247 ImmutableList.of(1, 2, 3).forEach(i -> {
248 String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i - 1]);
249 checkMenuItem(actualInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_OPEN_ITEM, openEnabled[i - 1], contextMenuOpen -> {
250 Click.byTestId(contextMenuOpen);
251 vidBasePage.goOutFromIframe();
252 GeneralUIUtils.ultimateWait();
254 Wait.byText("View/Edit Service Instance");
255 Wait.byText("Add node instance");
256 Wait.byText("i'm a port");
257 Wait.byText("f8791436-8d55-4fde-b4d5-72dd2cf13cfb");
259 vidBasePage.screenshotDeployDialog("view-edit-" + actualInstanceName);
260 SideMenu.navigateToMacroInstantiationStatus();
266 private void verifyOpenAuditInfo(String serviceInstanceName) {
267 boolean auditInfoEnabled = true;
268 String[] statuses = {"COMPLETED", "IN_PROGRESS", "PENDING"};
269 for (Integer i : ImmutableList.of(1, 2, 3)) {
270 String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i - 1]);
271 checkMenuItem(actualInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_AUDIT_INFO_ITEM, auditInfoEnabled, contextMenuOpen -> {
272 Click.byTestId(contextMenuOpen);
273 checkAuditInfoModal(actualInstanceName, i, statuses);
275 final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName);
276 row.findElement(By.id(Constants.InstantiationStatus.TD_JOB_STATUS_ICON + "-" + (i - 1))).click();
277 checkAuditInfoModal(actualInstanceName, i, statuses);
281 private void checkAuditInfoModal(String actualInstanceName, Integer i, String[] statuses) {
283 Wait.waitByTestId("vidJobStatus", 10);
285 WebElement webElement = Get.byTestId("model-item-value-serviceInstanceName");
286 assertEquals(webElement.getText(), actualInstanceName, "Service Instance Name must be equal");
288 WebElement vidTableElement = Get.byId("service-instantiation-audit-info-vid");
289 assertEquals(3, vidTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "VID table must contain 3 columns");
291 List<WebElement> vidStatusesElements = vidTableElement.findElements(By.id("vidJobStatus"));
292 List<String> vidStatuses = vidStatusesElements.stream()
294 convertUITextCapitalizeAndFormatPipe(s.getText()))
295 .collect(Collectors.toList());
297 List<String> serviceStatus = Arrays.asList(Arrays.copyOfRange(statuses, i - 1, statuses.length));
298 assertThat("statuses for " + actualInstanceName + " must be as expected", vidStatuses, is(Lists.reverse(serviceStatus)));
300 String dateString = vidTableElement.findElements(By.id("vidStatusTime")).get(0).getText();
301 assertTrue("vid Status Time column must contains valid date in format : MMM dd, yyyy HH:mm", isDateValid(dateString, "MMM dd, yyyy HH:mm"));
303 WebElement MSOTableElement = Get.byId("service-instantiation-audit-info-mso");
304 assertEquals(4, MSOTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "MSO table must contain 4 columns");
306 if (statuses[i - 1].equals("PENDING")) {
307 assertEquals(0, MSOTableElement.findElement(By.tagName("tbody")).findElements(By.tagName("tr")).size(), "When status is PENDING MSO table is empty");
310 vidBasePage.screenshotDeployDialog("audit-info-" + actualInstanceName);
311 Click.byId(Constants.AuditInfoModal.CANCEL_BUTTON);
314 private String convertUITextCapitalizeAndFormatPipe(String text) {
315 return text.toUpperCase().replace("-", "_");
318 private boolean isDateValid(String dateToValidate, String dateFromat) {
320 if (dateToValidate == null) {
323 SimpleDateFormat sdf = new SimpleDateFormat(dateFromat);
324 sdf.setLenient(false);
326 //if not valid, it will throw ParseException
327 Date date = sdf.parse(dateToValidate);
329 } catch (ParseException e) {
336 private void verifyDeleteJob(String serviceInstanceName) {
337 boolean[] deleteEnabled = {false, false, true};
338 String[] statuses = {"COMPLETED", "IN_PROGRESS", "PENDING"};
339 verifyDeleteOrHideOperation(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_DELETE, statuses, deleteEnabled, "deleted");
342 private void verifyHideJob(String serviceInstanceName) {
343 boolean[] hideEnabled = {true, false};
344 String[] statuses = {"COMPLETED", "IN_PROGRESS"};
345 verifyDeleteOrHideOperation(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HIDE, statuses, hideEnabled, "hidden");
348 private void verifyDeleteOrHideOperation(String serviceInstanceName, String contextMenuItem, String[] statuses, boolean[] operationEnabled, String operationName) {
349 for (int i = 1; i <= statuses.length; i++) {
350 String actualInstanceName = getActualInstanceName(serviceInstanceName, i, statuses[i - 1]);
351 checkMenuItem(actualInstanceName, contextMenuItem, operationEnabled[i - 1], contextMenuDelete -> {
352 Click.byTestId(contextMenuDelete);
353 GeneralUIUtils.ultimateWait();
354 assertNull(actualInstanceName + " should be " + operationName,
355 InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName));
358 vidBasePage.screenshotDeployDialog(serviceInstanceName);
361 private void checkMenuItem(String actualInstanceName, String contextMenuItem, boolean shouldBeEnabled, Consumer<String> doIfEnabled) {
362 Wait.waitFor(name -> {
363 if (null == InstantiationStatusPage.getInstantiationStatusRow(name)) {
364 InstantiationStatusPage.clickRefreshButton();
369 }, actualInstanceName, 8, 1);
370 final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName);
371 row.findElement(By.className("menu-div")).click();
372 String clazz = Get.byXpath("//div[@data-tests-id='" + contextMenuItem + "']/ancestor::li").getAttribute("class");
373 assertThat("item " + contextMenuItem + " of " + actualInstanceName +
374 " should be " + (shouldBeEnabled ? "enabled" : "disabled"), !clazz.equals("disabled"), is(shouldBeEnabled));
375 if (shouldBeEnabled) {
376 doIfEnabled.accept(contextMenuItem);
379 Get.byClass("title").get(0).click();
383 private ImmutableMap<String, String> expectedRowFields(String actualInstanceName) {
384 return ImmutableMap.<String, String>builder()
385 .put("userId", getUserCredentials().getUserId())
386 .put("serviceModelName", "action-data")
387 .put("serviceInstanceName", actualInstanceName)
388 .put("serviceModelVersion", "1.0")
389 .put("subscriberName", "USP VOICE")
390 .put("serviceType", "VIRTUAL USP")
391 .put("regionId", "mtn6")
392 .put("tenantName", "AIN Web Tool-15-D-testgamma")
393 .put("aicZoneName", "NFTJSSSS-NFT1")
394 .put("project", "DFW")
395 .put("owningEntityName", "MetroPacketCore")
396 .put("pause", "false")
400 private String createSriovService(User user, List<String> serviceDynamicFields,
401 String csarName, String modelId, boolean modelWithGeneratedName,
402 boolean multiStageDesign, boolean tryCancelsAndReentries) {
403 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
405 // simulate typing with spaces, but expected is without spaces
406 String serviceInstanceNameWithSpaces = RandomStringUtils.randomAlphabetic(5) + " instance name";
407 String serviceInstanceName = serviceInstanceNameWithSpaces.replace(" ", "");
409 List<String> cycles = tryCancelsAndReentries ? ImmutableList.of("WILL_CANCEL", "AFTER_CANCEL") : ImmutableList.of("SINGLE_SHOT");
410 cycles.forEach(cycle -> {
411 if ("AFTER_CANCEL".equals(cycle)) {
412 loadServicePopupOnBrowseASDCPage(modelId);
414 loadServicePopup(csarName, modelId);
417 WebElement instanceName = Get.byId("instance-name");
418 if (modelWithGeneratedName) {
419 Assert.assertNull(instanceName, "instance name input should be invisible when serviceEcompNaming == true.");
421 instanceName.sendKeys(serviceInstanceNameWithSpaces);
424 //serviceType should be dependent on subscriber selection
425 assertElementDisabled("service-type-select");
427 GeneralUIUtils.ultimateWait();
428 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
429 VidBasePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
430 GeneralUIUtils.ultimateWait();
432 //lcpRegion should be dependent on serviceType selection
433 assertElementDisabled("lcpRegion-select");
435 String serviceType = "VIRTUAL USP";
436 Wait.waitByClassAndText(Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS, serviceType, 30);
437 browseASDCPage.selectServiceTypeByName(serviceType);
439 //tenant should be dependent on lcpRegion selection
440 assertElementDisabled("tenant-select");
442 String lcpRegion = "mtn6";
443 Wait.waitByClassAndText("lcpRegionOption", lcpRegion, 30);
444 browseASDCPage.selectLcpRegion(lcpRegion);
446 browseASDCPage.selectTenant("bae71557c5bb4d5aac6743a4e5f1d054");
448 String setButtonTestId = "service-form-set";
449 assertSetButtonDisabled(setButtonTestId);
451 SelectOption.byTestIdAndVisibleText("MetroPacketCore", (Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID));
452 assertSetButtonDisabled(setButtonTestId);
454 SelectOption.byTestIdAndVisibleText("DHV", Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID);
455 assertSetButtonEnabled(setButtonTestId);
457 browseASDCPage.selectProductFamily("e433710f-9217-458d-a79d-1c7aff376d89");
459 assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS);
460 browseASDCPage.selectAicZone("NFT1");
462 SelectOption.byTestIdAndVisibleText("DFW", Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
464 assertNotificationAreaVisibilityBehaviour();
466 assertPauseOnPausePointsVisibility(multiStageDesign);
468 validateDynamicFields(serviceDynamicFields);
470 vidBasePage.screenshotDeployDialog("createSriovService-" + serviceInstanceName);
472 if ("WILL_CANCEL".equals(cycle)) {
473 Click.byTestId(Constants.CANCEL_BUTTON_TEST_ID);
475 Click.byTestId(setButtonTestId);
478 browseASDCPage.goOutFromIframe();
480 browseASDCPage.goToIframe();
483 return serviceInstanceName;
486 private void createVnf(boolean isInstanceNameGenerated, String vnfName, String serviceInstanceName, boolean tryCancelsAndReentries) {
487 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
488 drawingBoardPage.clickAddButtonByNodeName(vnfName);
490 if (isInstanceNameGenerated) {
491 WebElement instanceName = Get.byId("instance-name");
492 Assert.assertNull(instanceName, "instance name input should be invisible when serviceEcompNaming == true.");
494 Input.text("VNF instance name", "instanceName");
497 //tenant should be dependent on lcpRegion selection
498 assertElementDisabled("tenant-select");
500 WebElement legacyRegion = Get.byTestId("lcpRegionText");
501 Assert.assertNull(legacyRegion, "legacy region shouldn't be visible when lcp region isn't AAIAIC25,rdm3 or rdm5a.");
503 browseASDCPage.selectLcpRegion("AAIAIC25");
505 legacyRegion = Get.byTestId("lcpRegionText");
506 Assert.assertNotNull(legacyRegion, "legacy region should be visible when lcp region is AAIAIC25,rdm3 or rdm5a.");
508 browseASDCPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86");
510 String setButtonTestId = "vnf-form-set";
511 assertSetButtonDisabled(setButtonTestId);
513 browseASDCPage.selectPlatform("platform");
515 assertSetButtonEnabled(setButtonTestId);
517 browseASDCPage.setLegacyRegion("some legacy region");
518 browseASDCPage.selectLineOfBusiness("ECOMP");
520 Wait.waitByTestId("model-item-value-subscriberName", 10);
521 Assert.assertEquals(Get.byTestId("model-item-value-subscriberName").getText(), "USP VOICE", "Subscriber name should be shown in vf module");
522 Assert.assertEquals(Get.byTestId("model-item-value-min"), null, "Min value should not be shown in VNF popup");
523 Assert.assertEquals(Get.byTestId("model-item-value-max"), null, "Max value should not be show in VNF popup");
524 if (!isInstanceNameGenerated) {
525 Assert.assertEquals(Get.byTestId("model-item-value-serviceName").getText(), serviceInstanceName, "Subscriber name should be shown in vf module");
528 vidBasePage.screenshotDeployDialog("createVnf-" + serviceInstanceName);
529 Click.byTestId(setButtonTestId);
531 String nodeToEdit = "69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_ADIOD-vPE 0";
532 if (tryCancelsAndReentries) {
533 hoverAndClickEditButton(nodeToEdit);
535 Wait.byText("VIRTUAL USP");
536 GeneralUIUtils.ultimateWait();
537 Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID), "AAIAIC25");
538 Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.TENANT_SELECT_TESTS_ID), "USP-SIP-IC-24335-T-01");
539 Assert.assertEquals(Get.selectedOptionText(Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID), "ECOMP");
540 Assert.assertEquals(Get.selectedOptionText(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID), "platform");
541 Click.byTestId(Constants.CANCEL_BUTTON_TEST_ID);
543 toggleItemInTree(nodeToEdit);
547 private void toggleItemInTree(String nodeToEdit) {
548 Click.byXpath("//tree-root[@data-tests-id='" + Constants.DrawingBoard.AVAILABLE_MODELS_TREE + "']//span[@class='" + Constants.DrawingBoard.TOGGLE_CHILDREN + "']");
551 private void hoverAndClickEditButton(String nodeToEdit) {
552 String buttonOfEdit = Constants.DrawingBoard.NODE_PREFIX + nodeToEdit + Constants.DrawingBoard.CONTEXT_MENU_BUTTON;
553 GeneralUIUtils.hoverOnAreaByTestId(buttonOfEdit);
554 Click.byTestId(buttonOfEdit);
555 Click.byTestId(Constants.DrawingBoard.CONTEXT_MENU_ITEM);
558 private void createVfModule(String vfModuleName, boolean isInstanceNameGenerated, boolean vgEnabled, int vgMin,
559 int vgMax, List<String> vfModuleDynamicFields, String serviceInstanceName) {
560 String setButtonTestId = "vnf-form-set";
561 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
562 // Click.byTestId(Constants.DrawingBoard.NODE_PREFIX + vnfName);
563 drawingBoardPage.clickAddButtonByNodeName(vfModuleName);
564 if (!isInstanceNameGenerated) {
565 Input.text("VF instance name", "instanceName");
567 Assert.assertNull(Get.byTestId("instanceName"));
568 Assert.assertNull(Get.byTestId("volumeGroupName"));
571 if (vgEnabled && !isInstanceNameGenerated) {
572 browseASDCPage.setInputText("volumeGroupName", "some group name name");
574 Assert.assertNull(Get.byTestId("volumeGroupName"), "volumeGroupName input should be invisible when vgEnabled == false");
576 Wait.waitByTestId("model-item-value-subscriberName", 10);
577 Assert.assertEquals(Get.byTestId("model-item-value-subscriberName").getText(), "USP VOICE", "Subscriber name should be shown in vf module");
578 Assert.assertEquals(Get.byTestId("model-item-value-min").getText(), Integer.toString(vgMin), "Min should be shown");
579 Assert.assertEquals(Get.byTestId("model-item-value-max").getText(), Integer.toString(vgMax), "Max should be shown");
580 if (!isInstanceNameGenerated) {
581 Wait.byText(serviceInstanceName);
582 Assert.assertEquals(Get.byTestId("model-item-value-serviceName").getText(), serviceInstanceName, "Service name should be shown in vf module");
584 validateDynamicFields(vfModuleDynamicFields);
586 browseASDCPage.screenshotDeployDialog("createVfModule-" + serviceInstanceName);
587 Click.byTestId(setButtonTestId);
590 private void assertPauseOnPausePointsVisibility(boolean visibility) {
591 WebElement pauseElem = Get.byId("pause");
592 final String assertionMessage = "pause on pause points visibility should be " + visibility;
594 Assert.assertNotNull(pauseElem, assertionMessage);
596 Assert.assertNull(pauseElem, assertionMessage);
600 private void assertNotificationAreaVisibilityBehaviour() {
601 WebElement webElement = Get.byId("notification-area");
602 Assert.assertNull(webElement, "notification area should be invisible if only 1 qty.");
604 SelectOption.byIdAndVisibleText("quantity-select", "3");
606 webElement = Get.byId("notification-area");
607 Assert.assertNotNull(webElement, "notification area should be visible if more then 1 qty.");
611 * following are two popup service models that represent two opposite/extreme states of the popup.
612 * they should be enough to test all the possible popup states.
614 private void loadMacroServicePopup_withDynamicFields_partialModelDetails_ecompNamingTrue() {
615 loadServicePopup("csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip", "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd");
618 private void loadMacroServicePopup_noDynamicFields_fullModelDetails_ecompNamingFalse() {
619 loadServicePopup("csar-noDynamicFields-ecompNamingFalse-fullModelDetails-1a80c596.zip", "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd");
623 private Object[][] createSriovService(
625 List<String> dynamicFields = Arrays.asList(
626 "2017488 adiodvpe0 VNF config template version:",
627 "Adiodvpe0 bandwidth units:",
628 "Adiodvpe0 bandwidth:",
629 "2017488 adiodvpe0 aic clli:",
630 "2017488 adiodvpe0 asn:",
631 "2017488 adiodvpe0 VNF instance name");
632 ServiceData withEcompNaming = new ServiceData("csar-withDynamicFields-ecompNamingTrue-partialModelDetails.zip",
633 "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
635 true, true, true, false,
636 "2017-488_ADIOD-vPE 0",
637 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>());
638 return new Object[][]{{withEcompNaming}};
642 private class ServiceData {
644 public ServiceData(String csarName, String modelUuid, List<String> dynamicFields, boolean isServiceGeneratedNaming, boolean isVnfGeneratedNaming, boolean isVgEnabled, boolean multiStageDesign, String vnfName, String vfName, int vfMin, int vfMax, List<String> vfModuleDynamicFields) {
645 this.csarName = csarName;
646 this.modelUuid = modelUuid;
647 this.dynamicFields = dynamicFields;
648 this.isGeneratedNaming = isServiceGeneratedNaming;
649 this.multiStageDesign = multiStageDesign;
650 this.vnfData = new VnfData(vnfName, isVnfGeneratedNaming);
651 this.vfData = new VfData(vfName, isVgEnabled, vfMin, vfMax, vfModuleDynamicFields);
654 public String csarName;
655 public String modelUuid;
656 public List<String> dynamicFields;
657 public boolean isGeneratedNaming;
658 public boolean multiStageDesign;
659 public VnfData vnfData;
660 public VfData vfData;
664 private class VnfData {
666 public VnfData(String vnfName, boolean isGeneratedNaming) {
667 this.vnfName = vnfName;
668 this.isGeneratedNaming = isGeneratedNaming;
671 public String vnfName;
672 public boolean isGeneratedNaming;
676 private class VfData {
677 public VfData(String vfName, boolean vgEnabled, int vfMin, int vfMax, List<String> dynamicFields) {
678 this.vfName = vfName;
679 this.vgEnabled = vgEnabled;
682 this.dynamicFields = dynamicFields;
689 public String vfName;
691 public boolean vgEnabled;
693 public List<String> dynamicFields;
698 private class ServiceStatusChecker implements Predicate<Boolean> {
699 private String actualInstanceName;
700 private Set<String> expectedStatuses;
701 private Set<String> columnClassesSet;
703 public ServiceStatusChecker(String actualInstanceName, Set<String> expectedStatuses) {
704 this.actualInstanceName = actualInstanceName;
705 this.expectedStatuses = expectedStatuses;
709 public boolean test(Boolean noMeaning) {
710 InstantiationStatusPage.clickRefreshButton();
711 final WebElement row = InstantiationStatusPage.getInstantiationStatusRow(actualInstanceName);
713 System.err.println("**********************" + actualInstanceName + "************************************************");
714 columnClassesSet = Collections.singleton(actualInstanceName + " NOT FOUND");
715 return false; // treat missing row as if test condition not fulfilled
717 columnClassesSet = new HashSet<>(Arrays.asList(
718 row.findElements(By.xpath(".//*[@id='" + "jobStatus" + "']")).get(0).getAttribute("class").split(" ")));
719 return !(Sets.intersection(expectedStatuses, columnClassesSet).isEmpty());
723 public Set<String> getColumnClassesSet() {
724 return columnClassesSet;