use of com.zimbra.soap.mail.message.GetContactsRequest in project zm-mailbox by Zimbra.
the class JaxbToElementTest method jaxbElementsFixupTest.
/**
* Check that @{link JaxbUtil.elementToJaxb} will accept XML where
* JAXB expects various attributes that have been specified as elements.
* Ensure that @XmlElements is handled
* @throws Exception
*/
@Test
public void jaxbElementsFixupTest() throws Exception {
Element rootElem = Element.XMLElement.mFactory.createElement(MailConstants.GET_CONTACTS_REQUEST);
// JAXB Attribute A_SYNC
rootElem.addNonUniqueElement(MailConstants.A_SYNC).addText("true");
// JAXB Attribute A_FOLDER
rootElem.addAttribute(MailConstants.A_FOLDER, "folderId");
// JAXB Attribute A_SORTBY
rootElem.addNonUniqueElement(MailConstants.A_SORTBY).addText("sortBy");
// JAXB Elements:
// Element E_ATTRIBUTE --> AttributeName
// Element E_CONTACT --> Id
Element attrName1 = rootElem.addNonUniqueElement(MailConstants.E_ATTRIBUTE);
attrName1.addAttribute(MailConstants.A_ATTRIBUTE_NAME, "aName1");
Element contact1 = rootElem.addNonUniqueElement(MailConstants.E_CONTACT);
contact1.addNonUniqueElement(MailConstants.A_ID).addText("ctctId1");
Element contact2 = rootElem.addNonUniqueElement(MailConstants.E_CONTACT);
contact2.addAttribute(MailConstants.A_ID, "ctctId2");
Element attrName2 = rootElem.addNonUniqueElement(MailConstants.E_ATTRIBUTE);
attrName2.addNonUniqueElement(MailConstants.A_ATTRIBUTE_NAME).addText("aName2");
Element memAttr1 = rootElem.addNonUniqueElement(MailConstants.E_CONTACT_GROUP_MEMBER_ATTRIBUTE);
memAttr1.addNonUniqueElement(MailConstants.A_ATTRIBUTE_NAME).addText("grpAttrName1");
GetContactsRequest req = JaxbUtil.elementToJaxb(rootElem);
Assert.assertEquals("Sync", true, req.getSync().booleanValue());
Assert.assertEquals("FolderID", "folderId", req.getFolderId());
Assert.assertEquals("SortBy", "sortBy", req.getSortBy());
}
use of com.zimbra.soap.mail.message.GetContactsRequest 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