@Test(
      groups = {"wso2.am"},
      description = "API Life cycle test case")
  public void testDAOTestCase() throws Exception {
    String APIName = "DAOTestAPI";
    String APIContext = "DAOTestAPI";
    String tags = "youtube, video, media";
    String url = "http://gdata.youtube.com/feeds/api/standardfeeds";
    String description = "This is test API create by API manager integration test";

    String APIVersion = "1.0.0";
    String apiContextAddedValue = APIContext + "/" + APIVersion;

    APIRequest apiRequest = new APIRequest(APIName, APIContext, new URL(url));
    apiRequest.setTags(tags);
    apiRequest.setDescription(description);
    apiRequest.setVersion(APIVersion);
    apiRequest.setProvider(providerName);
    apiPublisher.addAPI(apiRequest);
    apiPublisher.deleteAPI(APIName, APIVersion, providerName);
    apiPublisher.addAPI(apiRequest);
    APIBean apiBean =
        APIMTestCaseUtils.getAPIBeanFromHttpResponse(apiPublisher.getAPI(APIName, providerName));
    APILifeCycleStateRequest updateRequest =
        new APILifeCycleStateRequest(APIName, providerName, APILifeCycleState.PUBLISHED);
    apiPublisher.changeAPILifeCycleStatus(updateRequest);
    // Test API properties
    assertEquals(apiBean.getId().getApiName(), APIName, "API Name mismatch");
    assertTrue(apiBean.getContext().contains(apiContextAddedValue), "API context mismatch");
    assertEquals(apiBean.getId().getVersion(), APIVersion, "API version mismatch");
    assertEquals(apiBean.getId().getProviderName(), providerName, "Provider Name mismatch");
    for (String tag : apiBean.getTags()) {
      assertTrue(tags.contains(tag), "API tag data mismatched");
    }
    assertEquals(apiBean.getDescription(), description, "API description mismatch");

    apiStore.addApplication("DAOTestAPI-Application", "Gold", "", "this-is-test");
    SubscriptionRequest subscriptionRequest =
        new SubscriptionRequest(
            APIName, storeContext.getContextTenant().getContextUser().getUserName());
    subscriptionRequest.setApplicationName("DAOTestAPI-Application");
    apiStore.subscribe(subscriptionRequest);

    APPKeyRequestGenerator generateAppKeyRequest =
        new APPKeyRequestGenerator("DAOTestAPI-Application");
    String responseString = apiStore.generateApplicationKey(generateAppKeyRequest).getData();
    JSONObject response = new JSONObject(responseString);
    String accessToken =
        response.getJSONObject("data").getJSONObject("key").get("accessToken").toString();
    Map<String, String> requestHeaders = new HashMap<String, String>();
    requestHeaders.put("Authorization", "Bearer " + accessToken);
    Thread.sleep(2000);
  }
  @Test(
      groups = {"wso2.am"},
      description = "Pizzashack Test")
  public void testPizzashackApiSample() throws Exception {

    List<APIResourceBean> resourceBeanList = new ArrayList<APIResourceBean>();

    APICreationRequestBean apiCreationRequestBean =
        new APICreationRequestBean(
            "PizzaAPI",
            "pizzashack",
            "1.0.0",
            "admin",
            new URL("http://localhost:9766/pizzashack-api-1.0.0/api/"));

    apiCreationRequestBean.setThumbUrl("/home/bhagya/WS/Pizza_Shack_Logo.jpeg");
    apiCreationRequestBean.setDescription(
        "Pizza API:Allows to manage pizza orders (create, update, retrieve orders)");
    apiCreationRequestBean.setTags("pizza, order, pizza-menu");
    apiCreationRequestBean.setResourceCount("4");

    resourceBeanList.add(
        new APIResourceBean("GET", "Application & Application User", "Unlimited", "/menu"));
    resourceBeanList.add(
        new APIResourceBean("POST", "Application & Application User", "Unlimited", "/order"));
    resourceBeanList.add(
        new APIResourceBean(
            "GET", "Application & Application User", "Unlimited", "/order/{orderid}"));
    resourceBeanList.add(
        new APIResourceBean("GET", "Application & Application User", "Unlimited", "/delivery"));
    apiCreationRequestBean.setResourceBeanList(resourceBeanList);

    apiCreationRequestBean.setTier("Unlimited");
    apiCreationRequestBean.setTiersCollection("Unlimited");

    apiPublisher.addAPI(apiCreationRequestBean);
    APILifeCycleStateRequest updateRequest =
        new APILifeCycleStateRequest(
            "PizzaAPI",
            publisherContext.getContextTenant().getContextUser().getUserName(),
            APILifeCycleState.PUBLISHED);
    apiPublisher.changeAPILifeCycleStatus(updateRequest);
    apiStore.addApplication("PizzaShack", "Unlimited", "", "");
    SubscriptionRequest subscriptionRequest =
        new SubscriptionRequest(
            "PizzaAPI", storeContext.getContextTenant().getContextUser().getUserName());
    subscriptionRequest.setApplicationName("PizzaShack");
    apiStore.subscribe(subscriptionRequest);

    APPKeyRequestGenerator generateAppKeyRequest = new APPKeyRequestGenerator("PizzaShack");
    String responseString = apiStore.generateApplicationKey(generateAppKeyRequest).getData();
    JSONObject response = new JSONObject(responseString);
    String accessToken =
        response.getJSONObject("data").getJSONObject("key").get("accessToken").toString();
    Map<String, String> requestHeaders = new HashMap<String, String>();
    requestHeaders.put("Authorization", "Bearer " + accessToken);

    Thread.sleep(2000);

    HttpResponse pizzaShackResponse =
        HttpRequestUtil.doGet(
            gatewayUrlsMgt.getWebAppURLNhttp() + "pizzashack/1.0.0/menu", requestHeaders);
    assertEquals(
        pizzaShackResponse.getResponseCode(),
        Response.Status.OK.getStatusCode(),
        "Response code mismatched when api invocation");
    System.out.println("My Response Code is " + pizzaShackResponse.getResponseCode());

    assertTrue(
        pizzaShackResponse.getData().contains("BBQ Chicken Bacon"),
        "Response data mismatched when api invocation");
    assertTrue(
        pizzaShackResponse.getData().contains("Grilled white chicken"),
        "Response data mismatched when api invocation");
    assertTrue(
        pizzaShackResponse.getData().contains("Chicken Parmesan"),
        "Response data mismatched when api invocation");
    assertTrue(
        pizzaShackResponse.getData().contains("Tuscan Six Cheese"),
        "Response data mismatched when api invocation");
    assertTrue(
        pizzaShackResponse.getData().contains("Asiago and Fontina"),
        "Response data mismatched when api invocation");
  }