Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Test to check API Product type returned on Search #13496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading