Search in sources :

Example 11 with KeyValuePair

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

the class TestDelegatedDL method createDistributionList.

@Test
public void createDistributionList() throws Exception {
    String dlName = getAddress(genGroupNameLocalPart());
    SoapTransport transport = authUser(USER_CREATOR);
    CreateDistributionListRequest req = new CreateDistributionListRequest(dlName, null, DYNAMIC);
    List<KeyValuePair> attrsCreate = Lists.newArrayList(new KeyValuePair(Provisioning.A_zimbraDistributionListSubscriptionPolicy, ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name()));
    req.setKeyValuePairs(attrsCreate);
    CreateDistributionListResponse resp = invokeJaxb(transport, req);
    DLInfo dlInfo = resp.getDl();
    String dlId = dlInfo.getId();
    Group group = prov.getGroup(Key.DistributionListBy.name, dlName);
    assertNotNull(group);
    assertEquals(group.getId(), dlId);
    boolean seenExpectedMail = false;
    boolean seenExpectedSubsPolicy = false;
    List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
    for (KeyValuePair attr : attrs) {
        String name = attr.getKey();
        String value = attr.getValue();
        if (Provisioning.A_mail.equals(name)) {
            assertEquals(group.getName(), value);
            seenExpectedMail = true;
        }
        if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(name)) {
            assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
            seenExpectedSubsPolicy = true;
        }
    }
    assertTrue(seenExpectedMail);
    assertTrue(seenExpectedSubsPolicy);
}
Also used : Group(com.zimbra.cs.account.Group) CreateDistributionListRequest(com.zimbra.soap.account.message.CreateDistributionListRequest) KeyValuePair(com.zimbra.soap.type.KeyValuePair) CreateDistributionListResponse(com.zimbra.soap.account.message.CreateDistributionListResponse) DLInfo(com.zimbra.soap.account.type.DLInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 12 with KeyValuePair

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

the class TestDelegatedDL method getDistributionList.

@Test
public void getDistributionList() throws Exception {
    SoapTransport transport = authUser(USER_OWNER);
    GetDistributionListRequest req = new GetDistributionListRequest(DistributionListSelector.fromName(DL_NAME), Boolean.TRUE);
    GetDistributionListResponse resp = invokeJaxb(transport, req);
    DistributionListInfo dlInfo = resp.getDl();
    assertTrue(dlInfo.isOwner());
    assertFalse(dlInfo.isMember());
    String dlId = dlInfo.getId();
    Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
    assertNotNull(group);
    assertEquals(group.getId(), dlId);
    boolean seenMail = false;
    boolean seenSubsPolicy = false;
    boolean seenUnsubsPolicy = false;
    List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
    for (KeyValuePair attr : attrs) {
        String name = attr.getKey();
        String value = attr.getValue();
        if (Provisioning.A_mail.equals(name)) {
            assertEquals(group.getName(), value);
            seenMail = true;
        }
        if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(name)) {
            assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
            seenSubsPolicy = true;
        }
        // zimbraAccount:GetDistributionListResponse should return the default value, instead of empty.
        if (Provisioning.A_zimbraDistributionListUnsubscriptionPolicy.equals(name)) {
            assertEquals(ZAttrProvisioning.DistributionListUnsubscriptionPolicy.REJECT.name(), value);
            seenUnsubsPolicy = true;
        }
    }
    assertTrue(seenMail);
    assertTrue(seenSubsPolicy);
    assertTrue(seenUnsubsPolicy);
    List<? extends DistributionListGranteeInfoInterface> dlOwners = dlInfo.getOwners();
    assertEquals(1, dlOwners.size());
    for (DistributionListGranteeInfoInterface owner : dlOwners) {
        com.zimbra.soap.type.GranteeType type = owner.getType();
        String id = owner.getId();
        String name = owner.getName();
        assertEquals(com.zimbra.soap.type.GranteeType.usr, type);
        assertEquals(USER_OWNER, name);
    }
}
Also used : GetDistributionListResponse(com.zimbra.soap.account.message.GetDistributionListResponse) Group(com.zimbra.cs.account.Group) DistributionListGranteeInfoInterface(com.zimbra.soap.base.DistributionListGranteeInfoInterface) DistributionListInfo(com.zimbra.soap.account.type.DistributionListInfo) KeyValuePair(com.zimbra.soap.type.KeyValuePair) GetDistributionListRequest(com.zimbra.soap.account.message.GetDistributionListRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Aggregations

KeyValuePair (com.zimbra.soap.type.KeyValuePair)12 Test (org.junit.Test)11 Element (com.zimbra.common.soap.Element)8 JSONElement (com.zimbra.common.soap.Element.JSONElement)8 XMLElement (com.zimbra.common.soap.Element.XMLElement)8 XmlAnyElement (javax.xml.bind.annotation.XmlAnyElement)7 XmlElement (javax.xml.bind.annotation.XmlElement)7 FilterTest (com.zimbra.soap.mail.type.FilterTest)6 SoapTransport (com.zimbra.common.soap.SoapTransport)4 Group (com.zimbra.cs.account.Group)4 GetDistributionListResponse (com.zimbra.soap.account.message.GetDistributionListResponse)3 DLInfo (com.zimbra.soap.account.type.DLInfo)3 DistributionListInfo (com.zimbra.soap.account.type.DistributionListInfo)3 CreateDistributionListResponse (com.zimbra.soap.account.message.CreateDistributionListResponse)2 WrappedKeyValuePairsTester (com.zimbra.soap.jaxb.WrappedKeyValuePairsTester)2 Account (com.zimbra.cs.account.Account)1 CreateDistributionListRequest (com.zimbra.soap.account.message.CreateDistributionListRequest)1 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)1 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)1 GetAccountDistributionListsRequest (com.zimbra.soap.account.message.GetAccountDistributionListsRequest)1