/** This method select trigger at the left panel */
 public static NotificationsPage selectNotificationLeftPanelAndCheckPage(
     TriggersPage triggersPage) {
   NotificationsPage notificationsPage = triggersPage.clickOnNotificationLink();
   Assert.assertTrue(notificationsPage.checkPage(), "Notifications page is not loaded correctly");
   Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
   return notificationsPage;
 }
 /**
  * This method create a trigger
  *
  * @param triggersPage Trigger PO
  * @param triggerName Trigger name
  */
 public static void createTrigger(TriggersPage triggersPage, String triggerName) {
   triggersPage.clickOnAddTrigger();
   Assert.assertTrue(
       triggersPage.isTriggerPopUPDisplayed(POPUP_ADD_TRIGGER),
       "Adding trigger popup is not displayed");
   triggersPage.addTrigger(triggerName);
   triggersPage.submit();
   Utilities.waitTime(ConstantsClass.TIMEOUT_2_SECONDS);
   Assert.assertTrue(
       triggersPage.existTrigger(triggerName),
       String.format("Trigger '%s' was not added correctly", triggerName));
 }
 /**
  * This method create a notification
  *
  * @param notificationsPage Notification PO
  * @param notificationName Notification name
  */
 public static void createNotification(
     NotificationsPage notificationsPage, String notificationName, String action) {
   notificationsPage.clickOnAddNotification();
   Assert.assertTrue(
       notificationsPage.isNotificationPopUPDisplayed(POPUP_ADD_NOTIFICATION),
       "Adding trigger popup is not displayed");
   notificationsPage.addNotification(notificationName, action);
   notificationsPage.submit();
   Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
   Assert.assertTrue(
       notificationsPage.existNotification(notificationName),
       String.format("Trigger '%s' was not added correctly", notificationName));
 }
 /**
  * This method prepare the text area to be used, since it is hidden
  *
  * @return The textarea element
  */
 private WebElement prepareTextArea() {
   String script =
       "arguments[0].setAttribute('style', 'overflow: visible; position: relative; width: 3px; height: 0px; top: 4px; left: 60px;');";
   WebDriverCommands.click(By.cssSelector(EXPAND_ALL), ConstantsClass.TIMEOUT_2_SECONDS);
   WebElement textAreaParentNode =
       WebDriverCommands.findElement(
           By.xpath(TEXT_AREA_PARENT_MIRROR), ConstantsClass.TIMEOUT_2_SECONDS);
   WebDriverCommands.executeScriptOnElement(
       WebDriverCommands.getDriver(), script, textAreaParentNode);
   Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
   WebElement textArea =
       WebDriverCommands.findElement(
           By.xpath(String.format(TEXT_AREA_MIRROR)), ConstantsClass.TIMEOUT_2_SECONDS);
   textArea.clear();
   return textArea;
 }
  /**
   * Test Case Name: Verify multiple Windows Servers can be added and modeled correctly
   *
   * <p>Summary: This test case verifies the ability to add and model multiple Server Window targets
   * simultaneously to discover the windows device components.
   *
   * <p>Pre-requisites: Zenoss instance is running Python Collector ZenPack is installed Microsoft
   * Windows ZenPack is installed
   *
   * <p>Post-requisites: The added devices must be deleted
   *
   * <p>Author Alexander Sanchez
   *
   * @param testCaseId The id of the test case
   * @param username User name of the application to test
   * @param password User password of the application to test
   * @param deviceName Name of the win 2008 device to add
   * @param windowsUser the windows user credential needed to model the windows 2003 device
   * @param windowsPassword the windows password credential needed to model the device
   * @param zenPackName the zenpack name
   * @param expectedComponents The list of components that need to be checked
   * @throws Exception Exception
   */
  @Test(groups = {"tc_32428"})
  @Parameters({
    "tc_32428_testcaseid",
    "tc_32428_username",
    "tc_32428_password",
    "tc_ps_win_devicename",
    "tc_32428_windowsuser",
    "tc_32428_windowspassword",
    "zenpack_microsoftwindowsname",
    "tc_win2008_expected_components"
  })
  public void verifyAddMultipleDevicesFunctionalityForWindowsZenpack(
      String testCaseId,
      String username,
      String password,
      String deviceName,
      String windowsUser,
      String windowsPassword,
      String zenPackName,
      String expectedComponents) {
    // ***Pre-Test
    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_PRETEST_LABEL);
    TestlinkCommands.setTestCaseID(testCaseId);
    CommonPage commonPage = new CommonPage();
    String endPoint = getEndPoint();
    String targetNameSpace = getTargetNameSpace();
    String host = getHostName();
    Autoinstall autoinstall = new Autoinstall();

    ZenPacksCommon.validateZenpackInstalledCompleteWorkFlow(username, password, zenPackName);
    Utilities.waitTime(ConstantsClass.TIMEOUT_2_SECONDS);

    DevicesPage devicesPage =
        (DevicesPage) commonPage.navigateTo(ConstantsClass.INFRASTRUCTURE_PAGE);
    Assert.assertTrue(devicesPage.checkPage(), "Infrastructure page is not displayed");

    if (DevicesCommon.selectDeviceInList(devicesPage, deviceName, ConstantsClass.DEVICE_FILTER))
      Assert.assertTrue(
          autoinstall.deleteDevice(endPoint, targetNameSpace, host, deviceName),
          String.format("Device can't be deleted"));

    // ***Test
    setTestCaseSection(TEST_CASE_SECTION_TEST);
    Assert.assertTrue(
        devicesPage.clickOnAddDeviceButton(),
        "The list with options to add device is not displayed");
    devicesPage.clickOnAddDeviceOption(ConstantsClass.ADD_MULTIPLE_DEVICES_OPTION_NAME);

    // These parameters are quite cumbersome, but are needed for the following method. Said method
    // will need to be optimized in the future
    String parameters =
        ConstantsClass.ADD_INFRASTRUCTURE_CATEGORY_SERVER
            + ","
            + ConstantsClass.ADD_INFRASTRUCTURE_TYPE_WIN_SERVER_RM
            + ","
            + deviceName
            + ","
            + windowsUser
            + ","
            + windowsPassword;
    DevicesCommon.addMultipleDevices(new AddMultipleDevicesPage(), parameters);
    devicesPage = (DevicesPage) commonPage.navigateTo(ConstantsClass.INFRASTRUCTURE_PAGE);
    Assert.assertTrue(devicesPage.checkPage(), "Infrastructure page is not displayed");
    Utilities.waitTime(TIMEOUT_5_SECONDS);
    OverviewPage overviewPage = devicesPage.clickDeviceLink(deviceName);
    String[] components = expectedComponents.split(",");
    Assert.assertTrue(
        overviewPage.areExpectedComponentsDisplayed(components),
        "After manually changing the creds, the components were not modeled correctly");

    // Post Test
    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    // Delete the device
    Assert.assertTrue(
        autoinstall.deleteDevice(endPoint, targetNameSpace, host, deviceName),
        String.format("Device [%s] can't be deleted", deviceName));
  }
  /**
   * Test Case Name: Adding/Modeling - Authentication - Wrong username/password
   *
   * <p>Summary: This is a negative test This test case verifies whether the user is given proper
   * message when user tries to add a Windows Device that has incorrect username and/or password
   *
   * <p>Pre-requisites: Python Collector ZenPack is installed Microsoft Windows ZenPack is installed
   * Target Device is configured with WinRM
   *
   * <p>Post-requisites: The added devices must be deleted
   *
   * <p>Author Alexander Sanchez
   *
   * @param testCaseId The id of the test case
   * @param username User name of the application to test
   * @param password User password of the application to test
   * @param deviceName Name of the win 2008 device to add
   * @param deviceClass the device class of the windows device
   * @param windowsUserCorrect the correct windows user credential needed to model the device
   * @param windowsUserIncorrect the incorrect windows user credential needed to model the device
   * @param windowsPasswordCorrect the correct windows password credential needed to model the
   *     device
   * @param windowsPasswordIncorrect the incorrect windows us credential needed to model the device
   * @param zenPackName the name of the zenpack that is being evaulated
   * @param expectedComponents The list of components that need to be checked
   * @throws Exception Exception
   */
  @Test(groups = {"tc_32430"})
  @Parameters({
    "tc_32430_testcaseid",
    "tc_32430_username",
    "tc_32430_password",
    "tc_ps_win_devicename",
    "tc_ps_win_deviceclass",
    "tc_32430_windowsusercorrect",
    "tc_32430_windowsuserincorrect",
    "tc_32430_windowspasswordcorrect",
    "tc_32430_windowspasswordincorrect",
    "zenpack_microsoftwindowsname",
    "tc_win2008_expected_components"
  })
  public void verifyWrongUsernamesAndPasswordsBlockModeling(
      String testCaseId,
      String username,
      String password,
      String deviceName,
      String deviceClass,
      String windowsUserCorrect,
      String windowsUserIncorrect,
      String windowsPasswordCorrect,
      String windowsPasswordIncorrect,
      String zenPackName,
      String expectedComponents) {

    Autoinstall autoinstall = new Autoinstall();
    CommonPage commonPage = new CommonPage();

    String host = getHostName();
    String endPoint = getEndPoint();
    String targetNameSpace = getTargetNameSpace();

    TestlinkCommands.setTestCaseID(testCaseId);

    // ***Pre-Test
    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    ZenPacksCommon.validateZenpackInstalledCompleteWorkFlow(username, password, zenPackName);
    Utilities.waitTime(ConstantsClass.TIMEOUT_2_SECONDS);

    DevicesPage devicesPage =
        (DevicesPage) commonPage.navigateTo(ConstantsClass.INFRASTRUCTURE_PAGE);
    Assert.assertTrue(devicesPage.checkPage(), "Infrastructure page is not displayed");
    // Utilities.waitTime(TIMEOUT_5_SECONDS);

    if (DevicesCommon.selectDeviceInList(devicesPage, deviceName, ConstantsClass.DEVICE_FILTER))
      Assert.assertTrue(
          autoinstall.deleteDevice(endPoint, targetNameSpace, host, deviceName),
          String.format("[WebService] Device %s can't be deleted", deviceName));

    // ***Test
    setTestCaseSection(TEST_CASE_SECTION_TEST);
    DevicesCommon.addSingleDevice(
        devicesPage, deviceName, deviceClass, "", "", "", "", false, "", "");

    DevicesCommon.selectDeviceInList(devicesPage, deviceName, ConstantsClass.DEVICE_FILTER);
    DeviceDetailPage deviceDetailPage = devicesPage.clickDeviceLink(deviceName);

    // The device hasn't been modeled yet
    String[] components = expectedComponents.split(",");
    Assert.assertFalse(
        deviceDetailPage.areExpectedComponentsDisplayed(components),
        "After manually changing the creds, the components were not modeled correctly");

    Map configPropertyMap = new HashMap();
    configPropertyMap.put(ConstantsClass.FILTER_CONFIGURATION_PAGE_WINRM_USER, windowsUserCorrect);
    configPropertyMap.put(
        ConstantsClass.FILTER_CONFIGURATION_PAGE_WINRM_PASSWORD, windowsPasswordIncorrect);
    ConfigurationPropertiesCommon.editConfigurationPropertyDeviceWinFailure(
        deviceDetailPage, configPropertyMap);

    // Should not show components
    Assert.assertFalse(
        deviceDetailPage.areExpectedComponentsDisplayed(components),
        "After manually changing the creds, the components were not modeled correctly");

    configPropertyMap.clear();
    configPropertyMap.put(
        ConstantsClass.FILTER_CONFIGURATION_PAGE_WINRM_USER, windowsUserIncorrect);
    configPropertyMap.put(
        ConstantsClass.FILTER_CONFIGURATION_PAGE_WINRM_PASSWORD, windowsPasswordCorrect);
    ConfigurationPropertiesCommon.editConfigurationPropertyDeviceWinFailure(
        deviceDetailPage, configPropertyMap);

    // Should not show components
    Assert.assertFalse(
        deviceDetailPage.areExpectedComponentsDisplayed(components),
        "After manually changing the creds, the components were not modeled correctly");

    // Post Test
    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    Assert.assertTrue(
        autoinstall.deleteDevice(endPoint, targetNameSpace, host, deviceName),
        String.format("[WebService] Device %s can't be deleted", deviceName));
  }
  /**
   * Test Case Name: Service actions for zenoperator role (Edit a Dynamic service)
   *
   * <p>Summary: This test case is intended to verify that user with zenOperator role can view
   * services but cannot execute basicpage actions in the Services page, in this case, editing a
   * service.
   *
   * <p>Pre-requisites: Create a user "zenoperator_user" with "zenoperator" as role Login as
   * zenoperator_user Service "TestService" must be created
   *
   * <p>Post-requisites: User named "zenoperator_user" should be deleted Service "TestService" must
   * be deleted
   *
   * <p>Author: Jennifer Castro
   *
   * @param testCaseId Test case ID
   * @param username Username to login
   * @param password Password of the user to login
   * @param newUsername Username of the user to add
   * @param newUserPassword Password of the user to add
   * @param userRole Type of the user to add e.g: manager
   * @param userEmail Email of the user
   * @param testService Logical node name
   */
  @Test(groups = {"tc_21018", "impact_services_tests"})
  @Parameters({
    "tc_21018_testcaseid",
    "tc_21018_username",
    "tc_21018_password",
    "tc_21018_newusername",
    "tc_21018_newuserpassword",
    "tc_21018_userrole",
    "tc_21018_useremail",
    "tc_21018_testservice",
    "ds_root_tree_node_name"
  })
  public void editDynamicServiceAsZenoperator(
      String testCaseId,
      String username,
      String password,
      String newUsername,
      String newUserPassword,
      String userRole,
      String userEmail,
      String testService,
      String dsTreeNodeName)
      throws Exception {

    TestlinkCommands.setTestCaseID(testCaseId);

    CommonPage commonPage = new CommonPage();
    DynamicServicesCommon dynamicServicesCommon = new DynamicServicesCommon();
    testService = String.format("%s %d", testService, Utilities.getRandomNumber(1000));
    List<String> path = new ArrayList<String>();
    path.add(0, testService);

    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_PRETEST_LABEL);
    addUserPreTestSteps(
        commonPage, username, password, newUsername, newUserPassword, userRole, userEmail);
    dynamicServicesCommon.addDynamicServicePreTestSteps(
        commonPage, username, password, testService);
    LoginCommon.login(newUsername, newUserPassword);

    setTestCaseSection(TEST_CASE_SECTION_TEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_TEST_LABEL);

    TestlinkCommands.addStepDescription("- Go to Services Page");
    DynamicServicesPage dynamicServicesPage =
        (DynamicServicesPage) commonPage.navigateTo(SERVICES_PAGE);
    Assert.assertTrue(dynamicServicesPage.checkPage(), "Dynamic Service page is not displayed");

    Assert.assertTrue(
        dynamicServicesPage.isItemInDynamicServiceTreeHighlighted(dsTreeNodeName),
        String.format("Dynamic service root node: %s is not highlighted", dsTreeNodeName));
    functions.waitTime(TIMEOUT_2_SECONDS);

    TestlinkCommands.addStepDescription(
        String.format("- Click on the service called \"%s\"", testService));
    DynamicServicesCommon.reachElementInsideTree(path, dynamicServicesPage, true, true);
    functions.waitTime(TIMEOUT_2_SECONDS);

    // Validation: Service "TestService" is highlighted to show that it is selected.
    Assert.assertTrue(
        dynamicServicesPage.isItemInDynamicServiceTreeHighlighted(testService),
        String.format("Dynamic service: %s is not highlighted", testService));
    functions.waitTime(TIMEOUT_2_SECONDS);

    // Validation: Add and delete buttons are disabled on the right frame.
    Assert.assertFalse(
        dynamicServicesPage.isAddToServiceButtonEnabled(),
        "Add to service (+) button is NOT disabled");

    Assert.assertFalse(
        dynamicServicesPage.isDeleteToServiceButtonEnabled(),
        "Delete to service (-) button is NOT disabled");

    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_POSTTEST_LABEL);
    LoginPage loginPage = commonPage.signOut();
    Assert.assertTrue(loginPage.checkPage(), "Login page is not displayed");
    dynamicServicesCommon.deleteDynamicServicePostTestSteps(
        commonPage, username, password, testService, path);
    deleteUserPostTestSteps(commonPage, username, password, newUsername);
  }
  /**
   * Test Case Name: Dashboard actions for ZenOperaror role
   *
   * <p>Summary:
   *
   * <p>Pre-requisites: Create a user "zenoperator_user" with "ZenOperator" as role Login as
   * zenoperator_user
   *
   * <p>Post-requisites: User named "zenoperator_user" should be deleted
   *
   * <p>Author: Jennifer Castro
   *
   * @param testCaseId testlink ID
   * @param username zenoss username
   * @param password zenoss password
   * @param role User role
   * @param newUser New user name
   * @param newUserPassword New user password user
   * @param email New user email
   * @param dashboard Dashboard to use
   */
  @Test(groups = {"tc_20651", "dashboard_portlets_tests"})
  @Parameters({
    "tc_20651_testcaseid",
    "tc_20651_username",
    "tc_20651_password",
    "tc_20651_role",
    "tc_20651_useridtoadd",
    "tc_20651_usertoaddnewpassword",
    "tc_20651_email",
    "tc_20651_dashboard"
  })
  public void validateDashboardActionsForZenOperatorRole(
      String testCaseId,
      String username,
      String password,
      String role,
      String newUser,
      String newUserPassword,
      String email,
      String dashboard) {

    TestlinkCommands.setTestCaseID(testCaseId);
    CommonPage commonPage = new CommonPage();

    // ***Pre-Test
    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_PRETEST_LABEL);
    DashboardPage dashboardPage = LoginCommon.login(username, password);

    // Add a Dashboard to modify
    // todo

    // Select a specific Dashboard
    dashboardPage.selectDashboardsDropDownValue(dashboard);

    // Delete all portlets
    DashboardCommon.deleteAllPortlets(dashboardPage, ConstantsClass.PORTLET_DEFAULT_ID);

    // Add 3 portlets
    DashboardCommon.addPortlet(dashboardPage, ConstantsClass.PORTLET_WATCH_LIST_ID);
    Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
    Assert.assertTrue(
        dashboardPage.isWatchListPortletDisplayed(""), "Watch List Portlet is not displayed");

    DashboardCommon.addPortlet(dashboardPage, ConstantsClass.PORTLET_DEVICE_ISSUES_ID);
    Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
    Assert.assertTrue(
        dashboardPage.isDeviceIssuesPortletDisplayed(""), "Device Issues Portlet is not displayed");

    DashboardCommon.addPortlet(dashboardPage, ConstantsClass.PORTLET_GOOGLE_MAP_ID);
    Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
    Assert.assertTrue(
        dashboardPage.isGoogleMapsPortletDisplayed(""), "Google Maps Portlet is not displayed");
    commonPage.signOut();

    // Log in with the new user
    addUserPreTestSteps(commonPage, username, password, newUser, newUserPassword, role, email);
    dashboardPage = LoginCommon.login(newUser, newUserPassword);

    // Select a specific Dashboard
    dashboardPage.selectDashboardsDropDownValue(dashboard);

    // Test
    setTestCaseSection(TEST_CASE_SECTION_TEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_TEST_LABEL);

    // Validate Dashboard buttons
    Assert.assertFalse(
        dashboardPage.isAddButtonDisplayed(),
        "'+' Add button IS displayed on right-top of Dashboard page");
    Assert.assertFalse(
        dashboardPage.isRemoveButtonDisplayed(),
        "'-' Add button IS displayed on right-top of Dashboard page");
    Assert.assertFalse(
        dashboardPage.isGearButtonDisplayed(),
        "Gear button IS displayed on right-top of Dashboard page");

    // Validation of default portlets
    Assert.assertTrue(
        dashboardPage.isWatchListPortletDisplayed(""), "Watch List Portlet is not displayed");
    Assert.assertTrue(
        dashboardPage.isDeviceIssuesPortletDisplayed(""), "Device Issues Portlet is not displayed");
    Assert.assertTrue(
        dashboardPage.isGoogleMapsPortletDisplayed(""), "Google Maps Portlet is not displayed");

    // Post Test
    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_POSTTEST_LABEL);
    LoginPage loginPage = commonPage.signOut();
    Assert.assertTrue(loginPage.checkPage(), "Login page is not displayed");
    deleteUserPostTestSteps(commonPage, username, password, newUser);
  }
  /**
   * Test Case Name: Actions for zenoperator role (Add a service)
   *
   * <p>Summary: This test case is intended to verify that user with zenOperator role can view
   * services but cannot execute basicpage actions in the Services page, in this case, adding a
   * service.
   *
   * <p>Pre-requisites: Create a user "zenoperator_user" with "zenoperator" as role Login as
   * zenoperator_user Service "TestService" must be created
   *
   * <p>Post-requisites: User named "zenoperator_user" should be deleted Service "TestService" must
   * be deleted
   *
   * <p>Author: Juan Polanco
   *
   * @param testCaseId testlink ID
   * @param username zenoss username
   * @param password zenoss password
   * @param userRole User role
   * @param newUser New user name
   * @param newUserPassword New user password user
   * @param managerEmail New user email
   * @param serviceName Dynamic service name
   */
  @Test(groups = {"tc_21016", "impact_services_tests"})
  @Parameters({
    "tc_21016_testcaseid",
    "tc_21016_username",
    "tc_21016_password",
    "tc_21016_userrole",
    "tc_21016_newusername",
    "tc_21016_newuserpassword",
    "tc_21016_useremail",
    "tc_21016_servicename"
  })
  public void zenOperatorRoleActionAddService(
      String testCaseId,
      String username,
      String password,
      String userRole,
      String newUser,
      String newUserPassword,
      String managerEmail,
      String serviceName) {

    TestlinkCommands.setTestCaseID(testCaseId);
    CommonPage commonPage = new CommonPage();
    LoginPage loginPage = new LoginPage();
    DynamicServicesCommon dynamicServicesCommon = new DynamicServicesCommon();
    serviceName = String.format("%s %d", serviceName, Utilities.getRandomNumber(1000));
    List<String> path = new ArrayList<String>();
    path.add(0, serviceName);

    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_PRETEST_LABEL);
    addUserPreTestSteps(
        commonPage, username, password, newUser, newUserPassword, userRole, managerEmail);
    dynamicServicesCommon.addDynamicServicePreTestSteps(
        commonPage, username, password, serviceName);
    LoginCommon.login(newUser, newUserPassword);

    setTestCaseSection(TEST_CASE_SECTION_TEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_TEST_LABEL);

    TestlinkCommands.addStepDescription("-Go to Dynamic Services ");
    DynamicServicesPage dynamicServicesPage =
        (DynamicServicesPage) commonPage.navigateTo(SERVICES_PAGE);
    Assert.assertTrue(dynamicServicesPage.checkPage(), "Dynamic Service page is not displayed");

    Assert.assertFalse(
        dynamicServicesPage.isAddDynamicServicesButtonDisplayed(),
        "Add dynamic services button is displayed");
    Assert.assertFalse(
        dynamicServicesPage.isDynamicServicesGearButtonDisplayed(), "Gears button is displayed");
    Assert.assertFalse(
        dynamicServicesPage.isRemoveDynamicServicesButtonDisplayed(),
        "Remove dynamic services button is displayed");

    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_POSTTEST_LABEL);
    TestlinkCommands.addStepDescription(String.format("- Logout as a [%s]", newUser));
    commonPage.signOut();
    Assert.assertTrue(loginPage.checkPage(), "Login page is not displayed");
    dynamicServicesCommon.deleteDynamicServicePostTestSteps(
        commonPage, username, password, serviceName, path);
    deleteUserPostTestSteps(commonPage, username, password, newUser);
  }
  /**
   * Test Case Name: Service actions for zenoperator role (Edit a Logical Node)
   *
   * <p>Summary: This test case is intended to verify that user with zenoperator role can view
   * logical nodes but cannot execute basicpage actions in the Logical Nodes page, in this case,
   * editing a logical node.
   *
   * <p>Pre-requisites: Create a user "zenoperator_user" with "zenoperator" as role Login as
   * zenoperator_user Create a logical node with the name "Testnode"
   *
   * <p>Post-requisites: User named "zenoperator_user" must be deleted Logical node with the name
   * "Testnode" must be deleted
   *
   * <p>Author: Jennifer Castro
   *
   * @param testCaseId Test case ID
   * @param username Username to login
   * @param password Password of the user to login
   * @param newUsername Username of the user to add
   * @param newUserPassword Password of the user to add
   * @param userRole Type of the user to add e.g: manager
   * @param userEmail Email of the user
   * @param testNode Logical node name
   */
  @Test(groups = {"tc_21032", "impact_services_tests"})
  @Parameters({
    "tc_21032_testcaseid",
    "tc_21032_username",
    "tc_21032_password",
    "tc_21032_newusername",
    "tc_21032_newuserpassword",
    "tc_21032_userrole",
    "tc_21032_useremail",
    "tc_21032_testnode",
    "tc_21032_nodedescription",
    "ln_root_tree_node_name"
  })
  public void editLogicalNodeAsZenoperator(
      String testCaseId,
      String username,
      String password,
      String newUsername,
      String newUserPassword,
      String userRole,
      String userEmail,
      String testNode,
      String nodeDescription,
      String lnTreeNodeName) {

    TestlinkCommands.setTestCaseID(testCaseId);

    CommonPage commonPage = new CommonPage();
    ServicesSubMenuPage servicesSubMenuPage = new ServicesSubMenuPage();
    LogicalNodesCommon logicalNodesCommon = new LogicalNodesCommon();
    testNode = String.format("%s %d", testNode, Utilities.getRandomNumber(1000));

    List<String> path = new ArrayList<String>();
    path.add(testNode);

    setTestCaseSection(TEST_CASE_SECTION_PRETEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_PRETEST_LABEL);
    addUserPreTestSteps(
        commonPage, username, password, newUsername, newUserPassword, userRole, userEmail);

    logicalNodesCommon.addLogicalNodePreTestSteps(
        commonPage, servicesSubMenuPage, username, password, testNode, path);

    LoginCommon.login(newUsername, newUserPassword);

    setTestCaseSection(TEST_CASE_SECTION_TEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_TEST_LABEL);
    TestlinkCommands.addStepDescription("- Go to Services Page");
    DynamicServicesPage dynamicServicesPage =
        (DynamicServicesPage) commonPage.navigateTo(SERVICES_PAGE);
    Assert.assertTrue(dynamicServicesPage.checkPage(), "Dynamic Service page is not displayed");

    TestlinkCommands.addStepDescription("- Go to Logical Nodes Page");
    LogicalNodesPage logicalNodesPage =
        (LogicalNodesPage) servicesSubMenuPage.navigateTo(LOGICAL_NODES_SUBMENU_PAGE);
    Assert.assertTrue(logicalNodesPage.checkPage(), "Logical Node page is not displayed");

    Assert.assertTrue(
        logicalNodesPage.isLogicalNodeHighlighted(lnTreeNodeName),
        String.format("Logical root node: %s is not highlighted", lnTreeNodeName));
    Utilities.waitTime(TIMEOUT_2_SECONDS);

    TestlinkCommands.addStepDescription(
        String.format("- Click on \"%s\" on the left frame", testNode));
    logicalNodesCommon.reachElementInsideTree(path, logicalNodesPage, true, true);

    // Validation: Logical Node is highlighted to show that it is selected.
    Assert.assertTrue(
        logicalNodesPage.isLogicalNodeHighlighted(testNode),
        String.format("Logical node: %s is not highlighted", testNode));

    logicalNodesPage.editBasicLogicalNodeinformation("", nodeDescription);
    functions.waitTime(TIMEOUT_2_SECONDS);

    // Validation: Save button is disabled
    Assert.assertFalse(logicalNodesPage.isSaveButtonEnabled(), "Save button is NOT disabled");

    // Validation: Cancel button is enabled on the right frame of the page.
    Assert.assertTrue(logicalNodesPage.isCancelButtonEnabled(), "Cancel button is NOT enabled");

    setTestCaseSection(TEST_CASE_SECTION_POSTTEST);
    TestlinkCommands.addStepDescription(TEST_CASE_SECTION_POSTTEST_LABEL);
    LoginPage loginPage = commonPage.signOut();
    Assert.assertTrue(loginPage.checkPage(), "Login page is not displayed");

    logicalNodesCommon.deleteLogicalNodePostTestSteps(
        commonPage, servicesSubMenuPage, username, password, testNode, path);

    deleteUserPostTestSteps(commonPage, username, password, newUsername);
  }
Esempio n. 11
0
 /**
  * This method select trigger at the left panel
  *
  * @param triggersPage Trigger PO
  */
 public static void selectTriggerLeftPanelAndCheckPage(TriggersPage triggersPage) {
   triggersPage.clickOnTriggerLink();
   Assert.assertTrue(triggersPage.checkPage(), "Trigger page is not loaded correctly");
   Utilities.waitTime(ConstantsClass.TIMEOUT_1_SECONDS);
 }