/** * Positive test case for createContact method with mandatory parameters. */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {createContact} integration test with mandatory parameters.") public void testCreateContactWithMandatoryParameters() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_createContact_mandatory.xml"); Assert.assertTrue(esbSoapResponse.getBody().toString().contains("atom:id")); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); batchDeleteContactId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); ContactEntry directResponseObject = directInvoker.retrieveSingleContact(batchDeleteContactId); Assert.assertEquals(idUrl, directResponseObject.getId()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:fullName/text())", nameSpaceMap), directResponseObject .getName().getFullName().getValue()); }
/** * Positive test case for createContact method with mandatory parameters. */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {updateContact} integration test with mandatory parameters.") public void testUpdateContactWithMandatoryParameters() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("contactId", contactId); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_updateContact_mandatory.xml", parametersMap); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); String updatedContactId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); ContactEntry directResponseObject = directInvoker.retrieveSingleContact(updatedContactId); Assert.assertEquals(idUrl, directResponseObject.getId()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:fullName/text())", nameSpaceMap), directResponseObject .getName().getFullName().getValue()); }
/** * Positive test case for createContact method with optional parameters. */ @Test(priority = 2, groups = { "wso2.esb" }, dependsOnMethods = { "testCreateContactWithOptionalParameters" }, description = "Google Contacts {createContact} integration test with optional parameters.") public void testUpdateContactWithOptionalParameters() throws Exception { Map<String, String> parametersMap = new HashMap<String, String>(); parametersMap.put("contactId", contactId); SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_updateContact_optional.xml", parametersMap); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); String updatedContactId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); // Adding a sleep timer to buffer time taken to apply changes on backend. Thread.sleep(Long.parseLong(connectorProperties.getProperty("timeDelay"))); ContactEntry directResponseObject = directInvoker.retrieveSingleContact(updatedContactId); Assert.assertEquals(idUrl, directResponseObject.getId()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:phoneNumber/text())", nameSpaceMap), directResponseObject .getPhoneNumbers().get(0).getPhoneNumber()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:email/@address)", nameSpaceMap), directResponseObject .getEmailAddresses().get(0).getAddress()); }
/** * Positive test case for createContact method with optional parameters. */ @Test(priority = 1, groups = { "wso2.esb" }, description = "Google Contacts {createContact} integration test with optional parameters.") public void testCreateContactWithOptionalParameters() throws Exception { SOAPEnvelope esbSoapResponse = sendSOAPRequest(proxyUrl, "esb_createContact_optional.xml"); Assert.assertTrue(esbSoapResponse.getBody().toString().contains("atom:id")); String xPathExp = "string(//atom:id/text())"; String idUrl = (String) xPathEvaluate(esbSoapResponse, xPathExp, nameSpaceMap); contactId = idUrl.substring(idUrl.lastIndexOf("/") + 1, idUrl.length()); ContactEntry directResponseObject = directInvoker.retrieveSingleContact(contactId); Assert.assertEquals(idUrl, directResponseObject.getId()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gd:givenName/text())", nameSpaceMap), directResponseObject .getName().getGivenName().getValue()); Assert.assertEquals((String) xPathEvaluate(esbSoapResponse, "string(//gContact:birthday/@when)", nameSpaceMap), directResponseObject .getBirthday().getValue()); }