/** * Positive test case for updateContactGroup method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactGroupWithMandatoryParameters" }, description = "Google Contacts {updateContactGroup} integration test with mandatory parameters.") public void testUpdateContactGroupWithMandatoryParameters() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("groupId", groupId); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_updateContactGroup_mandatory.xml", parametersMap); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); final ContactGroupEntry directResponse = directInvoker.retrieveSingleContactGroup(groupId); // Assert the group title. Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap), directResponse.getTitle().getPlainText()); // Assert the group's content. Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:content/text())", nameSpaceMap), directResponse.getPlainTextContent()); }
/** * 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 createContactGroup method with optional parameters. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {createContactGroup} integration test with optional parameters.") public void testCreateContactGroupWithOptionalParameters() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_createContactGroup_optional.xml"); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); batchDeleteGroupId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); final ContactGroupEntry directResponse = directInvoker.retrieveSingleContactGroupByUrl((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:link/@href)", nameSpaceMap)); // Assert the group title. Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap), directResponse.getTitle().getPlainText()); // Assert the value of the extended property. Assert.assertEquals( (String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//gd:extendedProperty/@value)", nameSpaceMap), directResponse.getExtendedProperties().get(0).getValue()); }
/** * Positive test case for createContactGroup method with mandatory parameters. * * @throws Exception the exception */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {createContactGroup} integration test with mandatory parameters.") public void testCreateContactGroupWithMandatoryParameters() throws Exception { final SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_createContactGroup_mandatory.xml"); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); groupId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); final ContactGroupEntry directResponse = directInvoker.retrieveSingleContactGroupByUrl((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:id/text())", nameSpaceMap)); // Assert the group title. Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap), directResponse.getTitle().getPlainText()); // Assert the group's content. Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:content/text())", nameSpaceMap), directResponse.getPlainTextContent()); }
/** * 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())); }
/** * Positive test case for RetrieveSingleContactGroup method with mandatory parameters. */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactGroupWithMandatoryParameters" }, description = "Google Contacts {retrieveSingleContactGroup integration test with mandatory parameters.") public void testRetrieveSingleContactGroup() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("groupId", groupId); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_retrieveSingleContactGroup_mandatory.xml", parametersMap); ContactGroupEntry directResponse = (ContactGroupEntry) directInvoker.retrieveSingleContactGroup(groupId); // Assert id Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:id/text())", nameSpaceMap), directResponse.getId()); // Assert title Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:title/text())", nameSpaceMap), directResponse.getTitle().getPlainText()); // Assert content Assert.assertEquals((String) xPathEvaluate(esbSoapResponse.getBody().getFirstElement(), "string(//atom:content/text())", nameSpaceMap), ((TextContent) directResponse.getContent()).getContent().getPlainText()); }