/** * Returns a list containing Phone Number GData extension objects. This method takes a formatted OM * Element and converts it to a list of phone number objects. * * @param phoneNumberElement The parent element containing the individual elements containing phone number * details. * @return a list containing GData extension PhoneNumber objects. */ protected final List<PhoneNumber> getPhoneNumberList(final OMElement phoneNumberElement) { List<PhoneNumber> phoneNoList = new ArrayList<PhoneNumber>(); Iterator< ? > phoneNumberIterator = phoneNumberElement.getChildElements(); while (phoneNumberIterator.hasNext()) { OMElement singlePhoneNumberElement = (OMElement) phoneNumberIterator.next(); PhoneNumber phoneNumber = new PhoneNumber(); phoneNumber.setPhoneNumber(singlePhoneNumberElement.getText()); phoneNumber.setRel(Constants.REL_OPEN + singlePhoneNumberElement.getLocalName()); if (singlePhoneNumberElement.getAttributeValue(new QName(Constants.PRIMARY)) != null) { phoneNumber.setPrimary(Boolean.parseBoolean(singlePhoneNumberElement.getAttributeValue(new QName( Constants.PRIMARY)))); } phoneNoList.add(phoneNumber); } return phoneNoList; }
/** * Initializes an ExtensionProfile based upon the extensions expected * by an ContactEntry. */ @Override public void declareExtensions(ExtensionProfile extProfile) { extProfile.declare(ContactEntry.class, Email.getDefaultDescription()); extProfile.declare(ContactEntry.class, Im.getDefaultDescription(false, true)); extProfile.declare(ContactEntry.class, PhoneNumber.getDefaultDescription()); extProfile.declare(ContactEntry.class, PostalAddress.getDefaultDescription()); extProfile.declare(ContactEntry.class, Organization.getDefaultDescription(false, false)); extProfile.declare(ContactEntry.class, GeoPt.getDefaultDescription()); extProfile.declare(ContactEntry.class, Deleted.class); }
/** * Positive test case for createContact method with optional parameters. */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {createContact} integration test with optional parameters.") public void testUpdateContactWithOptionalParameters() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("contactId", contactId); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_updateContact_optional.xml", parametersMap); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); String updatedContactId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); ContactEntry directResponseObject = directInvoker.retrieveSingleContact(updatedContactId); Assert.assertEquals(idUrl, directResponseObject.getId()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:phoneNumber/text())", nameSpaceMap), directResponseObject .getPhoneNumbers().get(0).getPhoneNumber()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:email/@address)", nameSpaceMap), directResponseObject .getEmailAddresses().get(0).getAddress()); }
/** * Initializes an ExtensionProfile based upon the extensions expected * by an ContactEntry. */ @Override public void declareExtensions(ExtensionProfile extProfile) { extProfile.declare(ContactEntry.class, Email.getDefaultDescription()); extProfile.declare(ContactEntry.class, Im.getDefaultDescription(false, true)); extProfile.declare(ContactEntry.class, PhoneNumber.getDefaultDescription()); extProfile.declare(ContactEntry.class, PostalAddress.getDefaultDescription()); extProfile.declare(ContactEntry.class, Organization.getDefaultDescription(false, false)); extProfile.declare(ContactEntry.class, GeoPt.getDefaultDescription()); extProfile.declare(ContactEntry.class, Deleted.class); }
/** * Initializes an ExtensionProfile based upon the extensions expected * by an ContactEntry. */ @Override public void declareExtensions(ExtensionProfile extProfile) { extProfile.declare(ContactEntry.class, Email.getDefaultDescription()); extProfile.declare(ContactEntry.class, Im.getDefaultDescription(false, true)); extProfile.declare(ContactEntry.class, PhoneNumber.getDefaultDescription()); extProfile.declare(ContactEntry.class, PostalAddress.getDefaultDescription()); extProfile.declare(ContactEntry.class, Organization.getDefaultDescription(false, false)); extProfile.declare(ContactEntry.class, GeoPt.getDefaultDescription()); extProfile.declare(ContactEntry.class, Deleted.class); }