Skip to content

Commit

Permalink
Add: Test to check API Product type returned on Search
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Jun 5, 2024
1 parent f9e0982 commit 99ccbe5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.wso2.am.integration.clients.store.api.v1.dto.APIInfoDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.APIListDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.*;
import org.wso2.am.integration.clients.store.api.v1.dto.SearchResultDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.SearchResultListDTO;
import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;

import java.util.*;
Expand Down Expand Up @@ -239,6 +241,25 @@ public org.wso2.am.integration.clients.store.api.v1.dto.APIDTO verifyApiProductI
return responseData;
}

/**
* Validate the API Type returned for a API Product on Search
*
* @param apiProductName API Product name passed as the query parameter
* @throws org.wso2.am.integration.clients.store.api.ApiException APIException if exists
*/
public void validateAPITypeForAPIProductOnSearch(String apiProductName)
throws org.wso2.am.integration.clients.store.api.ApiException {
SearchResultListDTO searchResultDTO = restAPIStore.searchAPIs(apiProductName);

for (Object object : searchResultDTO.getList()) {
if (object instanceof APIInfoDTO) {
APIInfoDTO apiInfoDTO = (APIInfoDTO) object;
Assert.assertEquals(apiInfoDTO.getType(), "APIPRODUCT");
}
}
Assert.fail("APIProduct Not Found in Store");
}

/**
* Returns a collection of API resources which can be used by an APIProduct,
* by selecting all resources from each available API provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public void testCreateAndInvokeApiProduct() throws Exception {
org.wso2.am.integration.clients.store.api.v1.dto.APIDTO apiDTO =
apiProductTestHelper.verifyApiProductInPortal(apiProductDTO);

// Validate APIProduct on search
apiProductTestHelper.validateAPITypeForAPIProductOnSearch(name);

// Step 4 : Subscribe to APIProduct
ApplicationDTO applicationDTO = apiTestHelper.verifySubscription(apiDTO, UUID.randomUUID().toString(),
TIER_UNLIMITED);
Expand Down

0 comments on commit 99ccbe5

Please sign in to comment.