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);
}
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);
}
}
Aggregations