From edfb358b770f935a4471bd15aa2604742b83c1b9 Mon Sep 17 00:00:00 2001 From: BLasan Date: Wed, 5 Jun 2024 15:18:13 +0530 Subject: [PATCH] Add: Test to check API Product type returned on Search --- .../test/impl/ApiProductTestHelper.java | 21 +++++++++++++++++++ .../APIProductCreationTestCase.java | 8 +++++++ 2 files changed, 29 insertions(+) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/ApiProductTestHelper.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/ApiProductTestHelper.java index 99d9d1ba8a..f4ae04d436 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/ApiProductTestHelper.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/ApiProductTestHelper.java @@ -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.*; @@ -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 diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/apiproduct/APIProductCreationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/apiproduct/APIProductCreationTestCase.java index 09f520f769..0478fb7cf0 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/apiproduct/APIProductCreationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/apiproduct/APIProductCreationTestCase.java @@ -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); @@ -219,6 +222,11 @@ public void testCreateAndInvokeApiProduct() throws Exception { Assert.assertEquals(httpResponse.getHeaders().get("Version"), "v2"); } + @Test(groups = {"wso2.com"}, description = "Check the APIProduct Type returned on Search") + public void testAPIProductTypeInSearchResponse() throws Exception { + + } + @Test(groups = {"wso2.am"}, description = "Create new version and publish") public void testAPIProductNewVersionCreation() throws Exception {