for (int i = 0; i < resultFeed.getEntries().size(); i++) { ContactEntry entry = resultFeed.getEntries().get(i); System.out.println("\t" + entry.getTitle().getPlainText());
/** * 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 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()); }
/** * 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); }
/** * 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())); }