Ejemplo n.º 1
0
  @Test
  public void spaceInFirstName() throws Exception {
    Mailbox mbox =
        MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put(ContactConstants.A_firstName, "First Second Third Forth");
    fields.put(ContactConstants.A_lastName, "Last");
    fields.put(ContactConstants.A_email, "*****@*****.**");
    mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);

    ContactAutoComplete autocomplete =
        new ContactAutoComplete(mbox.getAccount(), new OperationContext(mbox));
    Assert.assertEquals(
        1, autocomplete.query("first second third forth", null, 100).entries.size());
  }
Ejemplo n.º 2
0
 @Test
 public void addMatchedContactsWithUnicodeCase() throws Exception {
   Account account = Provisioning.getInstance().getAccount(MockProvisioning.DEFAULT_ACCOUNT_ID);
   ContactAutoComplete comp = new ContactAutoComplete(account, null);
   ContactAutoComplete.AutoCompleteResult result = new ContactAutoComplete.AutoCompleteResult(10);
   result.rankings = new ContactRankings(MockProvisioning.DEFAULT_ACCOUNT_ID);
   Map<String, Object> attrs =
       ImmutableMap.<String, Object>of(
           ContactConstants.A_firstName,
               "\u0421\u0440\u043f\u0441\u043a\u0438 \u0411\u043e\u0441\u043d\u0430 \u0438 \u0425\u0435\u0440\u0446\u0435\u0433\u043e\u0432\u0438\u043d\u0430",
           ContactConstants.A_lastName,
               "\u0441\u043a\u0438 \u0411\u043e\u0441\u043d\u0430 \u0438 \u0425\u0435\u0440\u0446\u0435\u0433\u043e\u0432\u0438\u043d\u0430",
           ContactConstants.A_email, "*****@*****.**");
   comp.addMatchedContacts(
       "\u0421\u0440\u043f\u0441\u043a\u0438 \u0411\u043e\u0441\u043d\u0430 \u0438 \u0425\u0435\u0440\u0446\u0435\u0433\u043e\u0432\u0438\u043d\u0430",
       attrs,
       Mailbox.ID_FOLDER_CONTACTS,
       null,
       result);
   Assert.assertEquals(1, result.entries.size());
   result.clear();
 }
Ejemplo n.º 3
0
  @Test
  public void addMatchedContacts() throws Exception {
    Account account = Provisioning.getInstance().getAccount(MockProvisioning.DEFAULT_ACCOUNT_ID);
    ContactAutoComplete comp = new ContactAutoComplete(account, null);
    ContactAutoComplete.AutoCompleteResult result = new ContactAutoComplete.AutoCompleteResult(10);
    result.rankings = new ContactRankings(MockProvisioning.DEFAULT_ACCOUNT_ID);
    Map<String, Object> attrs =
        ImmutableMap.<String, Object>of(
            ContactConstants.A_firstName, "First",
            ContactConstants.A_middleName, "Middle",
            ContactConstants.A_lastName, "Last",
            ContactConstants.A_email, "*****@*****.**");
    comp.addMatchedContacts("first f", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(0, result.entries.size());
    result.clear();

    comp.addMatchedContacts("first mid", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(1, result.entries.size());
    result.clear();

    comp.addMatchedContacts("first la", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(1, result.entries.size());
    result.clear();

    comp.addMatchedContacts("first mid la", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(1, result.entries.size());
    result.clear();

    attrs =
        ImmutableMap.<String, Object>of(
            ContactConstants.A_firstName, "Conf - hillview",
            ContactConstants.A_lastName, "test.server-vmware - dash",
            ContactConstants.A_email, "*****@*****.**");

    comp.addMatchedContacts(
        "test.server-vmware -", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(1, result.entries.size());
    result.clear();

    comp.addMatchedContacts(
        "test.server-vmware - d", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(1, result.entries.size());
    result.clear();

    comp.addMatchedContacts("conf - h", attrs, Mailbox.ID_FOLDER_CONTACTS, null, result);
    Assert.assertEquals(1, result.entries.size());
    result.clear();
  }
Ejemplo n.º 4
0
  @Test
  public void reservedQueryTerm() throws Exception {
    Mailbox mbox =
        MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put(ContactConstants.A_firstName, "not and or");
    fields.put(ContactConstants.A_lastName, "subject: from:");
    fields.put(ContactConstants.A_email, "*****@*****.**");
    mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);

    ContactAutoComplete autocomplete =
        new ContactAutoComplete(mbox.getAccount(), new OperationContext(mbox));
    Assert.assertEquals(1, autocomplete.query("not", null, 100).entries.size());
    Assert.assertEquals(1, autocomplete.query("not and", null, 100).entries.size());
    Assert.assertEquals(1, autocomplete.query("not and or", null, 100).entries.size());
    Assert.assertEquals(1, autocomplete.query("subject:", null, 100).entries.size());
    Assert.assertEquals(1, autocomplete.query("subject: from:", null, 100).entries.size());
  }