diff --git a/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GHAxonIvyProductRepoServiceImpl.java b/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GHAxonIvyProductRepoServiceImpl.java index 71af70207..78b034e49 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GHAxonIvyProductRepoServiceImpl.java +++ b/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GHAxonIvyProductRepoServiceImpl.java @@ -283,15 +283,15 @@ public String updateImagesWithDownloadUrl(Product product, List conte allContentOfImages.forEach(content -> { Image image = imageService.mappingImageFromGHContent(product, content); - System.out.println(content.getName()); imageUrls.put(content.getName(), "imageId-".concat(image.getId())); }); - for (String key : imageUrls.keySet()) { - String imageUrlPattern = String.format(README_IMAGE_FORMAT, Pattern.quote(key)); + for (Map.Entry entry : imageUrls.entrySet()) { + String imageUrlPattern = String.format(README_IMAGE_FORMAT, Pattern.quote(entry.getKey())); readmeContents = readmeContents.replaceAll(imageUrlPattern, - String.format(IMAGE_DOWNLOAD_URL_FORMAT, imageUrls.get(key))); + String.format(IMAGE_DOWNLOAD_URL_FORMAT, entry.getValue())); } + return readmeContents; } diff --git a/marketplace-service/src/main/java/com/axonivy/market/util/ImageUtils.java b/marketplace-service/src/main/java/com/axonivy/market/util/ImageUtils.java index 5f746c07f..0970aa45b 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/util/ImageUtils.java +++ b/marketplace-service/src/main/java/com/axonivy/market/util/ImageUtils.java @@ -16,6 +16,10 @@ import com.axonivy.market.entity.ProductModuleContent; public class ImageUtils { + + public ImageUtils() { + } + public static ProductModuleContent mappingImageForProductModuleContent(ProductModuleContent productModuleContent) { if (ObjectUtils.isEmpty(productModuleContent)) { return null; 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 53a1ed5f4..15a41fda5 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 @@ -235,7 +235,7 @@ private ProductJsonContent mockProductJsonContent() { } @Test - void test_getImageFromId() throws IOException { + void test_getImageFromId() { byte[] mockImageData = "image data".getBytes(); when(productService.readImage("66e2b14868f2f95b2f95549a")).thenReturn(mockImageData); diff --git a/marketplace-service/src/test/java/com/axonivy/market/factory/ProductFactoryTest.java b/marketplace-service/src/test/java/com/axonivy/market/factory/ProductFactoryTest.java index 97f587d0c..1b267fdc3 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/factory/ProductFactoryTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/factory/ProductFactoryTest.java @@ -41,7 +41,7 @@ void testMappingByGHContent() throws IOException { } @Test - void testMappingLogo() throws IOException { + void testMappingLogo() { Product product = new Product(); GHContent content = mock(GHContent.class); when(content.getName()).thenReturn(CommonConstants.LOGO_FILE); @@ -49,7 +49,6 @@ void testMappingLogo() throws IOException { assertNotEquals(null, result); when(content.getName()).thenReturn(CommonConstants.LOGO_FILE); -// when(content.getDownloadUrl()).thenReturn(DUMMY_LOGO_URL); result = ProductFactory.mappingByGHContent(product, content); assertNotEquals(null, result); } diff --git a/marketplace-service/src/test/java/com/axonivy/market/service/impl/GHAxonIvyProductRepoServiceImplTest.java b/marketplace-service/src/test/java/com/axonivy/market/service/impl/GHAxonIvyProductRepoServiceImplTest.java index 3cf328570..29cbc1419 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/service/impl/GHAxonIvyProductRepoServiceImplTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/service/impl/GHAxonIvyProductRepoServiceImplTest.java @@ -253,7 +253,6 @@ void testGetReadmeAndProductContentFromTag_ImageFromFolder() throws IOException GHContent mockImageFile = mock(GHContent.class); when(mockImageFile.getName()).thenReturn(ReadmeConstants.IMAGES, IMAGE_NAME); when(mockImageFile.isDirectory()).thenReturn(true); -// when(mockImageFile.getDownloadUrl()).thenReturn(IMAGE_DOWNLOAD_URL); Mockito.when(imageService.mappingImageFromGHContent(any(),any())).thenReturn(mockImage()); PagedIterable pagedIterable = Mockito.mock(String.valueOf(GHContent.class)); when(mockImageFile.listDirectoryContent()).thenReturn(pagedIterable); @@ -417,11 +416,10 @@ private GHContent createMockProductFolderWithProductJson() throws IOException { return mockContent; } - private static GHContent createMockProductJson() throws IOException { + private static GHContent createMockProductJson() { GHContent mockProductJson = mock(GHContent.class); when(mockProductJson.isFile()).thenReturn(true); when(mockProductJson.getName()).thenReturn(ProductJsonConstants.PRODUCT_JSON_FILE, IMAGE_NAME); -// when(mockProductJson.getDownloadUrl()).thenReturn(IMAGE_DOWNLOAD_URL); return mockProductJson; } diff --git a/marketplace-service/src/test/java/com/axonivy/market/service/impl/ImageServiceImplTest.java b/marketplace-service/src/test/java/com/axonivy/market/service/impl/ImageServiceImplTest.java index e4c7b886e..1c25ccf97 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/service/impl/ImageServiceImplTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/service/impl/ImageServiceImplTest.java @@ -24,7 +24,7 @@ import com.axonivy.market.repository.ImageRepository; @ExtendWith(MockitoExtension.class) -public class ImageServiceImplTest { +class ImageServiceImplTest { @InjectMocks private ImageServiceImpl imageService; diff --git a/marketplace-service/src/test/java/com/axonivy/market/util/ImageUtilsTest.java b/marketplace-service/src/test/java/com/axonivy/market/util/ImageUtilsTest.java index d0369015b..1eefe1584 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/util/ImageUtilsTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/util/ImageUtilsTest.java @@ -11,7 +11,7 @@ import com.axonivy.market.entity.ProductModuleContent; @ExtendWith(MockitoExtension.class) -public class ImageUtilsTest { +class ImageUtilsTest { @Test void testMappingImageForProductModuleContent() {