/** * Default mutable constructor. */ public ContactFeed() { super(ContactEntry.class); getCategories().add(ContactEntry.CATEGORY); }
/** * Declare the extensions of the feeds for the Google Contacts service. */ private void declareExtensions() { new ContactFeed().declareExtensions(extProfile); new ContactGroupFeed().declareExtensions(extProfile); new ProfileFeed().declareExtensions(extProfile); BatchUtils.declareExtensions(extProfile); }
throws ValidationException, XMLStreamException, ParseException { final ContactFeed requestFeed = new ContactFeed(); requestFeed.getEntries().add(getRetrieveContact(messageContext, batchEntry)); } else if (Constants.INSERT.equals(entryType)) { requestFeed.getEntries().add(getCreateContact(batchEntry)); } else if (Constants.UPDATE.equals(entryType)) { requestFeed.getEntries().add(getUpdateContact(messageContext, batchEntry)); } else if (Constants.DELETE.equals(entryType)) { requestFeed.getEntries().add(getDeleteContact(messageContext, batchEntry)); } else { throw new ValidationException("Invalid batch operation type.");
/** * Positive test case for retrieveAllContacts method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {retrieveAllContacts} integration test with mandatory parameters.") public void testRetrieveAllContactsWithMandatoryParameters() throws Exception { final SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveAllContacts_mandatory.xml"); final ContactFeed directResponse = directInvoker.retrieveAllContacts(); // Assert id Assert.assertEquals(directResponse.getEntries().get(0).getName().getFullName().getValue(), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//gd:fullName/text())", nameSpaceMap)); // Assert title Assert.assertEquals(directResponse.getTitle().getPlainText(), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap)); // Assert totalResults Assert.assertEquals(String.valueOf(directResponse.getTotalResults()), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//openSearch:totalResults/text())", nameSpaceMap)); }
/** * Positive test case for retrieveContactsByQuery method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {retrieveContactsByQuery} method {mandatory parameters} Integration Tests") public void testRetrieveContactsByQueryMandatoryParameters() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveContactsByQuery_mandatory.xml"); ContactFeed contactFeed = directInvoker.retrieveAllContacts(); Assert.assertEquals(String.valueOf(contactFeed.getTotalResults()), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//openSearch:totalResults/text())", nameSpaceMap)); Assert.assertEquals( contactFeed.getEntries().get(contactFeed.getEntries().size() - 1).getTitle().getPlainText(), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:entry[last()]/atom:title/text())", nameSpaceMap)); }
/** * Positive test case for retrieveContactsByQuery method with Optional parameters. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {retrieveContactsByQuery} method {Optional parameters} Integration Tests") public void testRetrieveContactsByQueryOptionalParameters() throws Exception { Map<String, String> paramMap = new HashMap<String, String>(); paramMap.put("requestUrl", "https://www.google.com/m8/feeds/contacts/default/full"); Query query = (Query) loadObjectFromFile("api_retrieveContactsByQuery_optional.xml", paramMap); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveContactsByQuery_optional.xml", paramMap); ContactFeed contactFeed = directInvoker.getDirectInvokerContactsService().query(query, ContactFeed.class); Assert.assertEquals(String.valueOf(contactFeed.getTotalResults()), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//openSearch:totalResults/text())", nameSpaceMap)); Assert.assertEquals(String.valueOf(contactFeed.getStartIndex()), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//openSearch:startIndex/text())", nameSpaceMap)); }
/** * Negative test case for batchCreateContacts method. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {batchCreateContacts} integration test with negative case.") public void testBatchCreateContactsWithNegativeCase() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_batchCreateContacts_negative.xml"); final ContactFeed directResponse = directInvoker.retrieveBatchContactFeed("aaddd3324dd"); // Assert for the Error result. Assert.assertEquals( (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:entry[batch:id = 'retrieveEntry']/atom:title/text())", nameSpaceMap), directResponse.getEntries().get(0).getTitle().getPlainText()); // Assert for the error response code. Assert.assertEquals( (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:entry[batch:id = 'retrieveEntry']/batch:status/@code)", nameSpaceMap), Integer.toString(directResponse.getEntries().get(0).getBatchStatus().getCode())); }
/** * Declare the extensions of the feeds for the Google Contacts service. */ private void declareExtensions() { new ContactFeed().declareExtensions(extProfile); new ContactGroupFeed().declareExtensions(extProfile); new ProfileFeed().declareExtensions(extProfile); BatchUtils.declareExtensions(extProfile); }
/** * Create a contacts batch result for negative case. * * @param contactId ID of the contact. * @return ContactFeed object containing the batch. * @throws ServiceException the service exception. * @throws IOException Signals that an I/O exception has occurred. * @throws MalformedURLException error in the provided URLs. * @throws BatchInterruptedException Batch Interruption failure exception. */ public ContactFeed retrieveBatchContactFeed(final String contactId) throws BatchInterruptedException, MalformedURLException, IOException, ServiceException { final ContactFeed batchFeed = new ContactFeed(); final ContactEntry retrieveEntry = new ContactEntry(); final StringBuilder requestUrlBuilder = new StringBuilder("https://www.google.com/m8/feeds/contacts/").append(emailAddress) .append("/full/").append(contactId); retrieveEntry.setId(requestUrlBuilder.toString()); BatchUtils.setBatchId(retrieveEntry, "retrieveEntry"); BatchUtils.setBatchOperationType(retrieveEntry, BatchOperationType.QUERY); batchFeed.getEntries().add(retrieveEntry); return directInvokerContactsService.batch(new URL( "https://www.google.com/m8/feeds/contacts/default/full/batch"), batchFeed); }
/** * Declare the extensions of the feeds for the Google Contacts service. */ private void declareExtensions() { new ContactFeed().declareExtensions(extProfile); new ContactGroupFeed().declareExtensions(extProfile); new ProfileFeed().declareExtensions(extProfile); BatchUtils.declareExtensions(extProfile); }
/** * Default mutable constructor. */ public ContactFeed() { super(ContactEntry.class); getCategories().add(ContactEntry.CATEGORY); }
/** * Default mutable constructor. */ public ContactFeed() { super(ContactEntry.class); getCategories().add(ContactEntry.CATEGORY); }