@Test(description = "List all Subscriptions By by calling the getAllSubscriptionsOfApplication")
  public void testGetAllSubscriptionsOfApplication() throws Exception {
    String subscriptionData = apiStore.getAllSubscriptionsOfApplication().getData();
    JSONObject jsonSubscription = new JSONObject(subscriptionData);

    int returnedSubscriptions = 0;
    if (jsonSubscription.getString("error").equals("false")) {
      JSONObject jsonSubscriptionsObject = jsonSubscription.getJSONObject("subscriptions");
      JSONArray jsonApplicationsArray = jsonSubscriptionsObject.getJSONArray("applications");

      // Remove API Subscriptions
      for (int i = 0; i < jsonApplicationsArray.length(); i++) {
        JSONObject appObject = jsonApplicationsArray.getJSONObject(i);
        String applicationName = appObject.getString("name");
        if ("DefaultApplication".equals(applicationName)) {
          // This is the default application. We have not added any subscriptions for this. Hence
          // skipping
          // this one
          continue;
        }
        JSONArray subscribedAPIJSONArray = appObject.getJSONArray("subscriptions");
        int length = subscribedAPIJSONArray.length();
        if (i == 0) {
          // We are checking the first application as the method should return that.
          // check whether the subscriptions are empty.
          assertEquals(1, length, "No subscriptions found for application : " + applicationName);
        } else {
          // If there are subscriptions for other applications returned, that is wrong
          assertEquals(0, length, "Subscriptions found for application : " + applicationName);
        }

        if (length > 0) {
          returnedSubscriptions++;
        }
        // We do not check whether the subscriptions are correct or not since that is covered from
        // the other
        // test cases. What we are interested is that, the testGetAllSubscriptionsOfApplication() is
        // returning
        // subscription details for first application. If they are found, then our test case is
        // successful.
      }
      assertEquals(
          1, returnedSubscriptions, "More than the number of expected subscriptions were returned");
    } else {
      throw new Exception("Unable to get the list of subscriptions.");
    }
  }
  @Test(
      description =
          "List all Subscriptions By by calling the getAllSubscriptionsOfApplication with application name")
  public void testGetAllSubscriptionsOfApplicationWithSelectedApp() throws Exception {
    String selectedApplication = applicationNamePrefix + 1;
    String subscriptionData =
        apiStore.getAllSubscriptionsOfApplication(selectedApplication).getData();
    JSONObject jsonSubscription = new JSONObject(subscriptionData);

    if (jsonSubscription.getString("error").equals("false")) {
      JSONObject jsonSubscriptionsObject = jsonSubscription.getJSONObject("subscriptions");
      JSONArray jsonApplicationsArray = jsonSubscriptionsObject.getJSONArray("applications");

      // Remove API Subscriptions
      for (int i = 0; i < jsonApplicationsArray.length(); i++) {
        JSONObject appObject = jsonApplicationsArray.getJSONObject(i);
        String applicationName = appObject.getString("name");

        JSONArray subscribedAPIJSONArray = appObject.getJSONArray("subscriptions");
        int length = subscribedAPIJSONArray.length();
        if ("DefaultApplication".equals(applicationName)) {
          // This is the default application. We have not added any subscriptions for this. Hence
          // should be 0
          assertEquals(
              0, length, "subscriptions found for the default application : " + applicationName);
        } else if (selectedApplication.equals(applicationName)) {
          // check whether the subscriptions are empty.
          assertEquals(
              1,
              length,
              "No subscriptions found for the selected application : " + applicationName);
        } else {
          // check whether the subscriptions are empty.
          assertEquals(
              0, length, "subscriptions found for invalid application : " + applicationName);
        }
        // We do not check whether the subscriptions are correct or not since that is covered from
        // the other
        // test cases. What we are interested is that, the
        // testGetAllSubscriptionsOfApplication(selectedApplication) is returning subscription
        // details for given application. If they are found, then our test case is successful.
      }
    } else {
      throw new Exception("Unable to get the list of subscriptions.");
    }
  }