1 package vid.automation.test.test;
3 import java.util.ArrayList;
4 import org.junit.Assert;
5 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
6 import org.openqa.selenium.WebElement;
7 import vid.automation.test.Constants;
8 import vid.automation.test.infra.Click;
9 import vid.automation.test.infra.Exists;
10 import vid.automation.test.infra.SelectOption;
11 import vid.automation.test.model.Service;
12 import vid.automation.test.model.ServiceModel;
13 import vid.automation.test.sections.ViewEditPage;
15 public class CreateInstanceDialogBaseTest extends VidBaseTestCase {
17 protected ViewEditPage viewEditPage= new ViewEditPage();
19 void assertServiceMetadata(String expectedMetadata, String actualMetadata) {
20 WebElement serviceNameElem = GeneralUIUtils.getWebElementByTestID(actualMetadata);
21 String actualServiceName = serviceNameElem.getText();
22 Assert.assertEquals(expectedMetadata, actualServiceName);
25 void validateServiceCreationDialog(Service expectedService) {
26 assertThatServiceCreationDialogIsVisible();
27 assertServiceMetadata(expectedService.name, Constants.SERVICE_NAME);
28 assertServiceMetadata(expectedService.uuid, Constants.SERVICE_UUID);
29 assertServiceMetadata(expectedService.invariantUuid, Constants.SERVICE_INVARIANT_UUID);
30 assertServiceMetadata(expectedService.category, Constants.SERVICE_CATEGORY);
31 assertServiceMetadata(expectedService.version, Constants.SERVICE_VERSION);
32 assertServiceMetadata(expectedService.description, Constants.SERVICE_DESCRIPTION);
35 public void assertThatServiceCreationDialogIsVisible() {
36 boolean byText = GeneralUIUtils.findAndWaitByText(Constants.BrowseASDC.CREATE_SERVICE_INSTANCE, 15);
37 Assert.assertTrue(byText);
40 void assertSuccessfulServiceInstanceCreation() {
41 boolean byText = GeneralUIUtils.findAndWaitByText(Constants.BrowseASDC.SERVICE_INSTANCE_CREATED_SUCCESSFULLY_TEXT, 100);
42 Assert.assertTrue(Constants.BrowseASDC.SERVICE_INSTANCE_CREATION_FAILED_MESSAGE, byText);
45 void validateVnfCreationDialog(ServiceModel expectedServiceInstance) {
46 GeneralUIUtils.ultimateWait();
47 validateNodeTemplateCreationDialog(expectedServiceInstance);
48 assertServiceMetadata(expectedServiceInstance.resourceName, Constants.CreateNewInstance.RESOURCE_NAME);
49 assertServiceMetadata(expectedServiceInstance.nfType, Constants.CreateNewInstance.NF_TYPE);
50 assertServiceMetadata(expectedServiceInstance.nfRole, Constants.CreateNewInstance.NF_ROLE);
51 assertServiceMetadata(expectedServiceInstance.nfFunction, Constants.CreateNewInstance.NF_FUNCTION);
52 assertServiceMetadata(expectedServiceInstance.nfNamingCode, Constants.CreateNewInstance.NF_NAMING_CODE);
55 void validateNodeTemplateCreationDialog(ServiceModel expectedServiceInstance){
56 GeneralUIUtils.ultimateWait();
57 assertServiceMetadata(expectedServiceInstance.serviceName, Constants.SERVICE_NAME);
58 assertServiceMetadata(expectedServiceInstance.subscriberName, Constants.SUBSCRIBER_NAME);
59 assertServiceMetadata(expectedServiceInstance.serviceInstanceName, Constants.SERVICE_INSTANCE_NAME);
60 assertServiceMetadata(expectedServiceInstance.modelName, Constants.CreateNewInstance.MODEL_NAME);
61 assertServiceMetadata(expectedServiceInstance.modelInvariantUuid, Constants.CreateNewInstance.MODEL_INVARIANT_UUID);
62 assertServiceMetadata(expectedServiceInstance.modelVersion, Constants.CreateNewInstance.MODEL_VERSION);
63 assertServiceMetadata(expectedServiceInstance.modelUuid, Constants.CreateNewInstance.MODEL_UUID);
64 assertServiceMetadata(expectedServiceInstance.modelCustomizationUuid, Constants.CreateNewInstance.MODEL_CUSTOMIZATION_UUID);
67 private String fillDetailsInDialog(String name, String lcpRegion, String cloudOwner, String tenant, String suppressRollback,
68 String legacyRegion, ArrayList<String> permittedTenants)
70 viewEditPage.setInstanceName(name);
71 viewEditPage.selectLcpRegion(lcpRegion, cloudOwner);
72 assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS);
73 viewEditPage.selectTenant(tenant);
74 viewEditPage.selectSuppressRollback(suppressRollback);
75 viewEditPage.setLegacyRegion(legacyRegion);
80 protected String addVFModule(String modelName, String instanceName, String lcpRegion, String cloudOwner, String tenant, String suppressRollback,
81 String legacyRegion, ArrayList<String> permittedTenants,ServiceModel expectedServiceInstance) {
82 viewEditPage.selectVfModuleToAdd(modelName);
83 if(expectedServiceInstance != null) {
84 validateNodeTemplateCreationDialog(expectedServiceInstance);
86 fillDetailsInDialog(instanceName, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, permittedTenants);
87 viewEditPage.clickConfirmButton();
88 assertSuccessfulVFModuleCreation();
89 viewEditPage.clickCloseButton();
90 GeneralUIUtils.ultimateWait();
94 protected void addVolumeGroup (String modelName, String instanceName, String lcpRegion, String cloudOwner, String tenant, String suppressRollback,
95 String legacyRegion, ArrayList<String> permittedTenants, ServiceModel expectedServiceInstance) {
96 viewEditPage.selectVolumeGroupToAdd(modelName);
97 if(expectedServiceInstance != null) {
98 validateNodeTemplateCreationDialog(expectedServiceInstance);
100 fillDetailsInDialog(instanceName, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, permittedTenants);
101 viewEditPage.clickConfirmButton();
102 assertSuccessfulVolumeGroupCreation();
103 viewEditPage.clickCloseButton();
104 GeneralUIUtils.ultimateWait();
107 protected void addVNF(String name, String lcpRegion, String cloudOwner, String tenant, String suppressRollback,
108 String legacyRegion, String productFamily, String platform, ArrayList<String> permittedTenants, String lobs, ServiceModel serviceModel, String instanceName) {
109 openAndFillVnfPopup(name, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, productFamily, platform,permittedTenants, lobs, serviceModel, instanceName);
110 viewEditPage.clickConfirmButton();
111 successConfirmVnfAndClosePopup();
115 protected void openAndFillVnfPopup(String name, String lcpRegion, String cloudOwner, String tenant, String suppressRollback,
116 String legacyRegion, String productFamily, String platform, ArrayList<String> permittedTenants, String lobs, ServiceModel serviceModel, String instanceName) {
117 viewEditPage.selectNodeInstanceToAdd(name);
118 GeneralUIUtils.ultimateWait();
119 if(serviceModel != null) {
120 validateVnfCreationDialog(serviceModel);
122 viewEditPage.selectProductFamily(productFamily);
123 if(platform != null) {
124 SelectOption.byTestIdAndVisibleText(platform, Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
127 Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
130 viewEditPage.selectLineOfBusiness(lobs);
132 fillDetailsInDialog(instanceName, lcpRegion, cloudOwner, tenant, suppressRollback, legacyRegion, permittedTenants);
135 protected void successConfirmVnfAndClosePopup() {
136 assertSuccessfulVNFCreation();
137 viewEditPage.clickCloseButton();
138 GeneralUIUtils.ultimateWait();
141 protected void assertConfirmShowMissingDataErrorOnCurrentPopup(String field) {
142 viewEditPage.clickConfirmButton();
143 boolean byclassAndText = Exists.byClassAndText(Constants.ViewEdit.ERROR_CLASS, String.format(Constants.MISSING_DATA, field));
144 Assert.assertTrue(field + " " + Constants.REQUIRED, byclassAndText);