Ejemplo n.º 1
0
  /**
   * Get an AppointmentItem using soap
   *
   * @param account
   * @param query
   * @param start
   * @param end
   * @return
   * @throws HarnessException
   */
  public static AppointmentItem importFromSOAP(
      ZimbraAccount account, String query, ZDate start, ZDate end) throws HarnessException {

    try {
      account.soapSend(
          "<SearchRequest xmlns='urn:zimbraMail' types='appointment' calExpandInstStart='"
              + start.toMillis()
              + "' calExpandInstEnd='"
              + end.toMillis()
              + "'>"
              + "<query>"
              + query
              + "</query>"
              + "</SearchRequest>");

      Element[] results = account.soapSelectNodes("//mail:SearchResponse/mail:appt");
      if (results.length != 1)
        // throw new HarnessException("Query should return 1 result, not "+ results.length);
        return null;

      String id = account.soapSelectValue("//mail:appt", "id");

      account.soapSend(
          "<GetAppointmentRequest xmlns='urn:zimbraMail' id='"
              + id
              + "' includeContent='1'>"
              + "</GetAppointmentRequest>");
      Element getAppointmentResponse = account.soapSelectNode("//mail:GetAppointmentResponse", 1);

      // Using the response, create this item
      return (importFromSOAP(getAppointmentResponse));

    } catch (Exception e) {
      throw new HarnessException(
          "Unable to import using SOAP query("
              + query
              + ") and account("
              + account.EmailAddress
              + ")",
          e);
    }
  }
Ejemplo n.º 2
0
  public static TaskItem importFromSOAP(ZimbraAccount account, String query)
      throws HarnessException {

    try {

      account.soapSend(
          "<SearchRequest xmlns='urn:zimbraMail' types='task' >"
              + "<query>"
              + query
              + "</query>"
              + "</SearchRequest>");

      Element[] results = account.soapSelectNodes("//mail:SearchResponse/mail:task");
      if (results.length != 1)
        throw new HarnessException("Query should return 1 result, not " + results.length);

      String invId = account.soapSelectValue("//mail:SearchResponse/mail:task", "invId");

      account.soapSend(
          "<GetMsgRequest xmlns='urn:zimbraMail'>"
              + "<m id='"
              + invId
              + "' />"
              + "</GetMsgRequest>");
      Element getMsgResponse = account.soapSelectNode("//mail:GetMsgResponse", 1);

      // Using the response, create this item
      return (importFromSOAP(getMsgResponse));

    } catch (Exception e) {
      throw new HarnessException(
          "Unable to import using SOAP query("
              + query
              + ") and account("
              + account.EmailAddress
              + ")",
          e);
    }
  }
Ejemplo n.º 3
0
  @Test(
      description = "Create document using keyboard shortcut - verify through SOAP & RestUtil",
      groups = {"functional"})
  public void CreateDocument_03() throws HarnessException {
    ZimbraAccount account = app.zGetActiveAccount();

    FolderItem briefcaseFolder = FolderItem.importFromSOAP(account, SystemFolder.Briefcase);

    // Create document item
    DocumentItem document = new DocumentItem();

    String docName = document.getName();
    String docText = document.getDocText();

    Shortcut shortcut = Shortcut.S_NEWDOCUMENT;

    // Open new document page using keyboard shortcut
    app.zPageBriefcase.zSelectWindow(PageBriefcase.pageTitle);
    DocumentBriefcaseNew documentBriefcaseNew =
        (DocumentBriefcaseNew) app.zPageBriefcase.zKeyboardShortcut(shortcut);

    try {
      app.zPageBriefcase.zSelectWindow(DocumentBriefcaseNew.pageTitle);

      // Fill out the document with the data
      documentBriefcaseNew.zFillField(DocumentBriefcaseNew.Field.Name, docName);
      documentBriefcaseNew.zFillField(DocumentBriefcaseNew.Field.Body, docText);

      // Save and close
      app.zPageBriefcase.zSelectWindow(DocumentBriefcaseNew.pageTitle);

      documentBriefcaseNew.zSubmit();
    } finally {
      app.zPageBriefcase.zSelectWindow(PageBriefcase.pageTitle);
    }

    app.zPageBriefcase.zWaitForWindowClosed(DocumentBriefcaseNew.pageTitle);

    // refresh briefcase page
    app.zTreeBriefcase.zTreeItem(Action.A_LEFTCLICK, briefcaseFolder, true);

    // Display file through RestUtil
    EnumMap<PageBriefcase.Response.ResponsePart, String> response =
        app.zPageBriefcase.displayFile(
            docName,
            new HashMap<String, String>() {
              private static final long serialVersionUID = 1L;

              {
                put("fmt", PageBriefcase.Response.Format.NATIVE.getFormat());
              }
            });

    // Search for created document
    account.soapSend(
        "<SearchRequest xmlns='urn:zimbraMail' types='document'>"
            + "<query>"
            + docName
            + "</query>"
            + "</SearchRequest>");

    ZAssert.assertStringContains(
        account.soapSelectValue("//mail:doc", "name"), docName, "Verify document name through GUI");

    HtmlElement element = HtmlElement.clean(response.get(PageBriefcase.Response.ResponsePart.BODY));
    HtmlElement.evaluate(element, "//body", null, Pattern.compile(".*" + docText + ".*"), 1);

    ZAssert.assertStringContains(
        response.get(PageBriefcase.Response.ResponsePart.BODY),
        docText,
        "Verify document content through GUI");

    // delete file upon test completion
    app.zPageBriefcase.deleteFileByName(docName);
  }