@Override
  public void zFill(IItem item) throws HarnessException {
    logger.info(FormAddZimbraAccount.class.getCanonicalName() + ".fill(IItem)");
    logger.info(item.prettyPrint());

    // Make sure the item is a DesktopAccountItem
    if (!(item instanceof DesktopAccountItem)) {
      throw new HarnessException("Invalid item type - must be DesktopAccountItem");
    }

    // Convert object to ContactGroupItem
    DesktopAccountItem desktopAccountItem = (DesktopAccountItem) item;

    // Fill out the form
    if (desktopAccountItem.accountName != null && !desktopAccountItem.accountName.equals("")) {
      sType(Locators.zAccountNameField, desktopAccountItem.accountName);
    }

    if (desktopAccountItem.emailAddress != null && !desktopAccountItem.emailAddress.equals("")) {
      sType(Locators.zEmailAddressField, desktopAccountItem.emailAddress);
    }

    if (desktopAccountItem.incomingServer != null
        && !desktopAccountItem.incomingServer.equals("")) {
      sType(Locators.zIncomingServerField, desktopAccountItem.incomingServer);
    }

    if (desktopAccountItem.password != null && !desktopAccountItem.password.equals("")) {
      sType(Locators.zPasswordField, desktopAccountItem.password);
    }

    if (desktopAccountItem.ssl) {
      sClick(Locators.zSecuritySSLRadioButton);
    } else {
      sClick(Locators.zSecurityNoneRadioButton);
    }

    if (desktopAccountItem.port != null && !desktopAccountItem.port.equals("")) {
      if (!sGetText(Locators.zPortField).equals(desktopAccountItem.port)) {
        zClick(Locators.zEditPortLink);
        sType(Locators.zPortField, desktopAccountItem.port);
      } else {
        logger.debug("Port is already the same as the new one," + " thus no need to change it");
        // Fall through
      }
    }
  }
Beispiel #2
0
  @Override
  public void zFill(IItem item) throws HarnessException {
    logger.info(FormAddImapAccount.class.getCanonicalName() + ".fill(IItem)");
    logger.info(item.prettyPrint());

    // Make sure the item is a DesktopAccountItem
    if (!(item instanceof DesktopAccountItem)) {
      throw new HarnessException("Invalid item type - must be DesktopAccountItem");
    }

    // Convert object to ContactGroupItem
    DesktopAccountItem desktopAccountItem = (DesktopAccountItem) item;

    // Fill out the form
    if (desktopAccountItem.accountName != null && !desktopAccountItem.accountName.equals("")) {
      sType(Locators.zAccountNameField, desktopAccountItem.accountName);
    }

    if (desktopAccountItem.emailAddress != null && !desktopAccountItem.emailAddress.equals("")) {
      sType(Locators.zEmailAddressField, desktopAccountItem.emailAddress);
    }

    if (desktopAccountItem.fullName != null && !desktopAccountItem.fullName.equals("")) {
      sType(Locators.zFullNameField, desktopAccountItem.fullName);
    }

    if (desktopAccountItem.receivingUsernname != null
        && !desktopAccountItem.receivingUsernname.equals("")) {
      sType(Locators.zReceivingUserNameField, desktopAccountItem.receivingUsernname);
    }

    if (desktopAccountItem.receivingPassword != null
        && !desktopAccountItem.receivingPassword.equals("")) {
      sType(Locators.zReceivingPasswordField, desktopAccountItem.receivingPassword);
    }

    if (desktopAccountItem.receivingIncomingServer != null
        && !desktopAccountItem.receivingIncomingServer.equals("")) {
      sType(Locators.zReceivingServerField, desktopAccountItem.receivingIncomingServer);
    }

    if (desktopAccountItem.receivingPassword != null
        && !desktopAccountItem.receivingPassword.equals("")) {
      sType(Locators.zReceivingPasswordField, desktopAccountItem.receivingPassword);
    }

    if (desktopAccountItem.receivingSecurityType != null) {
      String radioButtonLocator = null;
      switch (desktopAccountItem.receivingSecurityType) {
        case NONE:
          radioButtonLocator = Locators.zSecurityNoneRadioButton;
          break;
        case SSL:
          radioButtonLocator = Locators.zSecuritySSLRadioButton;
          break;
        case TLS:
          radioButtonLocator = Locators.zSecurityTLSRadioButton;
          break;
        case TLS_IF_AVAILABLE:
          radioButtonLocator = Locators.zSecurityTLSIfAvailableRadioButton;
          break;
        default:
          throw new HarnessException(
              "Unuspported receivingSecurityType: " + desktopAccountItem.receivingSecurityType);
      }

      sClick(radioButtonLocator);
    }

    if (desktopAccountItem.receivingPort != null && !desktopAccountItem.receivingPort.equals("")) {

      if (!sGetText(Locators.zReceivingPortField).equals(desktopAccountItem.receivingPort)) {
        zClick(Locators.zEditReceivingPortLink);
        sType(Locators.zReceivingPortField, desktopAccountItem.receivingPort);
      } else {
        logger.debug(
            "Receiving Port is already the same as the new one," + " thus no need to change it");
        // Fall through
      }
    }

    if (desktopAccountItem.sendingSmtpServer != null
        && !desktopAccountItem.sendingSmtpServer.equals("")) {
      sType(Locators.zSendingServerField, desktopAccountItem.sendingSmtpServer);
    }

    if (desktopAccountItem.sendingThroughSsl) {
      sCheck(Locators.zSendingSSLCheckbox);
    } else {
      sUncheck(Locators.zSendingSSLCheckbox);
    }

    if (desktopAccountItem.sendingPort != null && !desktopAccountItem.sendingPort.equals("")) {

      if (!sGetText(Locators.zSendingPortField).equals(desktopAccountItem.sendingPort)) {
        zClick(Locators.zEditSendingPortLink);
        sType(Locators.zSendingPortField, desktopAccountItem.sendingPort);
      } else {
        logger.debug(
            "Sending Port is already the same as the new one," + " thus no need to change it");
        // Fall through
      }
    }

    if (desktopAccountItem.sendingUserName != null || desktopAccountItem.sendingPassword != null) {
      sCheck(Locators.zUseAuthCheckbox);
      GeneralUtility.waitForElementPresent(this, Locators.zSendingUserNameField);
      if (!sGetText(Locators.zSendingUserNameField).equals(desktopAccountItem.sendingUserName)) {
        sType(Locators.zSendingUserNameField, desktopAccountItem.sendingUserName);
      }

      if (!sGetText(Locators.zSendingPasswordField).equals(desktopAccountItem.sendingPassword)) {
        sType(Locators.zSendingPasswordField, desktopAccountItem.sendingPassword);
      }
    }
  }