Class APIManagerLifecycleBaseTest

java.lang.Object
org.wso2.am.integration.test.utils.base.APIMIntegrationBaseTest
org.wso2.am.integration.test.utils.base.APIManagerLifecycleBaseTest

public class APIManagerLifecycleBaseTest extends APIMIntegrationBaseTest
Base test class for all API Manager lifecycle test cases. This class contents the all the common variables and t methods.
  • Field Details

    • CARBON_HOME

      protected static final String CARBON_HOME
    • HTTP_RESPONSE_CODE_OK

      protected static final int HTTP_RESPONSE_CODE_OK
    • HTTP_RESPONSE_CODE_CREATED

      protected static final int HTTP_RESPONSE_CODE_CREATED
    • HTTP_RESPONSE_CODE_UNAUTHORIZED

      protected static final int HTTP_RESPONSE_CODE_UNAUTHORIZED
    • HTTP_RESPONSE_CODE_NOT_FOUND

      protected static final int HTTP_RESPONSE_CODE_NOT_FOUND
    • HTTP_RESPONSE_CODE_BAD_REQUEST

      protected static final int HTTP_RESPONSE_CODE_BAD_REQUEST
    • HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE

      protected static final int HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE
    • HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS

      protected static final int HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS
      See Also:
    • HTTP_RESPONSE_CODE_FORBIDDEN

      protected static final int HTTP_RESPONSE_CODE_FORBIDDEN
    • HTTP_RESPONSE_PRECONDITION_FAILED

      protected static final int HTTP_RESPONSE_PRECONDITION_FAILED
    • HTTP_RESPONSE_DATA_API_BLOCK

      protected static final String HTTP_RESPONSE_DATA_API_BLOCK
      See Also:
    • HTTP_RESPONSE_DATA_NOT_FOUND

      protected static final String HTTP_RESPONSE_DATA_NOT_FOUND
      See Also:
    • HTTP_RESPONSE_DATA_API_FORBIDDEN

      protected static final String HTTP_RESPONSE_DATA_API_FORBIDDEN
      See Also:
    • GOLD_INVOCATION_LIMIT_PER_MIN

      protected static final int GOLD_INVOCATION_LIMIT_PER_MIN
      See Also:
    • SILVER_INVOCATION_LIMIT_PER_MIN

      protected static final int SILVER_INVOCATION_LIMIT_PER_MIN
      See Also:
    • TIER_UNLIMITED

      protected static final String TIER_UNLIMITED
      See Also:
    • TIER_GOLD

      protected static final String TIER_GOLD
      See Also:
    • TIER_SILVER

      protected static final String TIER_SILVER
      See Also:
    • MESSAGE_THROTTLED_OUT

      protected static final String MESSAGE_THROTTLED_OUT
      See Also:
    • MESSAGE_THROTTLED_OUT_RESOURCE

      protected static final String MESSAGE_THROTTLED_OUT_RESOURCE
      See Also:
    • THROTTLING_UNIT_TIME

      protected static final int THROTTLING_UNIT_TIME
      See Also:
    • THROTTLING_ADDITIONAL_WAIT_TIME

      protected static final int THROTTLING_ADDITIONAL_WAIT_TIME
      See Also:
    • API_NAME

      protected static final String API_NAME
      See Also:
    • API_CONTEXT

      protected static final String API_CONTEXT
      See Also:
    • API_TAGS

      protected static final String API_TAGS
      See Also:
    • API_VERSION_1_0_0

      protected static final String API_VERSION_1_0_0
      See Also:
    • API_DESCRIPTION

      protected static final String API_DESCRIPTION
      See Also:
    • APPLICATION_NAME

      protected static final String APPLICATION_NAME
      See Also:
  • Constructor Details

    • APIManagerLifecycleBaseTest

      public APIManagerLifecycleBaseTest()
  • Method Details

    • getAPIIdentifierString

      protected String getAPIIdentifierString(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier)
      Return a String with combining the value of API Name,API Version and API Provider Name as key:value format
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name,API Version and API Provider Name to create the String
      Returns:
      String - with API Name,API Version and API Provider Name as key:value format
    • getAPIIdentifierStringFromAPIRequest

      protected String getAPIIdentifierStringFromAPIRequest(APIRequest apiRequest)
      Return a String with combining the value of API Name,API Version and API Provider Name as key:value format
      Parameters:
      apiRequest - - Instance of APIRequest object that include the API Name,API Version and API Provider Name to create the String
      Returns:
      String - with API Name,API Version and API Provider Name as key:value format
    • subscribeToAPI

      protected org.wso2.carbon.automation.test.utils.http.client.HttpResponse subscribeToAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, String applicationName, APIStoreRestClient storeRestClient) throws APIManagerIntegrationTestException
      Subscribe a API
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider
      storeRestClient - - Instance of APIPublisherRestClient
      Returns:
      HttpResponse - Response of the API subscribe action
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of subscribe() in APIStoreRestClient.java
    • subscribeToAPI

      protected SubscriptionDTO subscribeToAPI(String apiID, String applicationID, String tier, RestAPIStoreImpl storeRestClient) throws ApiException, APIManagerIntegrationTestException
      Throws:
      ApiException
      APIManagerIntegrationTestException
    • subscribeToAPIUsingRest

      protected org.wso2.carbon.automation.test.utils.http.client.HttpResponse subscribeToAPIUsingRest(String apiId, String applicationId, String tier, RestAPIStoreImpl storeRestClient) throws APIManagerIntegrationTestException
      Subscribe a API
      Parameters:
      apiId - - UUID of the API
      applicationId - - UUID of the application
      storeRestClient - - Instance of APIPublisherRestClient
      Returns:
      HttpResponse - Response of the API subscribe action
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of subscribe() in APIStoreRestClient.java
    • generateApplicationKeys

      protected ApplicationKeyBean generateApplicationKeys(APIStoreRestClient storeRestClient, String applicationName) throws APIManagerIntegrationTestException
      Generate the access token
      Parameters:
      storeRestClient - - Instance of storeRestClient
      applicationName - - Application name
      Returns:
      ApplicationKeyBean - ApplicationKeyBean that contains access token, consumer key and consumer secret
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of generateApplicationKey() in APIStoreRestClient.java
    • deleteAPI

      protected void deleteAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APIPublisherRestClient publisherRestClient) throws APIManagerIntegrationTestException
      Delete a API from API Publisher.
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider.
      publisherRestClient - - Instance of APIPublisherRestClient.
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of deleteApi() in APIPublisherRestClient.java.
    • deleteAPI

      protected void deleteAPI(String apiID, RestAPIPublisherImpl publisherRestClient) throws ApiException
      Parameters:
      apiID -
      publisherRestClient -
      Throws:
      ApiException
    • getValueFromJSON

      protected String getValueFromJSON(org.wso2.carbon.automation.test.utils.http.client.HttpResponse httpResponse, String key) throws APIManagerIntegrationTestException
      Retrieve the value from JSON object bu using the key.
      Parameters:
      httpResponse - - Response that containing the JSON object in it response data.
      key - - key of the JSON value the need to retrieve.
      Returns:
      String - The value of provided key as a String
      Throws:
      APIManagerIntegrationTestException - - Exception throws when resolving the JSON object in the HTTP response
    • verifyAPIStatusChange

      public boolean verifyAPIStatusChange(org.wso2.carbon.automation.test.utils.http.client.HttpResponse httpResponse, APILifeCycleState oldStatus, APILifeCycleState newStatus) throws APIManagerIntegrationTestException
      verify the API status change. this method will check the latest lifecycle status change is correct according to the given old status and new status.
      Parameters:
      httpResponse - - Response returned in the the API lifecycle status change action
      oldStatus - - Status of the API before the change
      newStatus - - Status of the API after the change
      Returns:
      boolean - true if the given status change is correct, if not false
      Throws:
      APIManagerIntegrationTestException - - Exception throws when resolving the JSON object in the HTTP response
    • publishAPI

      protected org.wso2.carbon.automation.test.utils.http.client.HttpResponse publishAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APIPublisherRestClient publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException
      Publish a API.
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider
      publisherRestClient - - Instance of APIPublisherRestClient
      isRequireReSubscription - - If publish with re-subscription required option true else false.
      Returns:
      HttpResponse - Response of the API Publishing activity
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of changeAPILifeCycleStatusToPublish() in APIPublisherRestClient.java.
    • publishAPI

      protected org.wso2.carbon.automation.test.utils.http.client.HttpResponse publishAPI(String apiID, RestAPIPublisherImpl publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException
      Parameters:
      apiID -
      publisherRestClient -
      isRequireReSubscription -
      Returns:
      Throws:
      APIManagerIntegrationTestException
    • publishAPIUsingRest

      protected org.wso2.carbon.automation.test.utils.http.client.HttpResponse publishAPIUsingRest(String apiId, RestAPIPublisherImpl publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException, ApiException
      Publish an API using REST.
      Parameters:
      apiId - - UUID of the API,
      publisherRestClient - - Instance of APIPublisherRestClient
      isRequireReSubscription - - If publish with re-subscription required option true else false.
      Returns:
      HttpResponse - Response of the API Publishing activity
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of changeAPILifeCycleStatusToPublish() in APIPublisherRestClient.java.
      ApiException
    • createAndPublishAPI

      public void createAndPublishAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APICreationRequestBean apiCreationRequestBean, APIPublisherRestClient publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException
      Create and publish a API.
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider
      apiCreationRequestBean - - Instance of APICreationRequestBean with all needed API information
      publisherRestClient - - Instance of APIPublisherRestClient
      isRequireReSubscription - - If publish with re-subscription required option true else false.
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API create and publish activities.
    • createAndPublishAPI

      public APIDTO createAndPublishAPI(APICreationRequestBean apiCreationRequestBean, RestAPIPublisherImpl publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException, ApiException
      Parameters:
      apiCreationRequestBean -
      publisherRestClient -
      isRequireReSubscription -
      Throws:
      APIManagerIntegrationTestException
      ApiException
    • createAndPublishAPIUsingRest

      public String createAndPublishAPIUsingRest(APIRequest apiRequest, RestAPIPublisherImpl publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException, ApiException
      Create and publish a API.
      Parameters:
      apiRequest - - Instance of APIRequest
      publisherRestClient - - Instance of RestAPIPublisherImpl
      isRequireReSubscription - - If publish with re-subscription required option true else false.
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API create and publish activities.
      ApiException
    • createAndPublishAPIWithoutRequireReSubscription

      protected void createAndPublishAPIWithoutRequireReSubscription(APICreationRequestBean apiCreationRequestBean, RestAPIPublisherImpl publisherRestClient) throws APIManagerIntegrationTestException, ApiException
      Create and publish a API with re-subscription not required.
      Parameters:
      apiCreationRequestBean - - Instance of APICreationRequestBean with all needed API information
      publisherRestClient - - Instance of APIPublisherRestClient
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API create and publish activities.
      ApiException
    • createAndPublishAPIWithoutRequireReSubscriptionUsingRest

      protected String createAndPublishAPIWithoutRequireReSubscriptionUsingRest(APIRequest apiRequest, RestAPIPublisherImpl publisherRestClient) throws APIManagerIntegrationTestException, ApiException
      Create and publish a API with re-subscription not required.
      Parameters:
      apiRequest - - Instance of APIRequest
      publisherRestClient - - Instance of RestAPIPublisherImpl
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API create and publish activities.
      ApiException
    • copyAPI

      protected void copyAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, String newAPIVersion, APIPublisherRestClient publisherRestClient) throws APIManagerIntegrationTestException
      Copy and API and create a new version.
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider
      newAPIVersion - - New API version need to create
      publisherRestClient - - Instance of APIPublisherRestClient
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API copy activities.
    • copyAPI

      protected APIDTO copyAPI(String apiID, String newAPIVersion, RestAPIPublisherImpl publisherRestClient) throws ApiException
      Parameters:
      apiID -
      newAPIVersion -
      publisherRestClient -
      Throws:
      APIManagerIntegrationTestException
      ApiException
    • copyAndPublishCopiedAPI

      protected void copyAndPublishCopiedAPI(String apiID, String newAPIVersion, RestAPIPublisherImpl publisherRestClient, boolean isRequireReSubscription) throws APIManagerIntegrationTestException, ApiException
      Copy and publish the copied API.
      Parameters:
      newAPIVersion - - New API version need to create
      publisherRestClient - - Instance of APIPublisherRestClient
      isRequireReSubscription - - If publish with re-subscription required option true else false.
      Throws:
      APIManagerIntegrationTestException - -Exception throws by copyAPI() and publishAPI() method calls
      ApiException
    • createPublishAndSubscribeToAPI

      protected void createPublishAndSubscribeToAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APICreationRequestBean apiCreationRequestBean, APIPublisherRestClient publisherRestClient, APIStoreRestClient storeRestClient, String applicationName) throws APIManagerIntegrationTestException, XPathExpressionException
      Create publish and subscribe a API.
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider
      apiCreationRequestBean - - Instance of APICreationRequestBean with all needed API information
      publisherRestClient - - Instance of APIPublisherRestClient
      storeRestClient - - Instance of APIStoreRestClient
      applicationName - - Name of the Application that the API need to subscribe.
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API create publish and subscribe a API activities.
      XPathExpressionException
    • createPublishAndSubscribeToAPI

      protected APIDTO createPublishAndSubscribeToAPI(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APICreationRequestBean apiCreationRequestBean, RestAPIPublisherImpl publisherRestClient, RestAPIStoreImpl storeRestClient, String applicationID, String tier) throws APIManagerIntegrationTestException, ApiException, ApiException, XPathExpressionException
      Parameters:
      apiIdentifier -
      apiCreationRequestBean -
      publisherRestClient -
      storeRestClient -
      Throws:
      APIManagerIntegrationTestException
      ApiException
      ApiException
      XPathExpressionException
    • createPublishAndSubscribeToAPIUsingRest

      protected String createPublishAndSubscribeToAPIUsingRest(APIRequest apiRequest, RestAPIPublisherImpl publisherRestClient, RestAPIStoreImpl storeRestClient, String applicationId, String tier) throws APIManagerIntegrationTestException, ApiException, XPathExpressionException
      Create publish and subscribe a API using REST API.
      Parameters:
      apiRequest - - Instance of APIRequest with all needed API information
      publisherRestClient - - Instance of APIPublisherRestClient
      storeRestClient - - Instance of APIStoreRestClient
      applicationId - - UUID of the Application that the API need to subscribe.
      tier - - Tier that needs to be subscribed.
      Throws:
      APIManagerIntegrationTestException - - Exception throws by API create publish and subscribe a API activities.
      ApiException
      XPathExpressionException
    • readFile

      protected String readFile(String fileLocation) throws APIManagerIntegrationTestException
      Read the file content and return the content as String.
      Overrides:
      readFile in class APIMIntegrationBaseTest
      Parameters:
      fileLocation - - Location of the file.
      Returns:
      String - content of the file.
      Throws:
      APIManagerIntegrationTestException - - exception throws when reading the file.
    • deleteAPI

      protected void deleteAPI(String apiID, org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, RestAPIPublisherImpl publisherRestClient) throws APIManagerIntegrationTestException
      Delete a API from API Publisher.
      Parameters:
      apiIdentifier - - Instance of APIIdentifier object that include the API Name, API Version and API Provider.
      publisherRestClient - - Instance of RestAPIPublisherImpl.
      Throws:
      APIManagerIntegrationTestException - - Exception throws by the method call of deleteApi() in APIPublisherRestClient.java.