use of com.zimbra.soap.admin.message.AddDistributionListMemberRequest in project zm-mailbox by Zimbra.
the class TestDLMembership method testGetDistributionListMembers.
@Test
public void testGetDistributionListMembers() {
SoapTransport transport;
try {
transport = TestUtil.getAdminSoapTransport();
AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(testUser.getName())));
AddDistributionListMemberResponse addDLMemberResp2 = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL2.getId(), Collections.singleton(testUser2.getName())));
assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
//Verify GetDistributionListMembersRequest returns correct members.
SoapTransport transportAccount = TestUtil.authUser(testUser.getName(), TestUtil.DEFAULT_PASSWORD);
GetDistributionListMembersResponse resp = SoapTest.invokeJaxb(transportAccount, new GetDistributionListMembersRequest(0, 0, testDL2.getName()));
List<String> dlInfoList = resp.getDlMembers();
assertFalse("Unexepcted member present", dlInfoList.contains(testUser.getName()));
assertTrue("DL member not present", dlInfoList.contains(testUser2.getName()));
resp = SoapTest.invokeJaxb(transportAccount, new GetDistributionListMembersRequest(0, 0, testDL.getName()));
dlInfoList = resp.getDlMembers();
assertFalse("Unexepcted member present", dlInfoList.contains(testUser2.getName()));
assertTrue("DL member not present", dlInfoList.contains(testUser.getName()));
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
}
use of com.zimbra.soap.admin.message.AddDistributionListMemberRequest in project zm-mailbox by Zimbra.
the class TestDLMembership method testAddMemberByAlias.
@Test
public void testAddMemberByAlias() {
SoapTransport transport;
try {
transport = TestUtil.getAdminSoapTransport();
//add an alias to the account
AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
Account acct = Provisioning.getInstance().getAccount(testUser.getId());
assertNotNull(acct);
assertNotNull("account's aliases are null", acct.getAliases());
assertEquals("account has no aliases", acct.getAliases().length, 1);
//add a member by alias
AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
//verify that account is a member of the DL
GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
assertNotNull("GetAccountMembershipRequest cannot be null", resp);
List<DLInfo> dlInfoList = resp.getDlList();
assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
}
Aggregations