Search in sources :

Example 1 with ContactAttr

use of com.zimbra.soap.type.ContactAttr in project zm-mailbox by Zimbra.

the class TestSearchGalGroups method testSearchGroup.

/*
     * Verify isOwner and isMember flags are returned correctly.
     */
private void testSearchGroup(Account acct, Group group, Boolean needIsOwner, MemberOfSelector needIsMember, boolean actualIsOwner, boolean actualIsMember) throws Exception {
    SoapTransport transport = authUser(acct.getName());
    SearchGalRequest req = new SearchGalRequest();
    req.setName(group.getName());
    req.setNeedIsOwner(needIsOwner);
    req.setNeedIsMember(needIsMember);
    SearchGalResponse resp = invokeJaxb(transport, req);
    List<String> result = Lists.newArrayList();
    List<String> expected = Lists.newArrayList(Verify.makeResultStr(group.getName(), ContactConstants.TYPE_GROUP, needIsOwner == null ? null : actualIsOwner, needIsMember == null ? null : actualIsMember, ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name()));
    List<ContactInfo> entries = resp.getContacts();
    for (ContactInfo entry : entries) {
        List<ContactAttr> attrs = entry.getAttrs();
        String email = null;
        String type = null;
        String subsPolicy = null;
        for (ContactAttr attr : attrs) {
            String key = attr.getKey();
            if (ContactConstants.A_email.equals(key)) {
                email = attr.getValue();
            } else if (ContactConstants.A_type.equals(key)) {
                type = attr.getValue();
            } else if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(key)) {
                subsPolicy = attr.getValue();
            }
        }
        Boolean isOwner = entry.isOwner();
        Boolean isMember = entry.isMember();
        result.add(Verify.makeResultStr(email, type, isOwner, isMember, subsPolicy));
    }
    Verify.verifyEquals(expected, result);
}
Also used : ContactAttr(com.zimbra.soap.type.ContactAttr) SearchGalResponse(com.zimbra.soap.account.message.SearchGalResponse) SearchGalRequest(com.zimbra.soap.account.message.SearchGalRequest) ContactInfo(com.zimbra.soap.account.type.ContactInfo) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 2 with ContactAttr

use of com.zimbra.soap.type.ContactAttr in project zm-mailbox by Zimbra.

the class TestGetContactsRequest method checkMemberOf.

private void checkMemberOf(List<ContactInfo> contacts, String id, String... grpIds) {
    ContactInfo contact = getContactWithId(contacts, id);
    assertNotNull(String.format("No contact in list with id=%s", id), contact);
    List<ContactAttr> attrs = contact.getAttrs();
    String name = "unknown";
    for (ContactAttr attr : attrs) {
        if (ContactConstants.A_fullName.equals(attr.getKey())) {
            name = attr.getValue();
            break;
        }
    }
    Collection<String> memberOf = contact.getMemberOf();
    List<String> groups = Lists.newArrayList(grpIds);
    if (groups.isEmpty()) {
        assertTrue("memberOf info should be empty or null", (memberOf == null) || memberOf.isEmpty());
        return;
    }
    assertNotNull(String.format("No memberOf for contact in list with id=%s/name=%s", id, name), memberOf);
    assertEquals(String.format("Number of groups contact with id=%s/name=%s is a member of", id, name), groups.size(), memberOf.size());
    for (String grp : groups) {
        assertTrue(String.format("Contact with id=%s/name=%s should be a member of %s", id, name, grp), memberOf.contains(grp));
    }
}
Also used : NewContactAttr(com.zimbra.soap.mail.type.NewContactAttr) ContactAttr(com.zimbra.soap.type.ContactAttr) ContactInfo(com.zimbra.soap.mail.type.ContactInfo)

Aggregations

ContactAttr (com.zimbra.soap.type.ContactAttr)2 SoapTransport (com.zimbra.common.soap.SoapTransport)1 SearchGalRequest (com.zimbra.soap.account.message.SearchGalRequest)1 SearchGalResponse (com.zimbra.soap.account.message.SearchGalResponse)1 ContactInfo (com.zimbra.soap.account.type.ContactInfo)1 ContactInfo (com.zimbra.soap.mail.type.ContactInfo)1 NewContactAttr (com.zimbra.soap.mail.type.NewContactAttr)1