diff options
author | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
---|---|---|
committer | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
commit | 1cfb08779ea0e00be69e072a940b3063e049fe6b (patch) | |
tree | 6602a900387c8393ed0dcd81c0539381632903c6 /vid-automation/src/main/java/vid/automation/test/test | |
parent | 2f20b001b9243e0f8b44aecc768ec265fd538732 (diff) |
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d
Issue-ID: VID-86
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/test')
10 files changed, 2161 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java b/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java new file mode 100644 index 000000000..894be37b0 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/AssociatePnfTest.java @@ -0,0 +1,201 @@ +package vid.automation.test.test; + +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; +import vid.automation.test.model.User; +import vid.automation.test.sections.PnfSearchAssociationPage; +import vid.automation.test.sections.VidBasePage; +import vid.automation.test.sections.ViewEditPage; +import vid.automation.test.services.BulkRegistration; +import vid.automation.test.services.SimulatorApi; +import vid.automation.test.services.UsersService; + +import java.io.IOException; + +public class AssociatePnfTest extends VidBaseTestCase { + + private UsersService usersService = new UsersService(); + private VidBasePage vidBasePage = new VidBasePage(); + private ViewEditPage viewEditPage = new ViewEditPage(); + private PnfSearchAssociationPage pnfSearchAssociationPage = new PnfSearchAssociationPage(); + private String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + private String pnfInstanceName = "MX_960-F722"; + private String pnfModelName = "pnf 0"; + + public AssociatePnfTest() throws IOException { } + //work with Simulator & asdc client + @Test + public void testAssociatePnf() throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.associatePnf(); + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + goToExistingInstanceById(serviceInstanceId);//vid-test-444 + addPNF(pnfModelName);//vid-test-444 + searchPNF(pnfInstanceName); + testResultSearchPNF(); + associatePNF(); + vidBasePage.assertMsoRequestModal("COMPLETE - Success"); + vidBasePage.clickCloseButton(); + } + + @Test + public void testRainyAssociatePnf() throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.associatePnfError(); + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + goToExistingInstanceById(serviceInstanceId); + addPNF(pnfModelName); + searchPNF(pnfInstanceName); + associatePNF(); + vidBasePage.assertMsoRequestModal("Error"); + vidBasePage.clickCloseButton(); + } + @Test + public void testRainyChoosePnf() throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.associatePnfError(); + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + goToExistingInstanceById(serviceInstanceId); + String pnfName= "pnf 1"; + GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID, 60); + String message = String.format(Constants.ViewEdit.OPTION_IN_DROPDOWN_NOT_EXISTS, + Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID,"Add network instance"); + boolean waitForElementResult = Wait.waitByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + pnfName, 60); + Assert.assertTrue(message, !waitForElementResult); + } + @Test + public void testRainySearchPnfInstance() throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.associatePnfError(); + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + goToExistingInstanceById(serviceInstanceId); + addPNF(pnfModelName); + searchPNF("AAAAA"); + Wait.angularHttpRequestsLoaded(); + WebElement errorMessageWebElement = GeneralUIUtils.getWebElementByTestID(Constants.PnfAssociation.NOT_FOUND_ERROR_TEST_ID, 60); + 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" + + "Please note: A&AI is case sensitive",errorMessageWebElement.getText()); + Assert.assertTrue(Constants.PnfAssociation.NOT_FOUND_ERROR_MESSAGE, errorMessageWebElement!=null); + assertAssociateButtonState(false); + } + + private void assertAssociateButtonState(boolean shouldBeEnabled) { + WebElement associateWebElement = GeneralUIUtils.getWebElementByTestID(Constants.PnfAssociation.ASSOCIATE_PNF_TEST_ID, 60); + boolean enabledAssociate=associateWebElement.isEnabled(); + + if(shouldBeEnabled) { + Assert.assertTrue(Constants.PnfAssociation.PNF_ENABLE_ASSOCIATE_ERROR_MESSAGE, enabledAssociate); + }else{ + Assert.assertTrue(Constants.PnfAssociation.PNF_DISABLE_ASSOCIATE_ERROR_MESSAGE, !enabledAssociate); + } + GeneralUIUtils.ultimateWait(); + } + private void associatePNF() throws InterruptedException { + pnfSearchAssociationPage.clickAssociateButton(); + } + + private void addPNF(String name){ + viewEditPage.selectNodeInstanceToAdd(name); + checkServiceModelInfo(); + assertAssociateButtonState(false); + } + + private void searchPNF(String name){ + pnfSearchAssociationPage.setPnfName(name); + pnfSearchAssociationPage.clickSearchButton(); + } + + private void testResultSearchPNF(){ + checkPnfProperties(); + Wait.angularHttpRequestsLoaded(); + assertAssociateButtonState(true); + } + private void checkServiceModelInfo() { + Wait.angularHttpRequestsLoaded(); + //Service name + String elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.SERVIICE_NAME_KEY; + String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"Demo Service 1"); + //model name + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.MODEL_NAME; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"Test Pnf"); + //service instance name + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.SERVICE_INSTANCE_NAME; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"vid-test-444"); + //Model Invariant UUID + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.MODEL_INVARIANT_UUID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"61eba322-c758-48f6-8942-1a7625aaaffb"); + //ubscriber NameModel Invariant UUID + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.SUBSCRIBER_NAME_KEY; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"USP VOICE"); + //Model Version + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.MODEL_VERSION; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"0.1"); + //Model UUID + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.MODEL_UUID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"089b1c03-ff6b-4914-8c20-a7de3d375e8d"); + //Model Customization UUID + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.MODEL_CUSTOMIZATION_UUID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,"cabf6d26-c362-4444-ba06-f850e8af2d35"); + //Resource Name + elementTestId = Constants.serviceModelInfo.INFO_TEST_ID_PREFIX + Constants.serviceModelInfo.RESOURCE_NAME; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.serviceModelInfo.METADETA_ERROR_MESSAGE,elementTestId),infoItemText,pnfModelName); + } + + private void checkPnfProperties() { + //Pnf Instance unique name + String elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME_TEST_ID; + String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,pnfInstanceName); + //Pnf Instance name2 + elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME2_TEST_ID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-name-2"); + //Pnf Instance name2 source + elementTestId = Constants.PnfAssociation.PNF_INSTANCE_NAME2_SOURCE_TEST_ID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-name-2-source"); + //Pnf Instance Id + elementTestId = Constants.PnfAssociation.PNF_INSTANCE_ID_TEST_ID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"MX_960-F722-id"); + //Pnf Instance Equipment type + elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_TYPE_TEST_ID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"Switch"); + //Pnf Instance Equipment vendor + elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_VENDOR_TEST_ID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"Cisco"); + //Pnf Instance Equipment model + elementTestId = Constants.PnfAssociation.PNF_INSTANCE_EQUIP_MODEL_TEST_ID; + infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText(); + Assert.assertEquals(String.format(Constants.PnfAssociation.PNF_INSTANCE_ERROR_MESSAGE,elementTestId),infoItemText,"ASR1002-X"); + } + + + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java b/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java new file mode 100644 index 000000000..eb1c62faa --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/BrowseASDCTest.java @@ -0,0 +1,221 @@ +package vid.automation.test.test; + +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.model.*; +import vid.automation.test.sections.BrowseASDCPage; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.sections.ViewEditPage; +import vid.automation.test.services.ServicesService; +import vid.automation.test.services.UsersService; + +import java.io.IOException; + +public class BrowseASDCTest extends CreateInstanceDialogBaseTest { + private UsersService usersService = new UsersService(); + private ServicesService servicesService = new ServicesService(); + + public BrowseASDCTest() throws IOException { + } + + @Test + public void testPNFOnCreatePopup() throws Exception { + Service service = servicesService.getService("f39389e4-2a9c-4085-8ac3-04aea9c651be"); + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + SideMenu.navigateToBrowseASDCPage(); + browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); + assertThatServiceCreationDialogIsVisible(); + validatePNFCreationDialog(service, "Mobility", "pnf"); + } + + private void validatePNFCreationDialog(Service service, String serviceType, String serviceRole) { + assertServiceMetadata(serviceType, Constants.SERVICE_TYPE); + assertServiceMetadata(serviceRole, Constants.SERVICE_ROLE); + validateServiceCreationDialog(service); + } + + @Test + private void testPNFMacroInstantation() throws Exception { + User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY); + relogin(user.credentials); + + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + SideMenu.navigateToBrowseASDCPage(); + browseASDCPage.clickDeployServiceButtonByServiceUUID("f39389e4-2a9c-4085-8ac3-04aea9c651be"); + assertThatServiceCreationDialogIsVisible(); + assertDropdownPermittedItemsByValue(user.subscribers, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + browseASDCPage.selectProductFamily("ebc3bc3d-62fd-4a3f-a037-f619df4ff034"); + GeneralUIUtils.ultimateWait(); + + browseASDCPage.selectServiceTypeByName("Mobility"); + GeneralUIUtils.ultimateWait(); + browseASDCPage.selectLcpRegion("mtn16"); + + browseASDCPage.selectTenant("a259ae7b7c3f493cb3d91f95a7c18149"); + assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS); + browseASDCPage.selectAicZone("NFT1"); + + Click.onFirstSelectOptionById(Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + + browseASDCPage.clickConfirmButton(); + + assertSuccessfulServiceInstanceCreation(); + + browseASDCPage.clickCloseButton(); + + ViewEditPage viewEditPage = new ViewEditPage(); + viewEditPage.clickActivateButton(); + } + + @Test + private void testServiceInstantation() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + SideMenu.navigateToBrowseASDCPage(); + + Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0"); + + browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); + validateServiceCreationDialog(service); + + browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName()); + + assertDropdownPermittedItemsByValue(user.subscribers, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + + String serviceType = "VIRTUAL USP"; + GeneralUIUtils.findAndWaitByText(serviceType, 30); + + assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); + browseASDCPage.selectServiceTypeByName(serviceType); + + Click.onFirstSelectOptionById(Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + + browseASDCPage.selectSuppressRollback("false"); + + browseASDCPage.clickConfirmButton(); + + assertSuccessfulServiceInstanceCreation(); + + browseASDCPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + + addVNF("VID-PCRF-05-15-17 0", "AAIAIC25", "092eb9e8e4b7412e8787dd091bc58e86", + "false", "some legacy region", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", user.tenants); + addVolumeGroup("VidPcrf051517..pcrf_nimbus_pcm..module-4", "AAIAIC25", + "092eb9e8e4b7412e8787dd091bc58e86", "false", "some legacy region", user.tenants); + addVFModule("VidPcrf051517..pcrf_nimbus_psm..module-1", "AAIAIC25", + "092eb9e8e4b7412e8787dd091bc58e86", "false", "some legacy region", user.tenants); + } + + @Test + private void testCategoryParamsDropdownsExistsInCreationDialog() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + SideMenu.navigateToBrowseASDCPage(); + + Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0"); + + browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); + assertThatServiceCreationDialogIsVisible(); + + GeneralUIUtils.clickOnElementByTestId(Constants.OwningEntity.PROJECT_SELECT_TEST_ID); + GeneralUIUtils.clickOnElementByTestId(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + } + + @Test + private void testOwningEntityRequiredAndProjectOptional() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + SideMenu.navigateToBrowseASDCPage(); + + Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0"); + + browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); + validateServiceCreationDialog(service); + + browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName()); + + assertDropdownPermittedItemsByValue(user.subscribers, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + + String serviceType = "VIRTUAL USP"; + GeneralUIUtils.findAndWaitByText(serviceType, 30); + + assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); + browseASDCPage.selectServiceTypeByName(serviceType); + + browseASDCPage.clickConfirmButton(); + + GeneralUIUtils.findAndWaitByText("Missing data", 5); + + Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + + browseASDCPage.clickConfirmButton(); + assertSuccessfulServiceInstanceCreation(); + } + + @Test + protected void testLineOfBusinessOptionalAndPlatformRequired() throws Exception { + + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + + BrowseASDCPage browseASDCPage = new BrowseASDCPage(); + SideMenu.navigateToBrowseASDCPage(); + + Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0"); + + browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid); + validateServiceCreationDialog(service); + + browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName()); + + assertDropdownPermittedItemsByValue(user.subscribers, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + + String serviceType = "VIRTUAL USP"; + GeneralUIUtils.findAndWaitByText(serviceType, 30); + + assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); + browseASDCPage.selectServiceTypeByName(serviceType); + + Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID); + + browseASDCPage.clickConfirmButton(); + assertSuccessfulServiceInstanceCreation(); + + browseASDCPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + + //now add the VNF + ViewEditPage viewEditPage = new ViewEditPage(); + + viewEditPage.selectNodeInstanceToAdd("VID-PCRF-05-15-17 0"); + viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX); + viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + viewEditPage.selectLCPRegion("AAIAIC25"); + viewEditPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86"); + viewEditPage.setLegacyRegion("llkjhlkjhlkjh"); + + browseASDCPage.clickConfirmButton(); + + GeneralUIUtils.findAndWaitByText("Missing data", 5); + + Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID); + + viewEditPage.clickConfirmButton(); + assertSuccessfulVNFCreation(); + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java new file mode 100644 index 000000000..732d2998c --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java @@ -0,0 +1,596 @@ +package vid.automation.test.test; + + +//import com.sun.tools.internal.jxc.ap.Const; + +import com.google.common.primitives.Ints; +import org.json.JSONException; +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; +import org.openqa.selenium.support.ui.Select; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.*; +import vid.automation.test.Constants; +import vid.automation.test.infra.*; +import vid.automation.test.sections.ChangeManagementPage; +import vid.automation.test.services.SimulatorApi; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.IsNot.not; + +public class ChangeManagementTest extends VidBaseTestCase { + + @Test + public void testLeftPanelChangeManagementButton() { + Assert.assertTrue(Wait.byText(Constants.SideMenu.VNF_CHANGES)); + } + + @Test + public void testChangeManagementHeaderLine() { + ChangeManagementPage.openChangeManagementPage(); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pageHeadlineId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.headlineNewButtonId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.headlineSearchInputId)); + } + + @Test + public void testOpenNewChangeManagementModal() { + ChangeManagementPage.openNewChangeManagementModal(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalSubscriberInputId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalServiceTypeInputId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFNameInputId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalFromVNFVersionInputId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalWorkFlowInputId)); + Assert.assertTrue(Exists.byId(Constants.generalSubmitButtonId)); + Assert.assertTrue(Exists.byId(Constants.generalCancelButtonId)); + Click.byId(Constants.generalCancelButtonId); + Wait.modalToDisappear(); + } + + private void openAndFill1stScreen(String vnfName, String vnfTargetVersion, String workflow) { + String subscriberId = VNF_DATA_WITH_IN_PLACE.subscriberId; + String serviceType = VNF_DATA_WITH_IN_PLACE.serviceType; + String vnfType = VNF_DATA_WITH_IN_PLACE.vnfType; + String vnfSourceVersion = VNF_DATA_WITH_IN_PLACE.vnfSourceVersion; + + ChangeManagementPage.openNewChangeManagementModal(); + Wait.angularHttpRequestsLoaded(); + ChangeManagementPage.selectSubscriberById(subscriberId); + Wait.angularHttpRequestsLoaded(); + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalServiceTypeInputId, serviceType); + Wait.angularHttpRequestsLoaded(); + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFTypeInputId, vnfType); + Wait.angularHttpRequestsLoaded(); + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalFromVNFVersionInputId, vnfSourceVersion); + Wait.angularHttpRequestsLoaded(); + Click.byId(Constants.ChangeManagement.newModalVNFNameInputId); + Click.byText(vnfName); + Wait.angularHttpRequestsLoaded(); + if (vnfTargetVersion != null) { + SelectOption.byClassAndVisibleText(Constants.ChangeManagement.newModalTargetVersionInputsClass, vnfTargetVersion); + Wait.angularHttpRequestsLoaded(); + } + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalWorkFlowInputId, workflow); + + } + + public void scheduleChange2ndScreen(String duration, String fallback, String concurrencyLimit, String policy) { + + Wait.byText(Constants.ChangeManagement.schedulerModalNowLabel); + Click.byText(Constants.ChangeManagement.schedulerModalNowLabel); + +// Click.byId(Constants.ChangeManagement.schedulerModalStartDateInputId); //next month must be in the future +// Click.byClass(Constants.ChangeManagement.schedulerModalNextMonthButtonClass); +// Wait.byText(startDate); +// Click.byText(startDate); +// +// Click.byId(Constants.ChangeManagement.schedulerModalEndDateInputId); //next month must be in the future +// Click.byClass(Constants.ChangeManagement.schedulerModalNextMonthButtonClass); +// Wait.byText(endDate); +// Click.byText(endDate); + + SelectOption.byValue(Constants.ChangeManagement.schedulerModalHoursOption, Constants.ChangeManagement.schedulerModalTimeUnitSelectId); + + Input.text(duration, Constants.ChangeManagement.schedulerModalDurationInputTestId); + Input.text(fallback, Constants.ChangeManagement.schedulerModalFallbackInputTestId); + Input.text(concurrencyLimit, Constants.ChangeManagement.schedulerModalConcurrencyLimitInputTestId); + Wait.angularHttpRequestsLoaded(); + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.schedulerModalPolicySelectId, policy); + + Click.byText(Constants.ChangeManagement.schedulerModalScheduleButtonText); + + } + + static class DB_CONFIG { + static String url = String.format("jdbc:mariadb://%s:%d/vid_portal", + System.getProperty("DB_HOST", System.getProperty("VID_HOST", "127.0.0.1" )), + Integer.valueOf(System.getProperty("DB_PORT", "3306")) + ); + static String username = "euser"; + static String password = "euser"; + + static final int userId = 822; + static final int roleVFlowLogicId = 10822; + static final int roleMobilityId = 11822; + static final int vnfZrdm3amdns02test2Id = 11822; + static final int vnfHarrisonKrisId = 12822; + } + + static class VNF_DATA_WITH_IN_PLACE { + static String subscriberId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; + static String serviceType = "vFlowLogic"; + static String vnfType = "vMobileDNS"; + static String vnfSourceVersion = "1.0"; + static String vnfName = "zrdm3amdns02test2"; + static String vnfTargetVersion = "5.0"; + static String workflowName = "VNF In Place Software Update"; + } + + @AfterClass + protected void dropUser822() { + System.out.println("Connecting database..."); + + try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) { + System.out.println("Database connected!"); + Statement stmt = connection.createStatement(); + stmt.addBatch("DELETE FROM `fn_user_role` WHERE `USER_ID` = " + DB_CONFIG.userId); + stmt.addBatch("DELETE FROM `fn_role` WHERE `ROLE_ID` = " + DB_CONFIG.roleVFlowLogicId); + stmt.addBatch("DELETE FROM `fn_role` WHERE `ROLE_ID` = " + DB_CONFIG.roleMobilityId); + stmt.addBatch("DELETE FROM `fn_user` WHERE `USER_ID` = " + DB_CONFIG.userId); + int[] executeBatch = stmt.executeBatch(); + + stmt = connection.createStatement(); + stmt.addBatch("DELETE FROM `vid_vnf_workflow` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfZrdm3amdns02test2Id); + stmt.addBatch("DELETE FROM `vid_vnf` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfZrdm3amdns02test2Id); + executeBatch = stmt.executeBatch(); + + stmt = connection.createStatement(); + stmt.addBatch("DELETE FROM `vid_vnf_workflow` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfHarrisonKrisId); + stmt.addBatch("DELETE FROM `vid_vnf` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfHarrisonKrisId); + executeBatch = stmt.executeBatch(); + + } catch (SQLException e) { + throw new IllegalStateException("Cannot connect the database!", e); + } + } + + @BeforeClass + protected void registerToSimulator() { + SimulatorApi.registerExpectation( + "changeManagement/ecompportal_getSessionSlotCheckInterval.json" + , "changeManagement/get_aai_get_subscribers.json" + , "changeManagement/get_aai_sub_details.json" + , "changeManagement/get_scheduler_details_short.json" + , "changeManagement/get_sdc_catalog_services_2f80c596.json" + , "changeManagement/get_service-design-and-creation.json" + , "changeManagement/get_vnf_data_by_globalid_and_service_type.json" + , "changeManagement/service-design-and-creation.json" + ); + } + + @BeforeClass + protected void prepareUser822() { + + dropUser822(); + + System.out.println("Connecting database..."); + + try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) { + + System.out.println("Database connected!"); + + /////////////////////////////// + // Add user with specific roles + Statement stmt = connection.createStatement(); + stmt.addBatch("INSERT INTO `fn_user` (`USER_ID`, `ORG_USER_ID`, `LOGIN_ID`, `LOGIN_PWD`) VALUES (" + DB_CONFIG.userId + ", 'Porfirio Gerhardt', '"+ DB_CONFIG.userId +"', '"+ DB_CONFIG.userId +"')"); + stmt.addBatch("INSERT INTO `fn_role` (`ROLE_ID`, `ROLE_NAME`, `ACTIVE_YN`, `PRIORITY`) VALUES (" + DB_CONFIG.roleVFlowLogicId + ", 'PACKET CORE___vFlowLogic', 'Y', 5)"); + stmt.addBatch("INSERT INTO `fn_role` (`ROLE_ID`, `ROLE_NAME`, `ACTIVE_YN`, `PRIORITY`) VALUES (" + DB_CONFIG.roleMobilityId + ", 'PACKET CORE___Mobility', 'Y', 5)"); + stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", 16, NULL, 1)"); + stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", " + DB_CONFIG.roleVFlowLogicId + ", NULL, 1)"); + stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", " + DB_CONFIG.roleMobilityId + ", NULL, 1)"); + int[] executeBatch = stmt.executeBatch(); + assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0))); + + /////////////////////////////// + // Add 2 vnfs with some workflows + stmt = connection.createStatement(); + stmt.addBatch("INSERT INTO `vid_vnf` (`VNF_DB_ID`, `VNF_APP_UUID`, `VNF_APP_INVARIANT_UUID`) " + + "VALUES (" + DB_CONFIG.vnfZrdm3amdns02test2Id + ", '76e908e0-5201-44d2-a3e2-9e6128d05820', '72e465fe-71b1-4e7b-b5ed-9496118ff7a8')"); + stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfZrdm3amdns02test2Id + ", 2)"); + stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfZrdm3amdns02test2Id + ", 3)"); + executeBatch = stmt.executeBatch(); + assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0))); + + stmt = connection.createStatement(); + stmt.addBatch("INSERT INTO `vid_vnf` (`VNF_DB_ID`, `VNF_APP_UUID`, `VNF_APP_INVARIANT_UUID`) " + + "VALUES (" + DB_CONFIG.vnfHarrisonKrisId + ", '0903e1c0-8e03-4936-b5c2-260653b96413', '00beb8f9-6d39-452f-816d-c709b9cbb87d')"); + stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfHarrisonKrisId + ", 1)"); + stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfHarrisonKrisId + ", 2)"); + executeBatch = stmt.executeBatch(); + assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0))); + + } catch (SQLException e) { + throw new IllegalStateException("Cannot connect the database!", e); + } + + } + + @Override + protected UserCredentials getUserCredentials() { + return new UserCredentials("" + DB_CONFIG.userId, "" + DB_CONFIG.userId, "", "", ""); + } + + + @Test + public void testWorkflowVNFInPlaceSoftwareUpdateNotInWorkflowsListWhenNotExpected() { + List<String> workflows = getListOfWorkflowsFor("Harrison Kris"); + assertThat(workflows, not(hasItem(VNF_DATA_WITH_IN_PLACE.workflowName))); + } + + @Test + public void testWorkflowVNFInPlaceSoftwareUpdateInWorkflowsListWhenExpected() { + List<String> workflows = getListOfWorkflowsFor(VNF_DATA_WITH_IN_PLACE.vnfName); + assertThat(workflows, hasItem(VNF_DATA_WITH_IN_PLACE.workflowName)); + } + + public void openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate() { + openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, VNF_DATA_WITH_IN_PLACE.workflowName); + } + + @AfterMethod(alwaysRun = true) + public void closeForm() { + // Tries closing left-out popups, if any + // If none -- catch clause will swallow the exception + try { + Click.byId(Constants.generalCancelButtonId); + Click.byId(Constants.generalCancelButtonId); + Click.byId(Constants.generalCancelButtonId); + } catch (Exception | Error e) { + // ok, stop + } + Wait.modalToDisappear(); + } + + @Test + public void testWorkflowVNFInPlaceSoftwareUpdateShows3Fields() { + openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate(); + + List<String> idsWithoutMatchingElement = + Stream.of( + "operations-timeout", + "existing-software-version", + "new-software-version") + .filter(id -> Get.byId(id) == null) + .collect(Collectors.toList()); + assertThat("all three special VNFInPlace fields should appear", idsWithoutMatchingElement, is(empty())); + + assertThat(Get.byId(Constants.generalSubmitButtonId).isEnabled(), is(false)); + } + + @Test + public void testWorkflowVNFInPlaceSoftwareUpdate3ValidValues() { + openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate(); + + final String[][] options = { + {"true", "111", "222", "333"} + , {"true", "14710454", "Cz-Ou0EK5eH9.gAK1", "G9bUiFX3QM8xpxF8TlZ7b5T0"} + , {"true", "25316893", "fMx9V5kp.5.JGtYRhNGVTPoJ", "Jv5IieY0kTNjkfZ64bHXngR6"} + , {"true", "8", "3t3MhTRqkyjB85o5NC9OacAw", "B.bJ6f7KYI6WzDMR0fyNM9r4"} + , {"true", "3176", "ZlRS7tczf0cbMxQbBfyc6AP5", "1G1"} + , {"true", "78058488", "n", "WkH"} + , {"true", "501778", "1.d74LrJbBmcR.7bfvH.UZMX", "tFTAel7PS4RKEJeJ0b6mTeVT"} + , {"true", "76639623", "m2.EhbBxRE.rJj3j6qDtMxGR", "Rgkm-EPM1K0KAWm43Ex1wwjj"} + , {"true", "91244280", "zPDHRrXW65xR6GV.gVZND8C0", "mkrqFG26m7Vmv-28etQVyp04"} + , {"true", "8966", "7k2sRK2qSFRVCFpEvrlbmxAL", "IlvfmWTqzpF0Jo3elpZPHXx"} + , {"true", "01303495", "G26yl8B0NbLIKxu23h86QbZz", "vSou1seqCrcv9KoVbhlj4Wa4"} + , {"true", "787", "ce7joKCHYowpM2PtCb53Zs2v", ".qw1oY9HKjfAF2Yt05JNgib9"} + , {"true", "40116583", "-3bDEzEn.RbNnT2hWKQqf2HL", "QzlKlKZiIpc7sQ.EzO"} + , {"false", "", "222", "333"} + , {"false", "111", "", "333"} + , {"false", "111", "222", ""} + , {"false", "111a", "222", "333"} + , {"false", "aaa", "222", "333"} + , {"false", "111-", "222", "333"} +// , {"false", " 111", "222", "333"} +// , {"false", "111", "222 ", "333"} +// , {"false", "111", "222", " 333"} + , {"false", "111", "222", "3 33"} + , {"false", "111", "22,2", "333"} + , {"false", "111", "222~", "333"} + , {"false", "111", "222", "333&"} + , {"false", "$", "222", "333"} + , {"false", "111", "@", "333"} + , {"false", "111", "222", "^^^^^^"} + }; + + for (String[] option : options) { + fillVNFInPlace3Fields(option[1], option[2], option[3]); + assertThat("failed for set: " + Arrays.toString(option), + Get.byId(Constants.generalSubmitButtonId).isEnabled(), is(Boolean.parseBoolean(option[0]))); + } + + } + + private void fillVNFInPlace3Fields(String operationsTimeout, String existingSwVersion, String newSwVersion) { + Get.byId("operations-timeout").clear(); + Get.byId("existing-software-version").clear(); + Get.byId("new-software-version").clear(); + + Get.byId("operations-timeout").sendKeys(operationsTimeout); + Get.byId("existing-software-version").sendKeys(existingSwVersion); + Get.byId("new-software-version").sendKeys(newSwVersion); + } + + private List<String> getListOfWorkflowsFor(String vnfName) { + + openAndFill1stScreen(vnfName, null /*no matter*/, "Replace"); + + Select selectlist = new Select(Get.byId("workflow")); + List<String> workflows = selectlist.getOptions().stream().map(we -> we.getText()).collect(Collectors.toList()); + + Click.byId(Constants.generalCancelButtonId); + + return workflows; + } + + @DataProvider + public static Object[][] dataForUpdateWorkflowPartialWithInPlace() { + return new Object[][] { + { "1111", "22222", "33333" } + , {"8", "3t3MhTRqkyjB85o5NC9OacAw", "B.bJ6f7KYI6Wz-----DMR0.fyNM9r4"} + , {"78058488", "n", "WkH"} + }; + } + + @Test(dataProvider = "dataForUpdateWorkflowPartialWithInPlace") + public void testVidToMsoCallbackDataWithInPlaceSWUpdate(String operationsTimeout, String existingSwVersion, String newSwVersion) { + + openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate(); + fillVNFInPlace3Fields(operationsTimeout, existingSwVersion, newSwVersion); + + String payload = "\"payload\":\"{\\\"existing-software-version\\\":\\\""+ existingSwVersion +"\\\",\\\"new-software-version\\\":\\\""+ newSwVersion +"\\\",\\\"operation-timeout\\\":\\\""+ operationsTimeout +"\\\"}\","; + + assertThatVidToMsoCallbackDataIsOk(VNF_DATA_WITH_IN_PLACE.workflowName, payload); + } + + @Test + public void testVidToMsoCallbackData() { + String workflow = "Replace"; + + openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow); + + assertThatVidToMsoCallbackDataIsOk(workflow, ""); + } + + private void assertThatVidToMsoCallbackDataIsOk(String workflow, String payload) { + Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled()); + Click.byId(Constants.generalSubmitButtonId); + + String vidToMsoCallbackData = Input.getValueByTestId("vidToMsoCallbackData"); + + String modelInvariantId = "72e465fe-71b1-4e7b-b5ed-9496118ff7a8"; + String vnfInstanceId = "8e5e3ba1-3fe6-4d86-966e-f9f03dab4855"; + String expected = getExpectedVidToMsoCallbackData(modelInvariantId, vnfInstanceId, VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow, payload); + + try { + JSONAssert.assertEquals("built mso request is not ok", expected, vidToMsoCallbackData, JSONCompareMode.STRICT); + } catch (JSONException e) { + throw new RuntimeException(e); + } + + Click.byId(Constants.generalCancelButtonId); + } + + @Test(enabled = false) + public void testUpdateWorkflowNow() { + + String workflow = "Update"; + + String duration = "1"; + String fallback = "1"; + String concurrencyLimit = "1"; + String policy = "SNIRO_1710.Config_MS_PlacementOptimizationPolicy_dhv_v1.1.xml"; + + openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow); + Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled()); + Click.byId(Constants.generalSubmitButtonId); + + scheduleChange2ndScreen(duration, fallback, concurrencyLimit, policy); + } + + @Test + public void testNewChangeManagementCreation() { + ChangeManagementPage.openChangeManagementPage(); + + //TODO: After scheduler will be ready than we will examine if the creation working fine. + } + + @Test + public void testMainDashboardTable() { + ChangeManagementPage.openChangeManagementPage(); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardActiveTabId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTabId)); + + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardActiveTableId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardInProgressTheadId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardPendingTheadId)); + + Click.byId(Constants.ChangeManagement.dashboardFinishedTabId); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTableId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTheadId)); + Click.byId(Constants.ChangeManagement.dashboardActiveTabId); + } + + @Test + public void testMainDashboardTableContent() { + ChangeManagementPage.openChangeManagementPage(); + + //TODO: After scheduler will be ready than we will examine if the content is valid. + } + + @Test(enabled = false) + public void testOpenFailedStatusModal() { + ChangeManagementPage.openChangeManagementPage(); + + if(!Exists.byClass(Constants.ChangeManagement.failedIconClass)) { + //TODO: Create a job which will shown with status fail. + } + + Click.byClass(Constants.ChangeManagement.failedIconClass); + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalHeaderId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalContentId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalRetryButtonId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalRollbackButtonId)); + + Click.byClass(Constants.generalCloseModalButtonClass); + Wait.modalToDisappear(); + } + + @Test(enabled = false) + public void testOpenInProgressStatusModal() { + ChangeManagementPage.openChangeManagementPage(); + + if(!Exists.byClass(Constants.ChangeManagement.processIconClass)) { + //TODO: Create a job which will shown with status in-progress. + } + + Click.byClass(Constants.ChangeManagement.processIconClass); + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalHeaderId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalContentId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalStopButtonId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalRollbackButtonId)); + + Click.byClass(Constants.generalCloseModalButtonClass); + Wait.modalToDisappear(); + } + + @Test(enabled = false) + public void testOpenAlertStatusModal() { + ChangeManagementPage.openChangeManagementPage(); + + if(!Exists.byClass(Constants.ChangeManagement.alertIconClass)) { + //TODO: Create a job which will shown with status alert. + } + + Click.byClass(Constants.ChangeManagement.alertIconClass); + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalHeaderId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalContentId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalContinueButtonId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalRollbackButtonId)); + + Click.byClass(Constants.generalCloseModalButtonClass); + Wait.modalToDisappear(); + } + + @Test(enabled = false) + public void testOpenPendingStatusModal() { + ChangeManagementPage.openChangeManagementPage(); + + if(!Exists.byClass(Constants.ChangeManagement.pendingIconClass)) { + //TODO: Create a job which will shown with status pending. + } + + Click.byClass(Constants.ChangeManagement.pendingIconClass); + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalHeaderId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalContentId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalRescheduleButtonId)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalRollbackButtonId)); + + Click.byClass(Constants.generalCloseModalButtonClass); + Wait.modalToDisappear(); + } + + @Test(enabled = false) + public void testSuccessCancelPendingWorkflow() { + ChangeManagementPage.openChangeManagementPage(); + Wait.angularHttpRequestsLoaded(); + + Click.byClass(Constants.ChangeManagement.cancelPendingButtonClass); //cancel pending workflow modal + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalHeaderId)); + Assert.assertTrue(Exists.byClass(Constants.ChangeManagement.pendingModalCancelWorkflowButtonClass)); + Click.byClass(Constants.ChangeManagement.pendingModalCancelWorkflowButtonClass); + Wait.angularHttpRequestsLoaded(); + + Wait.modalToBeDisplayed(); //success alert modal should appear + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalHeaderId)); + Assert.assertTrue(Exists.byClassAndText(Constants.generalModalTitleClass, "Success")); + Click.byClass(Constants.generalCloseModalButtonClass); + Wait.modalToDisappear(); + //TODO check the workflow deleted from table/changed to deleted action + } + + private String getExpectedVidToMsoCallbackData(String modelInvariantId, String vnfInstanceId, String vnfName, String vnfTargetVersion, String workflow, String payload) { + return "" + + "{" + + " \"requestType\": \"" + workflow + "\"," + + " \"requestDetails\": [" + + " {" + + " \"vnfName\": \"" + vnfName + "\"," + + " \"vnfInstanceId\": \"" + vnfInstanceId + "\"," + + " \"modelInfo\": {" + + " \"modelType\": \"vnf\"," + + " \"modelInvariantId\": \"" + modelInvariantId + "\"," + + " \"modelVersionId\": \"76e908e0-5201-44d2-a3e2-9e6128d05820\"," + + " \"modelName\": \"" + vnfName + "\"," + + " \"modelVersion\": \"" + vnfTargetVersion + "\"," + + " \"modelCustomizationId\": \"c00e8fc8-af39-4da8-8c78-a7efc2fe5994\"" + + " }," + + " \"cloudConfiguration\": {" + + " \"lcpCloudRegionId\": \"mdt1\"," + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + + " }," + + " \"requestInfo\": {" + + " \"source\": \"VID\"," + + " \"suppressRollback\": false," + + " \"requestorId\": \"az2016\"" + + " }," + + " \"relatedInstanceList\": [" + + " {" + + " \"relatedInstance\": {" + + " \"instanceId\": \"97315a05-e6f3-4c47-ae7e-d850c327aa08\"," + + " \"modelInfo\": {" + + " \"modelType\": \"service\"," + + " \"modelInvariantId\": \"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," + + " \"modelVersionId\": \"76e908e0-5201-44d2-a3e2-9e6128d05820\"," + + " \"modelName\": \"action-data\"," + + " \"modelVersion\": \"1.0\"" + + " }" + + " }" + + " }" + + " ]," + + " \"requestParameters\": {" + + payload + + " \"usePreload\": true" + + " }" + + " }" + + " ]" + + "}"; + } + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java new file mode 100644 index 000000000..ff7dc3441 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java @@ -0,0 +1,35 @@ +package vid.automation.test.test; + +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; +import vid.automation.test.Constants; +import vid.automation.test.model.Service; + +public class CreateInstanceDialogBaseTest extends VidBaseTestCase { + void assertServiceMetadata(String expectedMetadata, String actualMetadata) { + WebElement serviceNameElem = GeneralUIUtils.getWebElementByTestID(actualMetadata); + String actualServiceName = serviceNameElem.getText(); + Assert.assertEquals(expectedMetadata, actualServiceName); + } + + void validateServiceCreationDialog(Service expectedService) { + assertThatServiceCreationDialogIsVisible(); + assertServiceMetadata(expectedService.name, Constants.SERVICE_NAME); + assertServiceMetadata(expectedService.uuid, Constants.SERVICE_UUID); + assertServiceMetadata(expectedService.invariantUuid, Constants.SERVICE_INVARIANT_UUID); + assertServiceMetadata(expectedService.category, Constants.SERVICE_CATEGORY); + assertServiceMetadata(expectedService.version, Constants.SERVICE_VERSION); + assertServiceMetadata(expectedService.description, Constants.SERVICE_DESCRIPTION); + } + + void assertThatServiceCreationDialogIsVisible() { + boolean byText = GeneralUIUtils.findAndWaitByText(Constants.BrowseASDC.CREATE_SERVICE_INSTANCE, 15); + Assert.assertTrue(byText); + } + + void assertSuccessfulServiceInstanceCreation() { + boolean byText = GeneralUIUtils.findAndWaitByText(Constants.BrowseASDC.SERVICE_INSTANCE_CREATED_SUCCESSFULLY_TEXT, 100); + Assert.assertTrue(Constants.BrowseASDC.SERVICE_INSTANCE_CREATION_FAILED_MESSAGE, byText); + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java new file mode 100644 index 000000000..46238acac --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/CreateNewInstanceTest.java @@ -0,0 +1,84 @@ +package vid.automation.test.test; + +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; +import org.testng.Assert; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.model.Service; +import vid.automation.test.model.User; +import vid.automation.test.sections.CreateNewInstancePage; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.services.ServicesService; +import vid.automation.test.services.UsersService; + +import java.io.IOException; + +public class CreateNewInstanceTest extends CreateInstanceDialogBaseTest { + private UsersService usersService = new UsersService(); + private ServicesService servicesService = new ServicesService(); + + public CreateNewInstanceTest() throws IOException { + } + + @Test + private void testCreateNewServiceInstance() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + + SideMenu.navigateToCreateNewServicePage(); + + CreateNewInstancePage createNewInstancePage = new CreateNewInstancePage(); + + String subscriberName = "USP VOICE"; + assertDropdownPermittedItemsByValue(user.subscribers, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + createNewInstancePage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89"); + createNewInstancePage.clickSubmitButton(); + assertSuccessfulSelection(Constants.CreateNewInstance.SELECTED_SUBSCRIBER_NAME_TEST_ID, subscriberName); + + String serviceType = "VIRTUAL USP"; + assertDropdownPermittedItemsByName(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS); + createNewInstancePage.selectServiceTypeByName(serviceType); + createNewInstancePage.clickSubmitButton(); + assertSuccessfulSelection(Constants.CreateNewInstance.SELECTED_SERVICE_TYPE_NAME_TEST_ID, serviceType); + + Service service = servicesService.getService( "c079d859-4d81-4add-a9c3-94551f96e2b0"); + + createNewInstancePage.clickDeployServiceButtonByServiceUUID(service.uuid); + + validateServiceCreationDialog(service, subscriberName, serviceType); + + String instanceName = createNewInstancePage.generateInstanceName(); + createNewInstancePage.setInstanceName(instanceName); + createNewInstancePage.selectSuppressRollback("false"); + createNewInstancePage.clickConfirmButton(); + + assertSuccessfulServiceInstanceCreation(); + + createNewInstancePage.clickCloseButton(); + + GeneralUIUtils.ultimateWait(); + + goToExistingInstanceByName(instanceName); + + addVNF("VID-PCRF-05-15-17 0", "AAIAIC25", "092eb9e8e4b7412e8787dd091bc58e86", + "false", "some legacy region", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", user.tenants); + addVolumeGroup("VidPcrf051517..pcrf_nimbus_pcm..module-4", "AAIAIC25", + "092eb9e8e4b7412e8787dd091bc58e86", "false", "some legacy region", user.tenants); + addVFModule("VidPcrf051517..pcrf_nimbus_psm..module-1", "AAIAIC25", + "092eb9e8e4b7412e8787dd091bc58e86", "false", "some legacy region", user.tenants); + } + + private void assertSuccessfulSelection(String elementTestId, String expectedSelection) { + GeneralUIUtils.ultimateWait(); + WebElement selectedElement = GeneralUIUtils.getWebElementByTestID(elementTestId, 30); + Assert.assertEquals(selectedElement.getText(), expectedSelection); + } + + private void validateServiceCreationDialog(Service expectedService, String subscriberName, String serviceType) { + assertServiceMetadata(subscriberName, Constants.SUBSCRIBER_NAME); + assertServiceMetadata(serviceType, Constants.SERVICE_TYPE); + validateServiceCreationDialog(expectedService); + + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java b/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java new file mode 100644 index 000000000..1c8101953 --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/EnvironmentsTest.java @@ -0,0 +1,484 @@ +package vid.automation.test.test; + +import com.google.common.collect.ImmutableMap; +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; +import org.springframework.http.HttpStatus; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.*; +import vid.automation.test.model.Environment; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.services.SimulatorApi.RegistrationStrategy; + +import vid.automation.test.sections.TestEnvironmentPage; +import vid.automation.test.sections.VidBasePage; +import vid.automation.test.services.SimulatorApi; +import vid.automation.test.utils.ReadFile; + +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static vid.automation.test.Constants.TestEnvironments.REFRESH_BUTTON; + + +/* + +1. Activate + a. Happy scenario + i. Polling screen is displayed + ii. Environment status become active in environments table + iii. Button become deactivation + iv. Attach file button is shown + b. Non JSON file content – error is shown + c. Invalid manifest format in the JSON – error is shown + d. MSO Error – 500/400 – error is shown +2. Attach manifest + a. Happy scenario + i. Polling screen is displayed + b. MSO Error – 500/400 – error is shown + +3. Deactivate + a. Happy scenario + i. Polling screen is displayed + ii. Environment status become inactive in environments table + iii. Button become activation + iv. Attach file button is not shown + b. MSO Error – 500/400 – error is shown + + */ + +public class EnvironmentsTest extends VidBaseTestCase { + + public static final String GET_EMPTY_OPERATIONAL_ENVIRONMENT_JSON = "get_empty_operational_environment.json"; + public static final String GET_OPERATIONAL_ENVIRONMENT_JSON = "get_operational_environment.json"; + public static final String GET_FULL_OPERATIONAL_ENVIRONMENT_JSON = "get_full_operational_environment.json"; + public static final String GET_ERROR_OPERATIONAL_ENVIRONMENT_JSON = "get_error_operational_environment.json"; + public static final String POST_OPERATIONAL_ENVIRONMENT_JSON = "post_operational_environment.json"; + static final String ENVIRONMENTS_CONF = "environments"; + static final String NEW_ENVIRONMENT_CONF = "newEnvironment"; + + public static final String ENV_ID_FOR_ACTIVATION = "f07ca256-96dd-40ad-b4d2-7a77e2a974eb"; + public static final String ENV_ID_FOR_DEACTIVATION = "f07ca256-96dd-40ad-b4d2-7a77e2a974ec"; + private VidBasePage vidBasePage = new VidBasePage(); + + public static enum FailureType { + ACTIVATION_FAILURE, + DEACTIVATION_FAILURE, + GET_STATUS_FAILURE + } + + @Test + public void testLeftPanelTestEnvironmentButton() { + List<WebElement> leftPanelButtons = Get.byClass(Constants.SideMenu.buttonClass); + Assert.assertTrue(Wait.byText(Constants.SideMenu.TEST_ENVIRONMENTS)); + } + + @Test + public void testEnvironmentHeaderLine() { + SideMenu.navigateToTestEnvironmentsPage(); + Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.PAGE_HEADLINE)); + Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON)); + Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.HEADLINE_SEARCH_INPUT)); + } + + @Test + public void testTable() throws Exception { + SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON); + vidBasePage.refreshPage(); + Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class); + String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE; + SideMenu.navigateToTestEnvironmentsPage(); + boolean emptyTableMessage = Exists.byTestId(Constants.TestEnvironments.NO_DATA_MESSAGE); + boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.ERROR_MESSAGE); + Assert.assertFalse(emptyTableMessage || errorMessage); + List<String> headers = Get.tableHeaderValuesByTestId(tableId); + Assert.assertEquals(file.get(Constants.TestEnvironments.HEADERS_LIST), headers); + List<List<String>> body = Get.tableBodyValuesByTestId(tableId); + Assert.assertEquals(file.get(Constants.TestEnvironments.BASIC_LIST), body); + } + + @Test + public void testSortTable() throws Exception { + SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, RegistrationStrategy.CLEAR_THEN_SET); + vidBasePage.refreshPage(); + Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class); + String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE; + SideMenu.navigateToTestEnvironmentsPage(); + Click.byClass(Constants.TestEnvironments.TABLE_HEADER_ASC); + GeneralUIUtils.ultimateWait(); + List<List<String>> body = Get.tableBodyValuesByTestId(tableId); + Assert.assertEquals(file.get(Constants.TestEnvironments.SORTED_LIST), body); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testFilterTable() throws Exception { + SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, RegistrationStrategy.CLEAR_THEN_SET); + vidBasePage.refreshPage(); + Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class); + String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE; + SideMenu.navigateToTestEnvironmentsPage(); + Input.text(Constants.TestEnvironments.TEXT_TO_FILTER, Constants.TestEnvironments.SEARCH_INPUT); + GeneralUIUtils.ultimateWait(); + List<List<String>> body = Get.tableBodyValuesByTestId(tableId); + Assert.assertEquals(file.get(Constants.TestEnvironments.FILTERED_LIST), body); + GeneralUIUtils.ultimateWait(); + } + + + @Test + public void testEmptyTableMessage() throws Exception { + SimulatorApi.registerExpectation(GET_EMPTY_OPERATIONAL_ENVIRONMENT_JSON); + vidBasePage.refreshPage(); + SideMenu.navigateToTestEnvironmentsPage(); + boolean emptyTableMessage = Exists.byTestId(Constants.TestEnvironments.NO_DATA_MESSAGE); + Assert.assertTrue(emptyTableMessage); + Assert.assertFalse(Exists.byTestId(Constants.TestEnvironments.TRY_AGAIN_BUTTON)); + Assert.assertFalse(Exists.byTestId(Constants.TestEnvironments.ENVIRONMENTS_TABLE)); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testErrorMessage() throws Exception { + SimulatorApi.registerExpectation(GET_ERROR_OPERATIONAL_ENVIRONMENT_JSON); + vidBasePage.refreshPage(); + SideMenu.navigateToTestEnvironmentsPage(); + boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.ERROR_MESSAGE); + Assert.assertTrue(errorMessage); + Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.TRY_AGAIN_BUTTON)); + Assert.assertFalse(Exists.byTestId(Constants.TestEnvironments.ENVIRONMENTS_TABLE)); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testNewEnvironmentPopup() throws Exception { + SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, RegistrationStrategy.CLEAR_THEN_SET); + SimulatorApi.registerExpectation(POST_OPERATIONAL_ENVIRONMENT_JSON); + SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json", + ImmutableMap.of("status_message", Constants.TestEnvironments.environmentCreatedSuccesfullyMessage, + "REQUEST-TYPE","Create")); + vidBasePage.refreshPage(); + Environment environment = ReadFile.getJsonFile(NEW_ENVIRONMENT_CONF, Environment.class); + SideMenu.navigateToTestEnvironmentsPage(); + Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON); + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.NEW_ENVIRONMENT_FORM)); + + boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.POPUP_ERROR_MESSAGE); + Assert.assertFalse(errorMessage); + + Assert.assertFalse(Get.byTestId(Constants.TestEnvironments.SUBMIT_BUTTON).isEnabled()); + Input.text(environment.operationalEnvironmentName, Constants.TestEnvironments.INSTANCE_NAME_INPUT); + + GeneralUIUtils.ultimateWait(); + SelectOption.byTestIdAndVisibleText(environment.EcompEnvironmentId, Constants.TestEnvironments.ECOMP_ID_DROP_DOWN); + + String ecompNameText = Input.getValueByTestId(Constants.TestEnvironments.ECOMP_NAME_INPUT); + Assert.assertEquals(environment.EcompEnvironmentName, ecompNameText); + + String tenantContextText = Input.getValueByTestId(Constants.TestEnvironments.TENANT_CONTEXT_INPUT); + Assert.assertEquals(environment.tenantContext, tenantContextText); + + String environmentTypeDefault = Get.selectedOptionText(Constants.TestEnvironments.ENVIRONMENT_TYPE_DROP_DOWN); + Assert.assertEquals(environment.operationalEnvironmentType, environmentTypeDefault); + + SelectOption.byTestIdAndVisibleText(environment.workloadContext, Constants.TestEnvironments.WORKLOAD_CONTEXT_DROP_DOWN); + + WebElement submitButton = Get.byTestId(Constants.TestEnvironments.SUBMIT_BUTTON); + Assert.assertTrue(submitButton.isEnabled()); + Click.byTestId(Constants.TestEnvironments.SUBMIT_BUTTON); + boolean waitForTextResult = Wait.waitByClassAndText("status", Constants.TestEnvironments.environmentCreatedSuccesfullyMessage, 60); + assertTrue(Constants.TestEnvironments.environmentCreatedSuccesfullyMessage + " message didn't appear on time", waitForTextResult); + + vidBasePage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + + // refresh table + Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class); + String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE; + SimulatorApi.registerExpectation(GET_FULL_OPERATIONAL_ENVIRONMENT_JSON, + ImmutableMap.of("new_name", environment.operationalEnvironmentName, "new_tenant", environment.tenantContext, "new_ecomp_id", environment.EcompEnvironmentId, "new_ecomp_name", environment.EcompEnvironmentName, "new_workload_context", environment.workloadContext), RegistrationStrategy.CLEAR_THEN_SET); + Click.byTestId(REFRESH_BUTTON); + Wait.angularHttpRequestsLoaded(); + List<List<String>> body = Get.tableBodyValuesByTestId(tableId); + Assert.assertEquals(file.get(Constants.TestEnvironments.FULL_LIST), body); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testAaiErrorNewEnvironmentPopup() throws Exception { + SimulatorApi.registerExpectation(GET_ERROR_OPERATIONAL_ENVIRONMENT_JSON); + vidBasePage.refreshPage(); + SideMenu.navigateToTestEnvironmentsPage(); + Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON); + Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.NEW_ENVIRONMENT_FORM)); + GeneralUIUtils.ultimateWait(); + boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.POPUP_ERROR_MESSAGE); + Assert.assertTrue(errorMessage); + Click.byTestId(Constants.TestEnvironments.CANCEL_BUTTON); + Wait.modalToDisappear(); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testCancelNewPopup() { + SideMenu.navigateToTestEnvironmentsPage(); + Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON); + Assert.assertTrue(Exists.modal()); + Click.byTestId(Constants.TestEnvironments.CANCEL_BUTTON); + Wait.modalToDisappear(); + Assert.assertFalse(Exists.modal()); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testCloseNewPopup() { + SideMenu.navigateToTestEnvironmentsPage(); + Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON); + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + GeneralUIUtils.ultimateWait(); + Click.byClass(Constants.TestEnvironments.MODAL_CLOSE_BUTTON_CLASS); + Wait.modalToDisappear(); + GeneralUIUtils.ultimateWait(); + Assert.assertFalse(Exists.modal()); + GeneralUIUtils.ultimateWait(); + } + + @Test + public void testApplicationEnvironmentActivation() throws Exception { + String envId = ENV_ID_FOR_ACTIVATION; + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json"); + SimulatorApi.registerExpectation("environment/activate/post_activate_operational_environment.json", + ImmutableMap.of("ENV-UUID", envId)); + SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json", + ImmutableMap.of("status_message", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage, + "REQUEST-TYPE","Activate")); + clickOnActivationButtonAndUploadFile(envId, "manifest.json"); + + Click.byId(Constants.generalSubmitButtonId); + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", + ImmutableMap.of("Deactivate", "Activate")); + + boolean waitForTextResult = Wait.waitByClassAndText("status", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage, 60); + assertTrue(Constants.TestEnvironments.environmentActivatedSuccesfullyMessage + " message didn't appear on time", waitForTextResult); + + vidBasePage.clickCloseButton(); + + GeneralUIUtils.ultimateWait(); + + WebElement deactivationButton = TestEnvironmentPage.getTestEnvironmentDeactivationButton(envId); + assertTrue("Failed to find Deactivate button for test env with id: "+envId, deactivationButton.isDisplayed()); + + WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId); + assertEquals("Active", status.getText()); + + WebElement attachButton = TestEnvironmentPage.getTestEnvironmentAttachButton(envId); + assertTrue("Failed to find Attach button for test env with id: "+envId, attachButton.isDisplayed()); + + //make sure page is clickable + SideMenu.navigateToTestEnvironmentsPage(); + } + + @Test + public void testApplicationEnvironmentDeactivation() throws Exception { + String envId = ENV_ID_FOR_DEACTIVATION; + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json"); + SimulatorApi.registerExpectation("environment/deactivate/post_deactivate_operational_environment.json", + ImmutableMap.of("ENV-UUID", envId)); + SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json", + ImmutableMap.of("status_message", Constants.TestEnvironments.environmentDeactivatedSuccesfullyMessage, + "REQUEST-TYPE","Deactivate")); + deactivateEnv(envId); + + SimulatorApi.registerExpectation("environment/deactivate/get_operational_environments_aai1.json"); + GeneralUIUtils.findAndWaitByText(Constants.TestEnvironments.environmentDeactivatedSuccesfullyMessage, 60); + + vidBasePage.clickCloseButton(); + + GeneralUIUtils.ultimateWait(); + + WebElement activationButton = TestEnvironmentPage.getTestEnvironmentActivationButton(envId); + assertTrue("Failed to find Activate button for test env with id: "+envId, activationButton.isDisplayed()); + + WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId); + assertEquals("Inactive", status.getText()); + + WebElement attachButton = TestEnvironmentPage.getTestEnvironmentAttachButton(envId); + assertFalse("attach button shouldn't be displayed for test env with id: "+envId, attachButton.isDisplayed()); + + SideMenu.navigateToTestEnvironmentsPage(); + } + + private void deactivateEnv(String envId) { + vidBasePage.refreshPage(); + SideMenu.navigateToTestEnvironmentsPage(); + WebElement deactivationButton = TestEnvironmentPage.getTestEnvironmentDeactivationButton(envId); + assertTrue("Failed to find Deactivation button for test env with id: "+envId, deactivationButton.isDisplayed()); + deactivationButton.click(); + } + + @DataProvider + public static Object[][] badManifestProvider() { + return new Object[][]{ + {"bad_manifest_structure.json","Manifest structure is wrong"}, + {"manifest_with_wrong_recovery_action.json", "Wrong value for RecoveryAction in manifest. Allowed options are: abort,retry,skip. Wrong value is: leave"} + }; + }; + + @Test + public void testApplicationEnvironmentActivationBadManifestStructure() throws Exception { + testApplicationEnvironmentActivationBadManifestStructure("bad_manifest_structure.json", "Manifest structure is wrong"); + testApplicationEnvironmentActivationBadManifestStructure("manifest_with_wrong_recovery_action.json", + "Wrong value for RecoveryAction in manifest. Allowed options are: abort, retry, skip. Wrong value is: leave"); + } + + //@Test(dataProvider = "badManifestProvider") TODO : use data provider here (for some reason not work with ui-ci framework) + public void testApplicationEnvironmentActivationBadManifestStructure(String badManifestFileName, String exceptedErrorMsg) throws Exception { + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json"); + clickOnActivationButtonAndUploadFile(ENV_ID_FOR_ACTIVATION, badManifestFileName); + WebElement attachButton = Get.byId("submit"); + assertEquals("Wrong text for submit button in activate modal", "Attach", attachButton.getText()); + attachButton.click(); + boolean waitForTextResult = Wait.waitByClassAndText("error", exceptedErrorMsg, 30); + assertTrue(exceptedErrorMsg+ " message didn't appear on time", waitForTextResult); + vidBasePage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + SideMenu.navigateToTestEnvironmentsPage(); + } + + @Test + public void testApplicationEnvironmentActivationNonJsonManifest() throws Exception { + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json"); + String fileName = "non_valid_json.json"; + clickOnActivationButtonAndUploadFile(ENV_ID_FOR_ACTIVATION, fileName); + WebElement errorLabel = Get.byId("errorLabel"); + assertEquals("wrong error message for non valid json file", "file: " + fileName + " is not a valid JSON", errorLabel.getText()); + vidBasePage.clickCancelButton(); + GeneralUIUtils.ultimateWait(); + } + + private void clickOnActivationButtonAndUploadFile(String envId, String inputFileName) { + vidBasePage.refreshPage(); + SideMenu.navigateToTestEnvironmentsPage(); + WebElement activationButton = TestEnvironmentPage.getTestEnvironmentActivationButton(envId); + assertTrue("Failed to find Activate button for test env with id: "+envId, activationButton.isDisplayed()); + activationButton.click(); + Input.file("applicationEnvironment/"+inputFileName, "testEnvManifestFileInput"); + WebElement manifestFileName = Get.byId("manifestFileName"); + assertEquals("Manifest file name is wrong in test environment activation modal", inputFileName, manifestFileName.getText()); + } + + @Test + public void testAttachManifestFileHappyFlow() throws Exception { + String envId = ENV_ID_FOR_ACTIVATION; + SimulatorApi.registerExpectation("environment/activate/post_activate_operational_environment.json", + ImmutableMap.of("ENV-UUID", envId)); + SimulatorApi.registerExpectation("environment/attachManifest/get_attachable_operational_environment.json"); + SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json", + ImmutableMap.of("status_message", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage)); + vidBasePage.refreshPage(); + SideMenu.navigateToTestEnvironmentsPage(); + WebElement attachButton = TestEnvironmentPage.getTestEnvironmentAttachButton(ENV_ID_FOR_ACTIVATION); + attachButton.click(); + + Input.file("applicationEnvironment/manifest.json", "testEnvManifestFileInput"); + + Click.byId(Constants.generalSubmitButtonId); + + boolean waitForTextResult = Wait.waitByClassAndText("status", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage, 60); + assertTrue(Constants.TestEnvironments.environmentActivatedSuccesfullyMessage + " message didn't appear on time", waitForTextResult); + + vidBasePage.clickCloseButton(); + } + @Test + public void testApplicationEnvironmentActivationErrorResponseFromMso() throws Exception { + String payload = "ERROR_PAYLOAD"; + testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.ACTIVATION_FAILURE); + testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.ACTIVATION_FAILURE); + testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.GET_STATUS_FAILURE); + testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.GET_STATUS_FAILURE); + } + + + public void testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus errorStatus, String payload, FailureType failureType) throws Exception { + + String envId = ENV_ID_FOR_ACTIVATION; + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json"); + switch (failureType) { + case ACTIVATION_FAILURE: + SimulatorApi.registerExpectation("environment/activate/mso_error_response_for_post_operational_environment.json", + ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId)); + break; + case GET_STATUS_FAILURE: + SimulatorApi.registerExpectation("environment/activate/post_activate_operational_environment.json", + ImmutableMap.of("ENV-UUID", envId)); + break; + } + + SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status_bad_response.json", + ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId)); + + clickOnActivationButtonAndUploadFile(envId, "manifest.json"); + Click.byId(Constants.generalSubmitButtonId); + Wait.waitByClassAndText("error", "System failure", 60); + Wait.waitByClassAndText("log", errorStatus.getReasonPhrase(), 60); + Wait.waitByClassAndText("log", payload, 60); + vidBasePage.clickCloseButton(); + + GeneralUIUtils.waitForAngular(); + + WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId); + assertEquals(Constants.INACTIVE, status.getText()); + //make sure page is clickable + SideMenu.navigateToTestEnvironmentsPage(); + } + + @Test + public void testApplicationEnvironmentDeactivationErrorResponseFromMso() throws Exception { + String payload = "<html><head><title>Error</title></head><body>REASON</body></html>"; + testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.DEACTIVATION_FAILURE); + testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.DEACTIVATION_FAILURE); + testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.GET_STATUS_FAILURE); + testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.GET_STATUS_FAILURE); + } + + public void testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus errorStatus, String payload, FailureType failureType) throws Exception { + String envId = ENV_ID_FOR_DEACTIVATION; + payload = payload.replace("REASON", errorStatus.getReasonPhrase()); + SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json"); + switch (failureType) { + case DEACTIVATION_FAILURE: + SimulatorApi.registerExpectation("environment/deactivate/error_deactivate_operational_environment.json", + ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId,"ERROR_PAYLOAD", payload)); + break; + case GET_STATUS_FAILURE: + SimulatorApi.registerExpectation("environment/deactivate/post_deactivate_operational_environment.json", + ImmutableMap.of("ENV-UUID", envId)); + break; + } + SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status_bad_response.json", + ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId, "ERROR_PAYLOAD", payload)); + deactivateEnv(envId); + + Wait.waitByClassAndText("error", "System failure", 60); + Wait.waitByClassAndText("log", errorStatus.getReasonPhrase(), 60); + Wait.waitByClassAndText("log", payload, 60); + vidBasePage.clickCloseButton(); + + GeneralUIUtils.ultimateWait(); + + WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId); + assertEquals(Constants.ACTIVE, status.getText()); + //make sure page is clickable + SideMenu.navigateToTestEnvironmentsPage(); + } + + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java b/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java new file mode 100644 index 000000000..5607496dc --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/ReadOnlyTest.java @@ -0,0 +1,64 @@ +package vid.automation.test.test; + +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; + +import org.openqa.selenium.WebElement; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.model.User; +import vid.automation.test.sections.SearchExistingPage; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.services.UsersService; + +import java.io.IOException; +import java.util.ArrayList; + +/** + * Created by Oren on 7/16/17. + */ +public class ReadOnlyTest extends VidBaseTestCase { + UsersService usersService = new UsersService(); + + public ReadOnlyTest() throws IOException { + } + + @Override + protected UserCredentials getUserCredentials() { + User user = usersService.getUser(Constants.Users.READONLY); + return new UserCredentials(user.credentials.userId, user.credentials.password, "", "", ""); + } + + @Test + public void testBrowsASDCReadOnly() { + SideMenu.navigateToBrowseASDCPage(); + Assert.assertTrue(isDeployBtnDisabled()); + } + + private boolean isDeployBtnDisabled(){ + WebElement deployBtn = GeneralUIUtils.getWebElementBy(By.className(Constants.BrowseASDC.DEPOLY_SERVICE_CLASS)); + return !deployBtn.isEnabled(); + } + + @Test + public void testSearchExistingReadOnly() { + String UUID = "1dddde21-daad-4433-894e-bd715e98d587"; + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + searchExistingPage.searchForInstanceByUuid(UUID); + searchExistingPage.clickSubmitButton(); + assertViewEditButtonState(Constants.VIEW_BUTTON_TEXT, UUID); + searchExistingPage.clickEditViewByInstanceId(UUID); + searchExistingPage.checkForEditButtons(); + } + + @Test + private void testCreateNewInstanceReadOnly() { + SideMenu.navigateToCreateNewServicePage(); + assertDropdownPermittedItemsByValue(new ArrayList<String>(), Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS); + } + + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java new file mode 100644 index 000000000..f3261a21a --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java @@ -0,0 +1,83 @@ +package vid.automation.test.test; + +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.model.User; +import vid.automation.test.sections.SearchExistingPage; +import vid.automation.test.sections.SideMenu; +import vid.automation.test.services.UsersService; + +import java.io.IOException; + +public class SearchExistingInstanceTest extends VidBaseTestCase { + + private UsersService usersService = new UsersService(); + + public SearchExistingInstanceTest() throws IOException { + } + + @Test + private void testSearchExistingInstanceById() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + SideMenu.navigateToSearchExistingPage(); + goToExistingInstanceById("3f93c7cb-2fd0-4557-9514-e189b7b04f9d"); + + //a flow that updates an existing instance is tested in testCreateNewServiceInstance. + } + + @Test + private void testSearchExistingInstanceByOwningEntitySingleValue() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + Click.byId(Constants.EditExistingInstance.SELECT_OWNING_ENTITY_ID); + Thread.sleep(1000); + Click.byText("owning-entity-SDN-RXU4"); + searchExistingPage.clickSubmitButton(); + searchExistingPage.clickEditViewByInstanceId("SDN-RXU4-B-servInstance-E1802"); + } + + @Test + private void testSearchExistingInstanceByOwningEntityMultiValue() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + Click.byId(Constants.EditExistingInstance.SELECT_OWNING_ENTITY_ID); + Thread.sleep(1000); + Click.byText("owning-entity-SDN-RXU4"); + Click.byText("owning-entity-SDN-LT1"); + searchExistingPage.clickSubmitButton(); + searchExistingPage.clickEditViewByInstanceId("SDN-LT1-B-servInstance-E1802"); + } + + @Test + private void testSearchExistingInstanceByProjectSingleValue() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + Click.byId(Constants.EditExistingInstance.SELECT_PROJECT_ID); + Thread.sleep(1000); + Click.byText("x1"); + searchExistingPage.clickSubmitButton(); + searchExistingPage.clickEditViewByInstanceId("SDN-LT1-B-servInstance-E1802"); + } + + @Test + private void testSearchExistingInstanceByProjectMultiValue() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + Click.byId(Constants.EditExistingInstance.SELECT_PROJECT_ID); + Thread.sleep(1000); + Click.byText("x1"); + Click.byText("x3"); + searchExistingPage.clickSubmitButton(); + searchExistingPage.clickEditViewByInstanceId("SDN-LT1-B-servInstance-E1802"); + } +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java new file mode 100644 index 000000000..d4e09be2d --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java @@ -0,0 +1,235 @@ +package vid.automation.test.test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.datatypes.Configuration; +import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.SelectOption; +import vid.automation.test.model.*; +import vid.automation.test.sections.*; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static org.testng.AssertJUnit.fail; + + +public class VidBaseTestCase extends SetupCDTest { + + static String currentUserId = null; + + @Override + protected UserCredentials getUserCredentials() { + ObjectMapper mapper = new ObjectMapper().enableDefaultTyping(); + try { + File configFile = FileHandling.getConfigFile("credentials"); + if(!configFile.exists()) { + String basePath = System.getProperty("BASE_PATH"); + configFile = new File( basePath + File.separator + "conf" + File.separator + "credentials"); + } + Credentials credentials = mapper.readValue(configFile, Credentials.class); + return new UserCredentials(credentials.userId, credentials.password, "", "", ""); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + @Override + protected org.openecomp.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() { + + try { + String envUrl = System.getProperty("ENV_URL"); + boolean isCustomLogin = Boolean.valueOf(System.getProperty("CUSTOM_LOGIN")); + Configuration configuration = new org.openecomp.sdc.ci.tests.datatypes.Configuration(envUrl, isCustomLogin); + //configuration.setBrowser("chorme"); + return configuration; + //return new org.openecomp.sdc.ci.tests.datatypes.Configuration(envUrl, isCustomLogin); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + @Override + protected void loginToLocalSimulator(UserCredentials userCredentials) { + LoginExternalPage.performLoginExternal(userCredentials); + } + + protected void relogin(Credentials credentials) throws Exception { + if (!credentials.userId.equals(currentUserId)) { + currentUserId = credentials.userId; + UserCredentials userCredentials = new UserCredentials(credentials.userId, + credentials.password, "", "", ""); + reloginWithNewRole(userCredentials); + } + } + + /** + * Validates that permitted options are enabled and others are disabled. + * + * @param permittedItems the list of permitted items. + * @param dropdownOptionsClassName the class name of the specific dropdown options. + * @return true, if all dropdown options disabled state is according to the permissions. + */ + protected void assertDropdownPermittedItemsByValue(ArrayList<String> permittedItems, String dropdownOptionsClassName) { + GeneralUIUtils.ultimateWait(); + List<WebElement> optionsList = + GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30); + for (WebElement option : + optionsList) { + String optionValue = option.getAttribute("value"); + if ((option.isEnabled() && !permittedItems.contains(optionValue)) || + !option.isEnabled() && permittedItems.contains(optionValue)) { + fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE); + } + } + } + + protected void assertAllIsPermitted(String dropdownOptionsClassName) { + GeneralUIUtils.ultimateWait(); + List<WebElement> optionsList = + GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30); + for (WebElement option : + optionsList) { + String optionValue = option.getAttribute("value"); + if (!option.isEnabled()) { + fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE); + } + } + } + + protected void assertDropdownPermittedItemsByName(ArrayList<String> permittedItems, String dropdownOptionsClassName) { + GeneralUIUtils.ultimateWait(); + List<WebElement> optionsList = + GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30); + for (WebElement option : + optionsList) { + String optionText = option.getText(); + if ((option.isEnabled() && !permittedItems.contains(optionText)) || + !option.isEnabled() && permittedItems.contains(optionText)) { + fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE); + } + } + } + + protected void assertViewEditButtonState(String expectedButtonText, String UUID) { + WebElement viewEditWebElement = GeneralUIUtils.getWebElementByTestID(Constants.VIEW_EDIT_TEST_ID_PREFIX + UUID, 100); + Assert.assertEquals(expectedButtonText, viewEditWebElement.getText()); + GeneralUIUtils.ultimateWait(); + } + + protected void addVNF(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, String productFamily, ArrayList<String> permittedTenants) throws InterruptedException { + ViewEditPage viewEditPage = new ViewEditPage(); + + viewEditPage.selectNodeInstanceToAdd(name); + viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX); + viewEditPage.selectProductFamily(productFamily); + viewEditPage.selectLCPRegion(lcpRegion); + + assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); + viewEditPage.selectTenant(tenant); + + Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID); + SelectOption.selectFirstTwoOptionsFromMultiselectById(Constants.OwningEntity.LOB_SELECT_TEST_ID); + + viewEditPage.selectSuppressRollback(suppressRollback); + + viewEditPage.setLegacyRegion(legacyRegion); + + viewEditPage.clickConfirmButton(); + assertSuccessfulVNFCreation(); + viewEditPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + } + + protected void addVFModule(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, ArrayList<String> permittedTenants) { + ViewEditPage viewEditPage = new ViewEditPage(); + + viewEditPage.selectVolumeGroupToAdd(name); + viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VF_MODULE_INSTANCE_NAME_PREFIX); + viewEditPage.selectLCPRegion(lcpRegion); + + assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); + viewEditPage.selectTenant(tenant); + + viewEditPage.selectSuppressRollback(suppressRollback); + + viewEditPage.setLegacyRegion(legacyRegion); + + viewEditPage.clickConfirmButton(); + assertSuccessfulVFModuleCreation(); + viewEditPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + } + + protected void addVolumeGroup(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, ArrayList<String> permittedTenants) { + ViewEditPage viewEditPage = new ViewEditPage(); + + viewEditPage.selectVolumeGroupToAdd(name); + viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX); + viewEditPage.selectLCPRegion(lcpRegion); + + assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); + viewEditPage.selectTenant(tenant); + + viewEditPage.selectSuppressRollback(suppressRollback); + + viewEditPage.setLegacyRegion(legacyRegion); + + viewEditPage.clickConfirmButton(); + assertSuccessfulVolumeGroupCreation(); + viewEditPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + } + + void assertSuccessfulVNFCreation() { + boolean byText = GeneralUIUtils.findAndWaitByText(Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT, 100); + Assert.assertTrue(Constants.ViewEdit.VNF_CREATION_FAILED_MESSAGE, byText); + } + + void assertSuccessfulPNFAssociation() { + //TODO + boolean byText = GeneralUIUtils.findAndWaitByText(Constants.PnfAssociation.PNF_ASSOCIATED_SUCCESSFULLY_TEXT, 100); + Assert.assertTrue(Constants.PnfAssociation.PNF_ASSOCIATED_FAILED_MESSAGE, byText); + } + void assertSuccessfulVolumeGroupCreation() { + boolean byText = GeneralUIUtils.findAndWaitByText(Constants.ViewEdit.VOLUME_GROUP_CREATED_SUCCESSFULLY_TEXT, 100); + Assert.assertTrue(Constants.ViewEdit.VOLUME_GROUP_CREATION_FAILED_MESSAGE, byText); + } + + void assertSuccessfulVFModuleCreation() { + boolean byText = GeneralUIUtils.findAndWaitByText(Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT, 100); + Assert.assertTrue(Constants.ViewEdit.VF_MODULE_CREATION_FAILED_MESSAGE, byText); + } + + void goToExistingInstanceById(String instanceUUID) { + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + searchExistingPage.searchForInstanceByUuid(instanceUUID); + assertViewEditButtonState( Constants.VIEW_EDIT_BUTTON_TEXT, instanceUUID); + searchExistingPage.clickEditViewByInstanceId(instanceUUID); + } + + void goToExistingInstanceByName(String instanceName) { + SearchExistingPage searchExistingPage = new SearchExistingPage(); + SideMenu.navigateToSearchExistingPage(); + searchExistingPage.searchForInstanceByName(instanceName); + WebElement instanceIdRow = GeneralUIUtils.getWebElementByTestID(Constants.INSTANCE_ID_FOR_NAME_TEST_ID_PREFIX + instanceName, 30); + String instanceId = instanceIdRow.getText(); + assertViewEditButtonState( Constants.VIEW_EDIT_BUTTON_TEXT, instanceId); + searchExistingPage.clickEditViewByInstanceId(instanceId); + } + +} diff --git a/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java new file mode 100644 index 000000000..f38433bde --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java @@ -0,0 +1,158 @@ +package vid.automation.test.test; + +import org.junit.Assert; +import org.junit.Before; +import org.openqa.selenium.WebElement; +import org.testng.annotations.Test; +import vid.automation.test.Constants; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.Wait; +import vid.automation.test.model.User; +import vid.automation.test.sections.ViewEditPage; +import vid.automation.test.services.BulkRegistration; +import vid.automation.test.services.SimulatorApi; +import vid.automation.test.services.UsersService; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public class ViewEditServiceInstanceTest extends VidBaseTestCase { + + private ViewEditPage viewEditPage = new ViewEditPage(); + private UsersService usersService = new UsersService(); + private String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + private String serviceInstanceId2 ="f36f5734-e9df-4fbf-9f35-61be13f028a1"; + private final String DEACTIVATE_ACTION = "deactivate"; + private final String ACTIVATE_ACTION = "activate"; + private List<String> pnfs = Arrays.asList("SANITY6785cce9", "tesai371ve2"); + + public ViewEditServiceInstanceTest() throws IOException { } + + @Test + public void testGetAssociatedPnfsForServiceInstance() { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.getAssociatedPnfs(); + + goToExistingInstanceById(serviceInstanceId); + for (String pnf: pnfs) { + viewEditPage.getPnf(pnf); + } + } + + @Test + public void testPnfsNotExistForServiceInstance() { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + + goToExistingInstanceById(serviceInstanceId); + assertNoPnfExists(); + } + @Test + public void testActivateServiceInstance()throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance("Created"); + BulkRegistration.activateServiceInstance(ACTIVATE_ACTION); + goToExistingInstanceById(serviceInstanceId); + viewEditPage.assertButtonState(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID,true); + viewEditPage.assertButtonState(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID,false); + viewEditPage.clickActivateButton(); + viewEditPage.assertMsoRequestModal("COMPLETE - Success"); + viewEditPage.clickCloseButton(); + } + + @Test + public void testActivateServiceInstanceError()throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance("Created"); + BulkRegistration.activateServiceInstanceError(ACTIVATE_ACTION); + goToExistingInstanceById(serviceInstanceId); + viewEditPage.assertButtonState(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID,true); + viewEditPage.assertButtonState(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID,false); + viewEditPage.clickActivateButton(); + viewEditPage.assertMsoRequestModal("Error"); + viewEditPage.clickCloseButton(); + } + @Test + public void testDeactivateServiceInstance(){ + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance("Active"); + BulkRegistration.activateServiceInstance(DEACTIVATE_ACTION); + goToExistingInstanceById(serviceInstanceId); + viewEditPage.assertButtonState(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID,true); + viewEditPage.assertButtonState(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID,false); + viewEditPage.clickDeactivateButton(); + viewEditPage.assertMsoRequestModal("COMPLETE - Success"); + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance("PendingDelete"); + BulkRegistration.activateServiceInstance(ACTIVATE_ACTION); + viewEditPage.clickCloseButton(); + viewEditPage.assertButtonState(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID,true); + viewEditPage.assertButtonState(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID,false); + } + + @Test + public void testDeactivateServiceInstanceError()throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance("Active"); + BulkRegistration.activateServiceInstanceError(DEACTIVATE_ACTION); + goToExistingInstanceById(serviceInstanceId); + viewEditPage.assertButtonState(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID,false); + viewEditPage.assertButtonState(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID,true); + viewEditPage.clickDeactivateButton(); + viewEditPage.assertMsoRequestModal("Error"); + viewEditPage.clickCloseButton(); + } + @Test + public void testSuccessDissociatePnfFromServiceInstance() throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.getAssociatedPnfs(); + BulkRegistration.dissociatePnf(); + goToExistingInstanceById(serviceInstanceId); + dissociatePnf(pnfs.get(0)); //SANITY6785cce9 + viewEditPage.assertMsoRequestModal("COMPLETE - Success"); + viewEditPage.clickCloseButton(); + } + + @Test + public void testFailDissociatePnfFromServiceInstance() throws Exception { + SimulatorApi.clearAll(); + BulkRegistration.searchExistingServiceInstance(); + BulkRegistration.getAssociatedPnfs(); + SimulatorApi.registerExpectation(Constants.RegisterToSimulator.pProbe.REMOVE_PNF_RELATIONSHIP_ERROR); + + goToExistingInstanceById(serviceInstanceId); + dissociatePnf(pnfs.get(0)); //SANITY6785cce9 + viewEditPage.assertMsoRequestModal("Error"); + viewEditPage.clickCloseButton(); + } + + private void assertNoPnfExists() { + WebElement pnfElement = viewEditPage.getPnf(""); + Assert.assertNull("Pnf found under service instance", pnfElement); + } + + private void dissociatePnf(String pnfName) throws InterruptedException { + viewEditPage.clickDissociatePnfButton(pnfName); + assertDissociateConfirmModal(pnfName); + } + + private void assertDissociateConfirmModal(String pnfName) { + Wait.modalToBeDisplayed(); + Assert.assertTrue(Exists.modal()); + Assert.assertTrue(Exists.byCssSelectorAndText(".modal-body span", String.format(Constants.ViewEdit.DISSOCIATE_CONFIRM_MODAL_TEXT, pnfName))); + WebElement confirmBtn = Get.byId(Constants.ViewEdit.DISSOCIATE_CONFIRM_MODAL_BTN_ID); + Assert.assertNotNull(confirmBtn); + confirmBtn.click(); + Wait.modalToDisappear(); + } + @Before + public void before() throws Exception { + User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP); + relogin(user.credentials); + } + +} |