/** * Adds a new group membership info. * * @param groupMembershipInfo group membership info */ public void addGroupMembershipInfo(GroupMembershipInfo groupMembershipInfo) { getGroupMembershipInfos().add(groupMembershipInfo); }
/** * Default mutable constructor. */ public ContactEntry() { super(); getCategories().add(CATEGORY); }
/** * Returns the marker for deleted entries. * * @return marker for deleted entries */ public Deleted getDeleted() { return getExtension(Deleted.class); }
/** * Sets the marker for deleted entries. * * @param deleted marker for deleted entries or <code>null</code> to reset */ public void setDeleted(Deleted deleted) { if (deleted == null) { removeExtension(Deleted.class); } else { setExtension(deleted); } }
SimpleDateFormat dateFormatter = new SimpleDateFormat(Constants.DATE_FORMAT); dateFormatter.parse(birthdayValue); entryToUpdate.setBirthday(new Birthday(birthdayValue)); entryToUpdate.setName(name); entryToUpdate.setNickname(new Nickname(tempElementString)); entryToUpdate.setFileAs(new FileAs(tempElementString)); entryToUpdate.getEmailAddresses().clear(); if (!tempElementString.isEmpty()) { OMElement emailElement = AXIOMUtil.stringToOM(tempElementString); List<Email> emailList = getEmailList(emailElement); for (Email emailAddress : emailList) { entryToUpdate.addEmailAddress(emailAddress); entryToUpdate.getPhoneNumbers().clear(); if (!tempElementString.isEmpty()) { OMElement phoneNumberElement = AXIOMUtil.stringToOM(tempElementString); List<PhoneNumber> phoneNumberList = getPhoneNumberList(phoneNumberElement); for (PhoneNumber phoneNo : phoneNumberList) { entryToUpdate.addPhoneNumber(phoneNo); entryToUpdate.getImAddresses().clear(); if (!tempElementString.isEmpty()) { List<Im> imList = getIMList(iMElement); for (Im im : imList) {
for (int i = 0; i < resultFeed.getEntries().size(); i++) { ContactEntry entry = resultFeed.getEntries().get(i); System.out.println("\t" + entry.getTitle().getPlainText()); for (Email email : entry.getEmailAddresses()) { System.out.print(" " + email.getAddress()); if (email.getRel() != null) { for (Im im : entry.getImAddresses()) { System.out.print(" " + im.getAddress()); if (im.getLabel() != null) { for (GroupMembershipInfo group : entry.getGroupMembershipInfos()) { String groupHref = group.getHref(); System.out.println(" Id: " + groupHref); for (ExtendedProperty property : entry.getExtendedProperties()) { if (property.getValue() != null) { System.out.println(" " + property.getName() + "(value) = " + String photoLink = entry.getContactPhotoLink().getHref(); System.out.println("Photo Link: " + photoLink); System.out.println("Contact's ETag: " + entry.getEtag());
/** * Positive test case for changeGroupMembership method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {changeGroupMembers} integration test with mandatory parameters.") public void testChangeGroupMembershipWithMandatoryParameters() throws Exception { final Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("contactId", contactId); final SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_changeGroupMembership_mandatory.xml", parametersMap); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); ContactEntry directResponse = directInvoker.retrieveSingleContact(contactId); final int apiResponseSize = directResponse.getGroupMembershipInfos().size(); final String directApiResponseHref = directResponse.getGroupMembershipInfos().get(apiResponseSize - 1).getHref(); final int esbResponseSize = Integer.parseInt((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(count(//atom:groupMembershipInfo))", nameSpaceMap)); final String directEsbResponseHref = (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:groupMembershipInfo[" + esbResponseSize + "]/@href)", nameSpaceMap); // Assert title Assert.assertEquals(directResponse.getTitle().getPlainText(), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap)); // Assert Checking whether both responses href are identical Assert.assertEquals(directApiResponseHref, directEsbResponseHref); }
/** * 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()); }
directResponseCreate.getTitle().getPlainText()); directResponseCreate.getPlainTextContent()); directResponseRead.getTitle().getPlainText()); directResponseRead.getEmailAddresses().get(0).getAddress()); directResponseUpdate.getTitle().getPlainText()); directResponseUpdate.getPlainTextContent());
/** * 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()); }
/** * Returns whether it has the marker for deleted entries. * * @return whether it has the marker for deleted entries */ public boolean hasDeleted() { return hasExtension(Deleted.class); }
/** * Returns whether it has the group membership infos. * * @return whether it has the group membership infos */ public boolean hasGroupMembershipInfos() { return hasRepeatingExtension(GroupMembershipInfo.class); }
/** * Returns the group membership infos. * * @return group membership infos */ public List<GroupMembershipInfo> getGroupMembershipInfos() { return getRepeatingExtension(GroupMembershipInfo.class); }
/** * Positive test case for updateContactPhoto method with mandatory parameters. */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {updateContactPhoto} integration test with mandatory parameters.") public void testUpdateContactPhotoWithMandatoryParameters() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); Map<String, String> attachmentMap = new HashMap<String, String>(); attachmentMap.put("photo", "updateContactPhoto_image.png"); parametersMap.put("contactId", contactId); sendSOAPRequest(proxyUrl, "esb_updateContactPhoto_mandatory.xml", parametersMap, attachmentMap); ContactEntry directResponseObject = directInvoker.retrieveSingleContact(contactId); Assert.assertTrue(directResponseObject.getContactPhotoLink() != null); }
contactEntry.setEtag(Constants.ETAG); final Link photoLink = contactEntry.getContactPhotoLink(); final URL photoUrl = new URL(photoLink.getHref());
/** * Sets the marker for deleted entries. * * @param deleted marker for deleted entries or <code>null</code> to reset */ public void setDeleted(Deleted deleted) { if (deleted == null) { removeExtension(Deleted.class); } else { setExtension(deleted); } }
/** * Returns whether it has the marker for deleted entries. * * @return whether it has the marker for deleted entries */ public boolean hasDeleted() { return hasExtension(Deleted.class); }
/** * Returns whether it has the group membership infos. * * @return whether it has the group membership infos */ public boolean hasGroupMembershipInfos() { return hasRepeatingExtension(GroupMembershipInfo.class); }
/** * Returns the group membership infos. * * @return group membership infos */ public List<GroupMembershipInfo> getGroupMembershipInfos() { return getRepeatingExtension(GroupMembershipInfo.class); }
/** * Positive test case for deleteContactPhoto method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {deleteContactPhoto} method {mandatory parameters} Integration Tests") public void testDeleteContactPhotoMandatoryParameters() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("contactId", contactId); // Delete a contact photo for given contact id through a esb call. sendSOAPRequest(proxyUrl, "esb_deleteContactPhoto_mandatory.xml", parametersMap); Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); // Get the contact entry which contact photo was deleted by direct api call. ContactEntry contactEntry = directInvoker.retrieveSingleContact(contactId); // Assert with retrieved contact photo link's etag attribute is not available. // If a contact does not have a photo, then the photo link element has no gd:etag. Assert.assertNull(contactEntry.getContactPhotoLink().getEtag()); }