Search in sources :

Example 1 with AutoProvDirectoryEntry

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

the class JaxbToElementTest method searchAutoProvDirectoryResponse.

// AutoProvDirectoryEntry contains 2 lists - one via extending AdminKeyValuePairs
// No order is specified for elements via XmlType propOrder.  Checking how well this works.
@Test
public void searchAutoProvDirectoryResponse() throws Exception {
    Element resp = Element.XMLElement.mFactory.createElement(AdminConstants.SEARCH_AUTO_PROV_DIRECTORY_RESPONSE);
    resp.addAttribute(AdminConstants.A_MORE, false);
    resp.addAttribute(AdminConstants.A_SEARCH_TOTAL, 1);
    Element entryE = resp.addNonUniqueElement(AdminConstants.E_ENTRY);
    entryE.addAttribute(AdminConstants.A_DN, "displayNam");
    entryE.addNonUniqueElement(AdminConstants.E_KEY).setText("keyValue1");
    entryE.addNonUniqueElement(AdminConstants.E_KEY).setText("keyValue2");
    entryE.addNonUniqueElement(AdminConstants.E_A).addAttribute(AdminConstants.A_N, "nVal1").setText("attr1Txt");
    entryE.addNonUniqueElement(AdminConstants.E_A).addAttribute(AdminConstants.A_N, "nVal2").setText("attr2Txt");
    SearchAutoProvDirectoryResponse jaxb = JaxbUtil.elementToJaxb(resp);
    Assert.assertNotNull("Unmarshal soap object", jaxb);
    List<AutoProvDirectoryEntry> entries = jaxb.getEntries();
    Assert.assertNotNull("entries list", entries);
    Assert.assertEquals("Number of entries", 1, entries.size());
    AutoProvDirectoryEntry entry = entries.get(0);
    List<KeyValuePair> kvps = entry.getKeyValuePairs();
    Assert.assertNotNull("entry - attrs list", kvps);
    Assert.assertEquals("entry - Number of attrs", 2, kvps.size());
    List<String> keys = entry.getKeys();
    Assert.assertNotNull("entry - keys list", keys);
    Assert.assertEquals("entry - Number of keys", 2, keys.size());
}
Also used : SearchAutoProvDirectoryResponse(com.zimbra.soap.admin.message.SearchAutoProvDirectoryResponse) AutoProvDirectoryEntry(com.zimbra.soap.admin.type.AutoProvDirectoryEntry) KeyValuePair(com.zimbra.soap.type.KeyValuePair) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Aggregations

Element (com.zimbra.common.soap.Element)1 JSONElement (com.zimbra.common.soap.Element.JSONElement)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 SearchAutoProvDirectoryResponse (com.zimbra.soap.admin.message.SearchAutoProvDirectoryResponse)1 AutoProvDirectoryEntry (com.zimbra.soap.admin.type.AutoProvDirectoryEntry)1 KeyValuePair (com.zimbra.soap.type.KeyValuePair)1 JAXBElement (javax.xml.bind.JAXBElement)1 Test (org.junit.Test)1