From 73ad495bfe7d49c62441670d53d579ba671821f8 Mon Sep 17 00:00:00 2001 From: Dinh Nguyen Date: Fri, 26 Jul 2024 15:15:30 +0700 Subject: [PATCH] update test case --- .../ProductDetailModelAssembler.java | 12 ++++++ .../axonivy/market/util/GitHubUtilsTest.java | 37 ++++++++++--------- .../product-detail.component.ts | 4 +- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/marketplace-service/src/main/java/com/axonivy/market/assembler/ProductDetailModelAssembler.java b/marketplace-service/src/main/java/com/axonivy/market/assembler/ProductDetailModelAssembler.java index e72ab8034..86d180d1f 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/assembler/ProductDetailModelAssembler.java +++ b/marketplace-service/src/main/java/com/axonivy/market/assembler/ProductDetailModelAssembler.java @@ -1,8 +1,10 @@ package com.axonivy.market.assembler; +import com.axonivy.market.constants.CommonConstants; import com.axonivy.market.controller.ProductDetailsController; import com.axonivy.market.entity.Product; import com.axonivy.market.entity.ProductModuleContent; +import com.axonivy.market.enums.NonStandardProduct; import com.axonivy.market.model.ProductDetailModel; import org.apache.commons.lang3.StringUtils; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; @@ -70,4 +72,14 @@ private void createDetailResource(ProductDetailModel model, Product product, Str private ProductModuleContent getProductModuleContentByTag(List contents, String tag) { return contents.stream().filter(content -> StringUtils.equals(content.getTag(), tag)).findAny().orElse(null); } + + private String convertVersionToTag(String productId, String version) { + String[] versionParts = version.split(CommonConstants.SPACE_SEPARATOR); + String versionNumber = versionParts[versionParts.length - 1]; + NonStandardProduct product = NonStandardProduct.findById(productId); + if (product.isVersionTagNumberOnly()) { + return versionNumber; + } + return "v" + versionNumber; + } } diff --git a/marketplace-service/src/test/java/com/axonivy/market/util/GitHubUtilsTest.java b/marketplace-service/src/test/java/com/axonivy/market/util/GitHubUtilsTest.java index a5126b2ed..2f97404dd 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/util/GitHubUtilsTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/util/GitHubUtilsTest.java @@ -1,5 +1,6 @@ package com.axonivy.market.util; +import com.axonivy.market.enums.NonStandardProduct; import com.axonivy.market.github.util.GitHubUtils; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Assertions; @@ -29,61 +30,61 @@ void testConvertArtifactIdToName() { @Test void testBuildProductJsonFilePath() { - String result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.PORTAL); + String result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.PORTAL.getId()); Assertions.assertEquals("AxonIvyPortal/portal-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.CONNECTIVITY_FEATURE); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.CONNECTIVITY_FEATURE.getId()); Assertions.assertEquals("connectivity/connectivity-demos-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.ERROR_HANDLING); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.ERROR_HANDLING.getId()); Assertions.assertEquals("error-handling/error-handling-demos-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.WORKFLOW_DEMO); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.WORKFLOW_DEMO.getId()); Assertions.assertEquals("workflow/workflow-demos-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.MICROSOFT_365); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.MICROSOFT_365.getId()); Assertions.assertEquals("msgraph-connector-product/products/msgraph-connector", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.MICROSOFT_CALENDAR); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.MICROSOFT_CALENDAR.getId()); Assertions.assertEquals("msgraph-connector-product/products/msgraph-calendar", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.MICROSOFT_TEAMS); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.MICROSOFT_TEAMS.getId()); Assertions.assertEquals("msgraph-connector-product/products/msgraph-chat", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.MICROSOFT_MAIL); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.MICROSOFT_MAIL.getId()); Assertions.assertEquals("msgraph-connector-product/products/msgraph-mail", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.MICROSOFT_TODO); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.MICROSOFT_TODO.getId()); Assertions.assertEquals("msgraph-connector-product/products/msgraph-todo", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.HTML_DIALOG_DEMO); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.HTML_DIALOG_DEMO.getId()); Assertions.assertEquals("html-dialog/html-dialog-demos-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.RULE_ENGINE_DEMOS); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.RULE_ENGINE_DEMOS.getId()); Assertions.assertEquals("rule-engine/rule-engine-demos-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.OPENAI_CONNECTOR); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.OPENAI_CONNECTOR.getId()); Assertions.assertEquals("openai-connector-product", result); - result = GitHubUtils.getNonStandardProductFilePath(NonStandardProductPackageConstants.OPENAI_ASSISTANT); + result = GitHubUtils.getNonStandardProductFilePath(NonStandardProduct.OPENAI_ASSISTANT.getId()); Assertions.assertEquals("openai-assistant-product", result); } @Test void testGetNonStandardImageFolder() { - String result = GitHubUtils.getNonStandardImageFolder(NonStandardProductPackageConstants.EXCEL_IMPORTER); + String result = GitHubUtils.getNonStandardImageFolder(NonStandardProduct.EXCEL_IMPORTER.getId()); Assertions.assertEquals("doc", result); - result = GitHubUtils.getNonStandardImageFolder(NonStandardProductPackageConstants.EXPRESS_IMPORTER); + result = GitHubUtils.getNonStandardImageFolder(NonStandardProduct.EXPRESS_IMPORTER.getId()); Assertions.assertEquals("img", result); - result = GitHubUtils.getNonStandardImageFolder(NonStandardProductPackageConstants.DEEPL_CONNECTOR); + result = GitHubUtils.getNonStandardImageFolder(NonStandardProduct.DEEPL_CONNECTOR.getId()); Assertions.assertEquals("img", result); - result = GitHubUtils.getNonStandardImageFolder(NonStandardProductPackageConstants.GRAPHQL_DEMO); + result = GitHubUtils.getNonStandardImageFolder(NonStandardProduct.GRAPHQL_DEMO.getId()); Assertions.assertEquals("assets", result); - result = GitHubUtils.getNonStandardImageFolder(NonStandardProductPackageConstants.OPENAI_ASSISTANT); + result = GitHubUtils.getNonStandardImageFolder(NonStandardProduct.OPENAI_ASSISTANT.getId()); Assertions.assertEquals("docs", result); result = GitHubUtils.getNonStandardImageFolder(JIRA_CONNECTOR); diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts index 6c4a505f9..9dfbfc964 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts @@ -170,9 +170,7 @@ export class ProductDetailComponent { } loadDetailTabs(selectedVersion: string) { - const tag = - selectedVersion.replaceAll('Version ', 'v') || - this.productDetail().newestReleaseVersion; + const tag = selectedVersion || this.productDetail().newestReleaseVersion; this.productService .getProductDetailsWithVersion(this.productDetail().id, tag) .subscribe(updatedProductDetail => {