From 6a94c9c46d28aa932b9a204c70fa45aea1679511 Mon Sep 17 00:00:00 2001 From: tutn Date: Fri, 30 Aug 2024 09:50:07 +0700 Subject: [PATCH] handle feedback --- .../com/axonivy/market/entity/Product.java | 2 +- .../ProductModuleContentRepository.java | 4 +- .../service/impl/ProductServiceImplTest.java | 13 +++--- .../product-detail.component.ts | 44 +++++++++---------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/marketplace-service/src/main/java/com/axonivy/market/entity/Product.java b/marketplace-service/src/main/java/com/axonivy/market/entity/Product.java index 8567d811c..8c14bfdd3 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/entity/Product.java +++ b/marketplace-service/src/main/java/com/axonivy/market/entity/Product.java @@ -57,7 +57,7 @@ public class Product implements Serializable { private int installationCount; private Date newestPublishedDate; private String newestReleaseVersion; - @DBRef(lazy = false) + @DBRef private List productModuleContents; private List artifacts; private Boolean synchronizedInstallationCount; diff --git a/marketplace-service/src/main/java/com/axonivy/market/repository/ProductModuleContentRepository.java b/marketplace-service/src/main/java/com/axonivy/market/repository/ProductModuleContentRepository.java index f48ccce38..1f9efb343 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/repository/ProductModuleContentRepository.java +++ b/marketplace-service/src/main/java/com/axonivy/market/repository/ProductModuleContentRepository.java @@ -6,4 +6,6 @@ import com.axonivy.market.entity.ProductModuleContent; @Repository -public interface ProductModuleContentRepository extends MongoRepository {} +public interface ProductModuleContentRepository extends MongoRepository { + +} diff --git a/marketplace-service/src/test/java/com/axonivy/market/service/impl/ProductServiceImplTest.java b/marketplace-service/src/test/java/com/axonivy/market/service/impl/ProductServiceImplTest.java index 8a8df68c4..28a47790d 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/service/impl/ProductServiceImplTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/service/impl/ProductServiceImplTest.java @@ -34,6 +34,7 @@ import java.util.UUID; import com.axonivy.market.criteria.ProductSearchCriteria; +import com.fasterxml.jackson.core.type.TypeReference; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -121,7 +122,7 @@ class ProductServiceImplTest extends BaseSetup { ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Product.class); @Captor - ArgumentCaptor> argumentCaptorProductModuleContent = ArgumentCaptor.forClass((Class) List.class); + ArgumentCaptor> argumentCaptorProductModuleContent; @Mock private GHAxonIvyProductRepoService ghAxonIvyProductRepoService; @@ -149,7 +150,7 @@ void testUpdateInstallationCountForProduct() { when(productRepository.getProductById(product.getId())).thenReturn(product); when(productRepository.increaseInstallationCount(product.getId())).thenReturn(31); result = productService.updateInstallationCountForProduct(product.getId()); - assertEquals(31,result); + assertEquals(31, result); } @Test @@ -298,8 +299,8 @@ void testFindAllProductsWithKeyword() { && product.getType().equals(TypeOption.CONNECTORS.getCode())) .toList())); // Executes - result = - productService.findProducts(TypeOption.CONNECTORS.getOption(), SAMPLE_PRODUCT_NAME, language, false, PAGEABLE); + result = productService.findProducts(TypeOption.CONNECTORS.getOption(), SAMPLE_PRODUCT_NAME, language, false, + PAGEABLE); assertTrue(result.hasContent()); assertEquals(SAMPLE_PRODUCT_NAME, result.getContent().get(0).getNames().get(Language.EN.getValue())); } @@ -478,8 +479,8 @@ void testRefineOrderedListOfProductsInCustomSort_ProductNotFound() { List orderedListOfProducts = List.of(SAMPLE_PRODUCT_ID); when(productRepository.findById(SAMPLE_PRODUCT_ID)).thenReturn(Optional.empty()); - InvalidParamException exception = assertThrows(InvalidParamException.class, () -> - productService.refineOrderedListOfProductsInCustomSort(orderedListOfProducts)); + InvalidParamException exception = assertThrows(InvalidParamException.class, + () -> productService.refineOrderedListOfProductsInCustomSort(orderedListOfProducts)); assertEquals(ErrorCode.PRODUCT_NOT_FOUND.getCode(), exception.getCode()); } 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 66f06575d..6483a6cfa 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 @@ -1,3 +1,4 @@ +import { CommonModule } from '@angular/common'; import { Component, ElementRef, @@ -7,39 +8,38 @@ import { signal } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { ProductService } from '../product.service'; +import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; import { TranslateModule } from '@ngx-translate/core'; import { MarkdownModule, MarkdownService } from 'ngx-markdown'; -import { ProductDetail } from '../../../shared/models/product-detail.model'; -import { ProductModuleContent } from '../../../shared/models/product-module-content.model'; +import { Observable } from 'rxjs'; +import { AuthService } from '../../../auth/auth.service'; +import { LanguageService } from '../../../core/services/language/language.service'; import { ThemeService } from '../../../core/services/theme/theme.service'; -import { CommonModule } from '@angular/common'; -import { ProductDetailInformationTabComponent } from './product-detail-information-tab/product-detail-information-tab.component'; -import { ProductDetailVersionActionComponent } from './product-detail-version-action/product-detail-version-action.component'; -import { ProductDetailMavenContentComponent } from './product-detail-maven-content/product-detail-maven-content.component'; +import { CommonDropdownComponent } from '../../../shared/components/common-dropdown/common-dropdown.component'; import { PRODUCT_DETAIL_TABS, VERSION } from '../../../shared/constants/common.constant'; -import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; -import { LanguageService } from '../../../core/services/language/language.service'; +import { ItemDropdown } from '../../../shared/models/item-dropdown.model'; +import { ProductDetail } from '../../../shared/models/product-detail.model'; +import { ProductModuleContent } from '../../../shared/models/product-module-content.model'; +import { HasValueTabPipe } from '../../../shared/pipes/has-value-tab.pipe'; +import { ProductTypeIconPipe } from '../../../shared/pipes/icon.pipe'; import { MultilingualismPipe } from '../../../shared/pipes/multilingualism.pipe'; -import { ProductDetailService } from './product-detail.service'; -import { ProductDetailFeedbackComponent } from './product-detail-feedback/product-detail-feedback.component'; -import { ProductFeedbackService } from './product-detail-feedback/product-feedbacks-panel/product-feedback.service'; +import { ProductTypePipe } from '../../../shared/pipes/product-type.pipe'; import { AppModalService } from '../../../shared/services/app-modal.service'; -import { AuthService } from '../../../auth/auth.service'; -import { ProductStarRatingNumberComponent } from './product-star-rating-number/product-star-rating-number.component'; -import { ProductInstallationCountActionComponent } from './product-installation-count-action/product-installation-count-action.component'; -import { ProductTypeIconPipe } from '../../../shared/pipes/icon.pipe'; -import { Observable } from 'rxjs'; -import { ProductStarRatingService } from './product-detail-feedback/product-star-rating-panel/product-star-rating.service'; import { RoutingQueryParamService } from '../../../shared/services/routing.query.param.service'; -import { CommonDropdownComponent } from '../../../shared/components/common-dropdown/common-dropdown.component'; import { CommonUtils } from '../../../shared/utils/common.utils'; -import { ItemDropdown } from '../../../shared/models/item-dropdown.model'; -import { ProductTypePipe } from '../../../shared/pipes/product-type.pipe'; -import { HasValueTabPipe } from '../../../shared/pipes/has-value-tab.pipe'; +import { ProductService } from '../product.service'; +import { ProductDetailFeedbackComponent } from './product-detail-feedback/product-detail-feedback.component'; +import { ProductFeedbackService } from './product-detail-feedback/product-feedbacks-panel/product-feedback.service'; +import { ProductStarRatingService } from './product-detail-feedback/product-star-rating-panel/product-star-rating.service'; +import { ProductDetailInformationTabComponent } from './product-detail-information-tab/product-detail-information-tab.component'; +import { ProductDetailMavenContentComponent } from './product-detail-maven-content/product-detail-maven-content.component'; +import { ProductDetailVersionActionComponent } from './product-detail-version-action/product-detail-version-action.component'; +import { ProductDetailService } from './product-detail.service'; +import { ProductInstallationCountActionComponent } from './product-installation-count-action/product-installation-count-action.component'; +import { ProductStarRatingNumberComponent } from './product-star-rating-number/product-star-rating-number.component'; export interface DetailTab { activeClass: string;