use of com.zimbra.soap.mail.type.NewContactGroupMember in project zm-mailbox by Zimbra.
the class TestContactGroup method createAndGetContactGroup.
@Test
@Bug(bug = 70558)
public void createAndGetContactGroup() throws Exception {
SoapTransport transport = authUser(acct.getName());
/*
* search gal to get ref of the member account in GAL
*/
SearchGalRequest searchGalReq = new SearchGalRequest();
searchGalReq.setName(memberAcct.getName());
SearchGalResponse searchGalResp = invokeJaxb(transport, searchGalReq);
List<ContactInfo> entries = searchGalResp.getContacts();
assertEquals(1, entries.size());
ContactInfo galEntry = entries.get(0);
String galMemberRef = galEntry.getReference();
/*
* create a contact group
*/
NewContactGroupMember contactGroupMemer = NewContactGroupMember.createForTypeAndValue(ContactGroup.Member.Type.GAL_REF.getSoapEncoded(), galMemberRef);
NewContactAttr contactAttr = new NewContactAttr(ContactConstants.A_type);
contactAttr.setValue(ContactConstants.TYPE_GROUP);
ContactSpec contactSpec = new ContactSpec();
contactSpec.addAttr(contactAttr);
contactSpec.addContactGroupMember(contactGroupMemer);
CreateContactRequest createContactReq = new CreateContactRequest(contactSpec);
CreateContactResponse createContactResp = invokeJaxb(transport, createContactReq);
String contactGroupId = createContactResp.getContact().getId();
/*
* get the contact group, derefed
*/
GetContactsRequest getContactsReq = new GetContactsRequest();
getContactsReq.addContact(new Id(contactGroupId));
getContactsReq.setDerefGroupMember(Boolean.TRUE);
GetContactsResponse getContactsResp = invokeJaxb(transport, getContactsReq, SoapProtocol.SoapJS);
List<com.zimbra.soap.mail.type.ContactInfo> contacts = getContactsResp.getContacts();
assertEquals(1, contacts.size());
com.zimbra.soap.mail.type.ContactInfo contact = contacts.get(0);
List<ContactGroupMember> members = contact.getContactGroupMembers();
assertEquals(1, members.size());
ContactGroupMember member = members.get(0);
String memberType = member.getType();
String memberValue = member.getValue();
assertEquals(ContactGroup.Member.Type.GAL_REF.getSoapEncoded(), memberType);
assertEquals(galMemberRef, memberValue);
}
Aggregations