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 updateExperiment method with optional parameters. * * @throws org.json.JSONException/*from w w w .j av a 2 s.c o m*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {updateExperiment} integration test with optional parameters.", dependsOnMethods = { "testCreateExperimentWithMandatoryParameters" }) public void testUpdateExperimentWithOptionalParameters() throws IOException, JSONException { final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("experimentProfileId") + "/experiments/" + connectorProperties.getProperty("experimentId"); RestResponse<JSONObject> apiRestResponseBefore = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponseBefore = apiRestResponseBefore.getBody(); esbRequestHeadersMap.put("Action", "urn:updateExperiment"); sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_updateExperiment_optional.json"); RestResponse<JSONObject> apiRestResponseAfter = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponseAfter = apiRestResponseAfter.getBody(); Assert.assertNotEquals(apiResponseBefore.getString("editableInGaUi"), apiResponseAfter.getString("editableInGaUi")); Assert.assertEquals(connectorProperties.getProperty("experimentUpdatedDescription"), apiResponseAfter.getString("description")); Assert.assertEquals(connectorProperties.getProperty("experimentUpdatedEditableInGaUi"), apiResponseAfter.getString("editableInGaUi")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for patchExperiment method with optional parameters. * * @throws org.json.JSONException/* w w w . ja va 2s .com*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {patchExperiment} integration test with optional parameters.", dependsOnMethods = { "testCreateExperimentWithOptionalParameters" }) public void testPatchExperimentWithOptionalParameters() throws IOException, JSONException { final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("experimentProfileId") + "/experiments/" + connectorProperties.getProperty("experimentIdOptional"); RestResponse<JSONObject> apiRestResponseBefore = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponseBefore = apiRestResponseBefore.getBody(); esbRequestHeadersMap.put("Action", "urn:patchExperiment"); sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_patchExperiment_optional.json"); RestResponse<JSONObject> apiRestResponseAfter = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponseAfter = apiRestResponseAfter.getBody(); Assert.assertNotEquals(apiResponseBefore.getString("name"), apiResponseAfter.getString("name")); Assert.assertNotEquals(apiResponseBefore.getString("status"), apiResponseAfter.getString("status")); Assert.assertEquals(connectorProperties.getProperty("experimentUpdatedName"), apiResponseAfter.getString("name")); Assert.assertEquals(connectorProperties.getProperty("experimentUpdatedStatus"), apiResponseAfter.getString("status")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listMultiChannelFunnelsReportData method with mandatory parameters. * * @throws org.json.JSONException/*from w ww . j av a 2 s . c o m*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listMultiChannelFunnelsReportData} integration test with mandatory parameters.", dependsOnMethods = { "testListAccountSummariesWithMandatoryParameters" }) public void testListMultiChannelFunnelReportDataWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listMultiChannelFunnelsReportData"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listMultiChannelFunnelData_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/data/mcf?ids=" + connectorProperties.getProperty("multiChannelIds") + "&start-date=" + connectorProperties.getProperty("multiChannelStartDate") + "&end-date=" + connectorProperties.getProperty("multiChannelEndDate") + "&metrics=" + connectorProperties.getProperty("multiChannelMetrics"); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); Assert.assertEquals(esbResponse.getJSONObject("query").getString("start-date"), apiResponse.getJSONObject("query").getString("start-date")); Assert.assertEquals(esbResponse.getJSONObject("query").getString("end-date"), apiResponse.getJSONObject("query").getString("end-date")); Assert.assertEquals(esbResponse.getString("itemsPerPage"), apiResponse.getString("itemsPerPage")); Assert.assertEquals(esbResponse.getString("totalResults"), apiResponse.getString("totalResults")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listMultiChannelFunnelsReportData method with optional parameters. * * @throws org.json.JSONException/*from w w w . j a v a2 s . c om*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listMultiChannelFunnelsReportData} integration test with optional parameters.", dependsOnMethods = { "testListAccountSummariesWithMandatoryParameters" }) public void testListMultiChannelFunnelReportDataWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listMultiChannelFunnelsReportData"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listMultiChannelFunnelData_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/data/mcf?ids=" + connectorProperties.getProperty("multiChannelIds") + "&start-date=" + connectorProperties.getProperty("multiChannelStartDate") + "&end-date=" + connectorProperties.getProperty("multiChannelEndDate") + "&metrics=" + connectorProperties.getProperty("multiChannelMetrics") + "&max-results=" + connectorProperties.getProperty("coreReportMaxResults") + "&start-index=" + connectorProperties.getProperty("coreReportStartIndex"); ; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); Assert.assertEquals(connectorProperties.getProperty("coreReportMaxResults"), apiResponse.getJSONObject("query").getString("max-results")); Assert.assertEquals(connectorProperties.getProperty("coreReportStartIndex"), apiResponse.getJSONObject("query").getString("start-index")); Assert.assertEquals(esbResponse.getString("itemsPerPage"), apiResponse.getString("itemsPerPage")); Assert.assertEquals(esbResponse.getString("totalResults"), apiResponse.getString("totalResults")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listConfigurationData method with mandatory parameters. * * @throws org.json.JSONException//from w ww. j a v a2 s . co m * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listConfigurationData} integration test with mandatory parameters.", dependsOnMethods = { "testListAccountSummariesWithMandatoryParameters" }) public void testListConfigurationDataWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listConfigurationData"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listConfigurationData_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/metadata/" + connectorProperties.getProperty("reportType") + "/columns"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); Assert.assertEquals(esbResponse.getString("etag"), apiResponse.getString("etag")); Assert.assertEquals(esbResponse.getString("totalResults"), apiResponse.getString("totalResults")); Assert.assertEquals(esbResponse.getJSONArray("items").length(), apiResponse.getJSONArray("items").length()); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listConfigurationData method with optional parameters. * * @throws org.json.JSONException//from w w w . ja va 2s . c o m * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listConfigurationData} integration test with optional parameters.", dependsOnMethods = { "testListAccountSummariesWithMandatoryParameters" }) public void testListConfigurationDataWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listConfigurationData"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listConfigurationData_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/metadata/" + connectorProperties.getProperty("reportType") + "/columns?fields=" + connectorProperties.getProperty("configFields"); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndpoint, "GET", apiRequestHeadersMap); final String apiEndpoint1 = apiEndpointUrl + "/metadata/" + connectorProperties.getProperty("reportType") + "/columns"; RestResponse<JSONObject> apiRestResponseWithoutFields = sendJsonRestRequest(apiEndpoint1, "GET", apiRequestHeadersMap); final JSONObject apiResponse = apiRestResponse.getBody(); Assert.assertEquals(esbResponse.getString("kind"), apiResponse.getString("kind")); Assert.assertEquals(esbResponse.getString("etag"), apiResponse.getString("etag")); Assert.assertFalse(esbResponse.has("totalResults")); Assert.assertFalse(apiResponse.has("totalResults")); Assert.assertTrue(apiRestResponseWithoutFields.getBody().has("totalResults")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for listViews method with mandatory parameters. * * @throws org.json.JSONException//from w ww . java2 s.co m * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listViews} integration test with mandatory parameters.") public void testListViewsWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listViews"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listViews_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles"; 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 listViews method with optional parameters. * * @throws org.json.JSONException//from www. j a v a2 s . com * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {listViews} integration test with optional parameters.") public void testListViewsWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listViews"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listViews_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles?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("kind"), apiResponse.getString("kind")); Assert.assertEquals(esbResponse.getString("totalResults"), apiResponse.getString("totalResults")); }
From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java
/** * Positive test case for getViews method with mandatory parameters. * * @throws org.json.JSONException// w ww .jav a2 s . c o m * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {getViews} integration test with mandatory parameters.") public void testGetViewsWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:getViews"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_getViews_mandatory.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("profileId"); 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 getViews method with optional parameters. * * @throws org.json.JSONException/*www. ja va 2 s . com*/ * @throws java.io.IOException */ @Test(groups = { "wso2.esb" }, description = "googleanalytics {getViews} integration test with optional parameters.") public void testGetViewsWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:getViews"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_getViews_optional.json"); final JSONObject esbResponse = esbRestResponse.getBody(); final String apiEndpoint = apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId") + "/webproperties/" + connectorProperties.getProperty("webPropertyId") + "/profiles/" + connectorProperties.getProperty("profileId") + "?fields=accountId,webPropertyId"; 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")); Assert.assertEquals(esbResponse.getString("webPropertyId"), apiResponse.getString("webPropertyId")); }