@Override public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { ArrayList<XmlWriter.Attribute> attrs = new ArrayList<XmlWriter.Attribute>(); if (rel != null) { attrs.add(new XmlWriter.Attribute("rel", rel)); } if (label != null) { attrs.add(new XmlWriter.Attribute("label", label)); } if (address != null) { attrs.add(new XmlWriter.Attribute("address", address)); } if (quota != null) { attrs.add(new XmlWriter.Attribute("quota", quota)); } if (primary) { attrs.add(new XmlWriter.Attribute("primary", true)); } if (displayName != null) { attrs.add(new XmlWriter.Attribute("displayName", displayName)); } generateStartElement(w, Namespaces.gNs, "email", attrs, null); // Invoke ExtensionPoint. generateExtensions(w, extProfile); w.endElement(Namespaces.gNs, "email"); }
/** * Returns a list containing Email GData extension objects. This method takes a formatted OM Element and * converts it to a list of email objects. * * @param emailElement The parent element containing the individual elements containing email details. * @return a list containing GData extension Email objects. */ protected final List<Email> getEmailList(final OMElement emailElement) { List<Email> emailList = new ArrayList<Email>(); Iterator< ? > emailChildrenItearator = emailElement.getChildElements(); while (emailChildrenItearator.hasNext()) { OMElement singleEmailElement = (OMElement) emailChildrenItearator.next(); Email email = new Email(); email.setAddress(singleEmailElement.getText()); email.setRel(Constants.REL_OPEN + singleEmailElement.getLocalName()); if (singleEmailElement.getAttributeValue(new QName(Constants.PRIMARY)) != null) { email.setPrimary(Boolean.parseBoolean(singleEmailElement .getAttributeValue(new QName(Constants.PRIMARY)))); } emailList.add(email); } return emailList; }
/** Declares extensions used in this entry. */ @Override public void declareExtensions(ExtensionProfile extProfile) { extProfile.declare(FriendEntry.class, YtStatus.class); extProfile.declare(FriendEntry.class, YtUsername.class); ExtensionDescription emailExtension = Email.getDefaultDescription(); emailExtension.setRepeatable(false); extProfile.declare(FriendEntry.class, emailExtension); extProfile.declareAdditionalNamespace(Namespaces.gNs); extProfile.declareArbitraryXmlExtension(FriendEntry.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()); }
/** Declares extensions used in this entry. */ @Override public void declareExtensions(ExtensionProfile extProfile) { extProfile.declare(FriendEntry.class, YtStatus.class); extProfile.declare(FriendEntry.class, YtUsername.class); ExtensionDescription emailExtension = Email.getDefaultDescription(); emailExtension.setRepeatable(false); extProfile.declare(FriendEntry.class, emailExtension); extProfile.declareAdditionalNamespace(Namespaces.gNs); extProfile.declareArbitraryXmlExtension(FriendEntry.class); } }
/** * Positive test case for retrieveSingleContact method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {retrieveSingleContact} integration test with mandatory parameters.") public void testRetrieveSingleContactWithMandatoryParameters() throws Exception { final Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("contactId", contactId); final SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveSingleContact_mandatory.xml", parametersMap); final ContactEntry directResponse = directInvoker.retrieveSingleContact(contactId); // Assert contact email. Assert.assertEquals( (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//gd:email/@address)", nameSpaceMap), directResponse.getEmailAddresses().get(0).getAddress()); // Assert the contact's title. Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap), directResponse.getTitle().getPlainText()); }
@Override public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { ArrayList<XmlWriter.Attribute> attrs = new ArrayList<XmlWriter.Attribute>(); if (rel != null) { attrs.add(new XmlWriter.Attribute("rel", rel)); } if (label != null) { attrs.add(new XmlWriter.Attribute("label", label)); } if (address != null) { attrs.add(new XmlWriter.Attribute("address", address)); } if (quota != null) { attrs.add(new XmlWriter.Attribute("quota", quota)); } if (primary) { attrs.add(new XmlWriter.Attribute("primary", true)); } if (displayName != null) { attrs.add(new XmlWriter.Attribute("displayName", displayName)); } generateStartElement(w, Namespaces.gNs, "email", attrs, null); // Invoke ExtensionPoint. generateExtensions(w, extProfile); w.endElement(Namespaces.gNs, "email"); }
/** * Initializes an ExtensionProfile based upon the extensions expected * by a MailItemEntry. */ @Override public void declareExtensions(ExtensionProfile extProfile) { super.declareExtensions(extProfile); extProfile.declare(MailItemEntry.class, Email.getDefaultDescription()); extProfile.declare(MailItemEntry.class, Label.getDefaultDescription()); extProfile.declare(MailItemEntry.class, MailItemProperty.getDefaultDescription()); extProfile.declare(MailItemEntry.class, Rfc822Msg.getDefaultDescription()); }
directResponseRead.getEmailAddresses().get(0).getAddress());
@Override public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { ArrayList<XmlWriter.Attribute> attrs = new ArrayList<XmlWriter.Attribute>(); if (rel != null) { attrs.add(new XmlWriter.Attribute("rel", rel)); } if (label != null) { attrs.add(new XmlWriter.Attribute("label", label)); } if (address != null) { attrs.add(new XmlWriter.Attribute("address", address)); } if (quota != null) { attrs.add(new XmlWriter.Attribute("quota", quota)); } if (primary) { attrs.add(new XmlWriter.Attribute("primary", true)); } if (displayName != null) { attrs.add(new XmlWriter.Attribute("displayName", displayName)); } generateStartElement(w, Namespaces.gNs, "email", attrs, null); // Invoke ExtensionPoint. generateExtensions(w, extProfile); w.endElement(Namespaces.gNs, "email"); }
/** * 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); }
/** * 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); }