List of usage examples for org.json JSONObject getString
public String getString(String key) throws JSONException
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listGoals method with mandatory parameters. * * @throws org.json.JSONException//from w ww .j ava 2 s .c om * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listGoals} integration test with mandatory parameters.") public void testListGoalsWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listGoals"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listGoals_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("profileId") + "/goals"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listGoals method with optional parameters. * * @throws org.json.JSONException/*from w w w . j a va2 s .co m*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listGoals} integration test with optional parameters.") public void testListGoalsWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listGoals"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listGoals_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("profileId") + "/goals?fields=kind,itemsPerPage"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for getGoals method with mandatory parameters. * * @throws org.json.JSONException// ww w .ja v a 2 s . c om * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {getGoals} integration test with mandatory parameters.") public void testGetGoalsWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:getGoals"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_getGoals_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("profileId") + "/goals/" + connectorProperties.getProperty("goalId"); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for getGoals method with optional parameters. * * @throws org.json.JSONException/* w w w . jav a2 s . c o m*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {getGoals} integration test with optional parameters.") public void testGetGoalsWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:getGoals"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_getGoals_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("profileId") + "/goals/" + connectorProperties.getProperty("goalId") + "?fields=accountId"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("accountId"), apiResponse.getString("accountId")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for getWebProperties method with mandatory parameters. * * @throws org.json.JSONException/* w w w. j av a 2 s . com*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {getWebProperties} integration test with mandatory parameters.") public void testGetWebPropertiesWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:getWebProperties"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_getWebProperties_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId"); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for getWebProperties method with optional parameters. * * @throws org.json.JSONException/*from ww w . ja va 2s .c o m*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {getWebProperties} integration test with optional parameters.") public void testGetWebPropertiesWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:getWebProperties"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_getWebProperties_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "?fields=kind,name"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); Assert.assertEquals(esbResponse.getString("name"), apiResponse.getString("name")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listWebProperties method with mandatory parameters. * * @throws org.json.JSONException//ww w .java 2s.c om * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listWebProperties} integration test with mandatory parameters.") public void testListWebPropertiesWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listWebProperties"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listWebProperties_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listWebProperties method with optional parameters. * * @throws org.json.JSONException/*from w w w . j a v a 2 s. c om*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listWebProperties} integration test with optional parameters.") public void testListWebPropertiesWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listWebProperties"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listWebProperties_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties?max-results=" + connectorProperties.getProperty("maxResults"); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("totalResults"), apiResponse.getString("totalResults")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listWebPropertyUserLinks method with mandatory parameters. * * @throws org.json.JSONException//from w w w. j a va 2s . co m * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listWebPropertyUserLinks} integration test with mandatory parameters.") public void testListWebPropertiesUserLinksWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listWebPropertyUserLinks"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listWebPropertyUserLinks_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/entityUserLinks"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listWebPropertyUserLinks method with optional parameters. * * @throws org.json.JSONException/*from ww w .j a v a2 s . c om*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listWebPropertyUserLinks} integration test with optional parameters.") public void testListWebPropertiesUserLinksWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listWebPropertyUserLinks"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listWebPropertyUserLinks_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/entityUserLinks?max-results=" + connectorProperties.getProperty("maxResults"); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), apiRestResponse.getHttpStatusCode()); Assert.assertEquals(esbResponse.getString("totalResults"), apiResponse.getString("totalResults")); }