requestFeed.getEntries().add(retreiveContactGroup(messageContext, entryElement)); } else if (Constants.INSERT.equals(entryType)) { requestFeed.getEntries().add(createContactGroup(entryElement)); } else if (Constants.UPDATE.equals(entryType)) { requestFeed.getEntries().add(updateContactGroup(messageContext, entryElement)); } else if (Constants.DELETE.equals(entryType)) { requestFeed.getEntries().add(deleteContactGroup(messageContext, entryElement)); } else { throw new ValidationException("Batch operation type is not found");
/** * Positive test case for retrieveAllContactGroups method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {retrieveAllContactGroups} method {mandatory parameters} Integration Tests") public void testRetrieveAllContactGroupsMandatoryParameters() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveAllContactGroups_mandatory.xml"); ContactGroupFeed groupFeed = directInvoker.retrieveAllContactGroups(); Assert.assertEquals(String.valueOf(groupFeed.getTotalResults()), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//openSearch:totalResults/text())", nameSpaceMap)); Assert.assertEquals(groupFeed.getEntries().get(groupFeed.getEntries().size() - 1).getTitle().getPlainText(), (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:entry[last()]/atom:title/text())", nameSpaceMap)); }
/** * Negative test case for batch create contacts group scenario. * * @throws Exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {batchCreateContactGroups} method {negative scenario} Integration Tests") public void testBatchCreateContactGroupsNegativeScenario() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_batchCreateContactGroups_negative.xml"); final ContactGroupFeed directResponse = directInvoker.retrieveBatchContactGroupFeed("aaddd3324dd"); // Assert for the Error result. Assert.assertEquals( (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:entry[batch:id = 'retrieve']/atom:title/text())", nameSpaceMap), directResponse.getEntries().get(0).getTitle().getPlainText()); // Assert for the error response code. Assert.assertEquals( (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//batch:status/@code)", nameSpaceMap), Integer.toString(directResponse.getEntries().get(0).getBatchStatus().getCode())); }
/** * Create a contacts groups batch result for negative case. * * @param groupId ID of the contact group. * @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 ContactGroupFeed retrieveBatchContactGroupFeed(final String groupId) throws BatchInterruptedException, MalformedURLException, IOException, ServiceException { final ContactGroupFeed batchFeed = new ContactGroupFeed(); final ContactGroupEntry retrieveEntry = new ContactGroupEntry(); final StringBuilder requestUrlBuilder = new StringBuilder("https://www.google.com/m8/feeds/groups/").append(emailAddress).append("/full/") .append(groupId); retrieveEntry.setId(requestUrlBuilder.toString()); BatchUtils.setBatchId(retrieveEntry, "retrieve"); BatchUtils.setBatchOperationType(retrieveEntry, BatchOperationType.QUERY); batchFeed.getEntries().add(retrieveEntry); return directInvokerContactsService.batch(new URL( "https://www.google.com/m8/feeds/groups/default/full/batch"), batchFeed); } }