/** * 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)); }
/** * 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 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)); }