/** * Positive test case for RetrieveContactGroupsByQuery method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 2, groups = { "wso2.esb" }, description = "Google Contacts {retrieveContactGroupsByQuery} integration test with mandatory parameters.") public void testRetrieveContactGroupsByQueryWithMandatoryParameters() throws Exception { Query contactQuery = new Query(new URL("https://www.google.com/m8/feeds/groups/default/full")); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveContactGroupsByQuery_mandatory.xml"); ContactGroupFeed feed = directInvoker.getDirectInvokerContactsService().query(contactQuery, ContactGroupFeed.class); // Assert Total Results. Assert.assertEquals(Integer.parseInt((String) xPathEvaluate(esbSoapResponse.getBody() .getFirstElement(), "string(//openSearch:totalResults/text())", nameSpaceMap)), feed.getTotalResults()); }
/** * 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)); }
/** * Positive test case for RetrieveContactGroupsByQuery method with optional parameters. * * @throws Exception the exception */ @Test(priority = 2, groups = { "wso2.esb" }, description = "Google Contacts {retrieveContactGroupsByQuery} integration test with optional parameters.") public void testRetrieveContactGroupsByQueryWithOptionalParameters() throws Exception { final Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("reqUrl", "https://www.google.com/m8/feeds/groups/default/full"); Query contactQuery = (Query) loadObjectFromFile("api_retrieveContactGroupsByQuery_optional.xml", parametersMap); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveContactGroupsByQuery_optional.xml", parametersMap); ContactGroupFeed feed = directInvoker.getDirectInvokerContactsService().query(contactQuery, ContactGroupFeed.class); // Assert Total Results. Assert.assertEquals(Integer.parseInt((String) xPathEvaluate(esbSoapResponse.getBody() .getFirstElement(), "string(//openSearch:totalResults/text())", nameSpaceMap)), feed.getTotalResults()); // Assert Items Per Page. Assert.assertEquals(Integer.parseInt((String) xPathEvaluate(esbSoapResponse.getBody() .getFirstElement(), "string(//openSearch:itemsPerPage/text())", nameSpaceMap)), feed.getItemsPerPage()); // Assert Start Index. Assert.assertEquals( Integer.parseInt((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//openSearch:startIndex/text())", nameSpaceMap)), feed.getStartIndex()); }