From c9ea38258e0d42a64c464f76171e5cb89b5426b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Fri, 30 Aug 2024 11:22:08 +0700 Subject: [PATCH] MARP-760 Handle Sonar --- .../market/assembler/ProductDetailModelAssembler.java | 1 - .../axonivy/market/controller/ProductDetailsController.java | 4 +--- .../main/java/com/axonivy/market/service/VersionService.java | 3 +-- .../com/axonivy/market/service/impl/VersionServiceImpl.java | 2 +- .../market/controller/ProductDetailsControllerTest.java | 3 +-- .../axonivy/market/service/impl/VersionServiceImplTest.java | 5 ++--- 6 files changed, 6 insertions(+), 12 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 13f8e43ae..487ee4b1c 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 @@ -5,7 +5,6 @@ import com.axonivy.market.entity.Product; import com.axonivy.market.model.ProductDetailModel; import com.axonivy.market.util.VersionUtils; -import com.fasterxml.jackson.core.JsonProcessingException; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.springframework.hateoas.Link; diff --git a/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java b/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java index fa5504c3a..d28e4193e 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java +++ b/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java @@ -17,7 +17,6 @@ import java.util.Map; import com.axonivy.market.model.VersionAndUrlModel; -import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.tags.Tag; @@ -108,8 +107,7 @@ public ResponseEntity> findProductJsonContent(@PathVariable( @GetMapping(VERSIONS_IN_DESIGNER) @Operation(summary = "Get the list of released version in product", description = "Collect the released versions in product for ivy designer") - public ResponseEntity> findVersionsForDesigner(@PathVariable(ID) String id) - throws JsonProcessingException { + public ResponseEntity> findVersionsForDesigner(@PathVariable(ID) String id) { List versionList = versionService.getVersionsForDesigner(id); return new ResponseEntity<>(versionList, HttpStatus.OK); } diff --git a/marketplace-service/src/main/java/com/axonivy/market/service/VersionService.java b/marketplace-service/src/main/java/com/axonivy/market/service/VersionService.java index 759df7641..e4800c5a9 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/service/VersionService.java +++ b/marketplace-service/src/main/java/com/axonivy/market/service/VersionService.java @@ -2,7 +2,6 @@ import com.axonivy.market.model.MavenArtifactVersionModel; import com.axonivy.market.model.VersionAndUrlModel; -import com.fasterxml.jackson.core.JsonProcessingException; import java.util.List; import java.util.Map; @@ -17,5 +16,5 @@ List getArtifactsAndVersionToDisplay(String productId Map getProductJsonContentByIdAndVersion(String name , String version); - List getVersionsForDesigner(String productId) throws JsonProcessingException; + List getVersionsForDesigner(String productId); } \ No newline at end of file diff --git a/marketplace-service/src/main/java/com/axonivy/market/service/impl/VersionServiceImpl.java b/marketplace-service/src/main/java/com/axonivy/market/service/impl/VersionServiceImpl.java index bc51c2417..edbb0b70a 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/service/impl/VersionServiceImpl.java +++ b/marketplace-service/src/main/java/com/axonivy/market/service/impl/VersionServiceImpl.java @@ -130,7 +130,7 @@ public Map getProductJsonContentByIdAndVersion(String productId, } @Override - public List getVersionsForDesigner(String productId) throws JsonProcessingException { + public List getVersionsForDesigner(String productId) { List versionAndUrlList = new ArrayList<>(); List versions = productRepository.getReleasedVersionsById(productId); for (String version : versions) { diff --git a/marketplace-service/src/test/java/com/axonivy/market/controller/ProductDetailsControllerTest.java b/marketplace-service/src/test/java/com/axonivy/market/controller/ProductDetailsControllerTest.java index 9e0b8b5a8..b487b86e1 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/controller/ProductDetailsControllerTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/controller/ProductDetailsControllerTest.java @@ -14,7 +14,6 @@ import com.axonivy.market.constants.RequestMappingConstants; import com.axonivy.market.entity.productjsonfilecontent.ProductJsonContent; import com.axonivy.market.model.VersionAndUrlModel; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -125,7 +124,7 @@ void testSyncInstallationCount() { } @Test - void findProductVersionsById() throws JsonProcessingException { + void findProductVersionsById() { when(versionService.getVersionsForDesigner("google-maps-connector")).thenReturn(mockVersionAndUrlModels()); var result = productDetailsController.findVersionsForDesigner("google-maps-connector"); diff --git a/marketplace-service/src/test/java/com/axonivy/market/service/impl/VersionServiceImplTest.java b/marketplace-service/src/test/java/com/axonivy/market/service/impl/VersionServiceImplTest.java index 13e7b7f88..3dffceb19 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/service/impl/VersionServiceImplTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/service/impl/VersionServiceImplTest.java @@ -14,7 +14,6 @@ import com.axonivy.market.repository.ProductJsonContentRepository; import com.axonivy.market.repository.ProductRepository; import com.axonivy.market.util.XmlReaderUtils; -import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.commons.lang3.StringUtils; import org.assertj.core.api.Fail; import org.junit.jupiter.api.Assertions; @@ -420,7 +419,7 @@ void testGetRepoNameFromMarketRepo() { } @Test - void testGetVersionsForDesigner() throws JsonProcessingException { + void testGetVersionsForDesigner() { Mockito.when(productRepository.getReleasedVersionsById(anyString())) .thenReturn(List.of("11.3.0", "11.1.1", "11.1.0", "10.0.2")); @@ -436,7 +435,7 @@ void testGetVersionsForDesigner() throws JsonProcessingException { } @Test - void testGetProductJsonContentByIdAndVersion() throws JsonProcessingException { + void testGetProductJsonContentByIdAndVersion() { ProductJsonContent mockProductJsonContent = new ProductJsonContent(); String mockContent = """ {