Example usage for org.json JSONObject getString

List of usage examples for org.json JSONObject getString

Introduction

In this page you can find the example usage for org.json JSONObject getString.

Prototype

public String getString(String key) throws JSONException 

Source Link

Document

Get the string associated with a key.

Usage

From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java

/**
 * Positive test case for listUploads method with mandatory parameters.
 *
 * @throws org.json.JSONException//from   w w  w .  j  a v  a 2s.  c o m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {listUploads} integration test with mandatory parameters.", dependsOnMethods = {
                "testListCustomDataSourcesWithMandatoryParameters" })
public void testListUploadsWithMandatoryParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:listUploads");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_listUploads_mandatory.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint = apiEndpointUrl + "/management/accounts/"
            + connectorProperties.getProperty("accountId") + "/webproperties/"
            + connectorProperties.getProperty("webPropertyId") + "/customDataSources/"
            + connectorProperties.getProperty("customDataSourceId") + "/uploads";
    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 listUploads method with optional parameters.
 *
 * @throws org.json.JSONException//from   www.  j  av a 2  s. co m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {listUploads} integration test with optional parameters.", dependsOnMethods = {
                "testListCustomDataSourcesWithMandatoryParameters" })
public void testListUploadsWithOptionalParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:listUploads");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_listUploads_optional.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint = apiEndpointUrl + "/management/accounts/"
            + connectorProperties.getProperty("accountId") + "/webproperties/"
            + connectorProperties.getProperty("webPropertyId") + "/customDataSources/"
            + connectorProperties.getProperty("customDataSourceId") + "/uploads?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 listProfileUserLink method with mandatory parameters.
 *
 * @throws org.json.JSONException//from   ww  w  .j a v  a  2 s.c  o  m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {listProfileUserLink} integration test with mandatory parameters.")
public void testListProfileUserLinkWithMandatoryParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:listProfileUserLink");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_listProfileUserLink_mandatory.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint = apiEndpointUrl + "/management/accounts/"
            + connectorProperties.getProperty("accountId") + "/webproperties/"
            + connectorProperties.getProperty("webPropertyId") + "/profiles/"
            + connectorProperties.getProperty("profileId") + "/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 listProfileUserLink method with optional parameters.
 *
 * @throws org.json.JSONException//www. j  av  a 2  s.c  o m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {listProfileUserLink} integration test with optional parameters.")
public void testListProfileUserLinkWithOptionalParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:listProfileUserLink");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_listProfileUserLink_optional.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint = apiEndpointUrl + "/management/accounts/"
            + connectorProperties.getProperty("accountId") + "/webproperties/"
            + connectorProperties.getProperty("webPropertyId") + "/profiles/"
            + connectorProperties.getProperty("profileId") + "/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"));
}

From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java

/**
 * Positive test case for listProfileFilterLink method with mandatory parameters.
 *
 * @throws org.json.JSONException//from ww  w  . j ava  2  s .c o  m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {listProfileFilterLink} integration test with mandatory parameters.")
public void testListProfileFilterLinkWithMandatoryParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:listProfileFilterLink");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_listProfileFilterLink_mandatory.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint = apiEndpointUrl + "/management/accounts/"
            + connectorProperties.getProperty("accountId") + "/webproperties/"
            + connectorProperties.getProperty("webPropertyId") + "/profiles/"
            + connectorProperties.getProperty("profileId") + "/profileFilterLinks";
    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 listProfileFilterLink method with optional parameters.
 *
 * @throws org.json.JSONException//from  w  w  w  . j av  a2  s  . co m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {listProfileFilterLink} integration test with optional parameters.")
public void testListProfileFilterLinkWithOptionalParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:listProfileFilterLink");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_listProfileFilterLink_optional.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint = apiEndpointUrl + "/management/accounts/"
            + connectorProperties.getProperty("accountId") + "/webproperties/"
            + connectorProperties.getProperty("webPropertyId") + "/profiles/"
            + connectorProperties.getProperty("profileId") + "/profileFilterLinks?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 getFilter method with mandatory parameters.
 *
 * @throws org.json.JSONException//from  w w w.ja  v a 2  s.  c o m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {getFilter} integration test with mandatory parameters.", dependsOnMethods = {
                "testListFiltersWithMandatoryParameters" })
public void testGetFilterWithMandatoryParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:getFilter");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_getFilter_mandatory.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint =

            apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId")
                    + "/filters/" + connectorProperties.getProperty("filterId");
    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 getFilter method with optional parameters.
 *
 * @throws org.json.JSONException/*from www. ja  v  a  2  s .  c o  m*/
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {getFilter} integration test with optional parameters.", dependsOnMethods = {
                "testListFiltersWithMandatoryParameters" })
public void testGetFilterWithOptionalParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:getFilter");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_getFilter_optional.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    final String apiEndpoint =

            apiEndpointUrl + "/management/accounts/" + connectorProperties.getProperty("accountId")
                    + "/filters/" + connectorProperties.getProperty("filterId") + "?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 insertGoals method with mandatory parameters.
 *
 * @throws org.json.JSONException//from w  ww  . ja  v a  2  s. co m
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {insertGoals} integration test with mandatory parameters.")
public void testCreateGoalsWithMandatoryParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:insertGoals");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_insertGoals_mandatory.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    Assert.assertEquals(esbRestResponse.getHttpStatusCode(), 200);
    Assert.assertEquals(esbResponse.getString("kind"), "analytics#goals");
}

From source file:org.wso2.carbon.connector.integration.test.googleanalytics.GoogleanalyticsConnectorIntegrationTest.java

/**
 * Positive test case for insertWebProperties method with mandatory parameters.
 *
 * @throws org.json.JSONException/*  ww w. j  a  v a2 s.  c  o  m*/
 * @throws java.io.IOException
 */
@Test(groups = {
        "wso2.esb" }, description = "googleanalytics {insertWebProperties} integration test with mandatory parameters.")
public void testCreateWebPropertiesWithMandatoryParameters() throws IOException, JSONException {

    esbRequestHeadersMap.put("Action", "urn:insertWebProperties");
    RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap,
            "esb_insertWebProperties_mandatory.json");
    final JSONObject esbResponse = esbRestResponse.getBody();
    Assert.assertEquals(esbRestResponse.getHttpStatusCode(), 200);
    Assert.assertEquals(esbResponse.getString("kind"), "analytics#webproperties");
}