From 00e8c102ca61db92064c240d8e306c74eb0dadd7 Mon Sep 17 00:00:00 2001 From: dev_kong Date: Fri, 8 Sep 2023 20:45:27 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EB=A6=AC=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=EC=A6=88=20=EC=8A=A4=ED=8A=B8=EB=A6=BC=20->=20parallelStream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/project/yozmcafe/service/ImageService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/project/yozmcafe/service/ImageService.java b/server/src/main/java/com/project/yozmcafe/service/ImageService.java index 53c0dd38..a385ce2d 100644 --- a/server/src/main/java/com/project/yozmcafe/service/ImageService.java +++ b/server/src/main/java/com/project/yozmcafe/service/ImageService.java @@ -1,13 +1,14 @@ package com.project.yozmcafe.service; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + import com.project.yozmcafe.domain.S3Client; import com.project.yozmcafe.domain.resizedimage.ImageName; import com.project.yozmcafe.domain.resizedimage.ImageResizer; import com.project.yozmcafe.domain.resizedimage.Size; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; @Service public class ImageService { @@ -23,7 +24,10 @@ public List resizeAndUpload(final List files, final List< .map(this::multipartfileToImageResizer) .toList(); - resizers.forEach(resizer -> resizer.getResizedImages(sizes).forEach(s3Client::upload)); + resizers.parallelStream() + .forEach(resizer -> resizer.getResizedImages(sizes) + .forEach(s3Client::upload) + ); return resizers.stream() .map(ImageResizer::getFileName) From 55de506bc955f6e0a85c4d3b309f6b45f462389a Mon Sep 17 00:00:00 2001 From: dev_kong Date: Wed, 13 Sep 2023 12:09:50 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor=20:=20final=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/project/yozmcafe/service/MenuService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/com/project/yozmcafe/service/MenuService.java b/server/src/main/java/com/project/yozmcafe/service/MenuService.java index fc521abd..f7a30878 100644 --- a/server/src/main/java/com/project/yozmcafe/service/MenuService.java +++ b/server/src/main/java/com/project/yozmcafe/service/MenuService.java @@ -48,7 +48,7 @@ public void saveMenu(final Long cafeId, final Cafe cafe = cafeRepository.findById(cafeId) .orElseThrow(() -> new BadRequestException(NOT_EXISTED_CAFE)); - Menu menu = menuRequest.toMenu(cafe, imageName); + final Menu menu = menuRequest.toMenu(cafe, imageName); menuRepository.save(menu); } @@ -58,7 +58,7 @@ public void saveMenuWithoutImage(final Long cafeId, final Cafe cafe = cafeRepository.findById(cafeId) .orElseThrow(() -> new BadRequestException(NOT_EXISTED_CAFE)); - Menu menu = menuRequest.toMenuWithoutImage(cafe); + final Menu menu = menuRequest.toMenuWithoutImage(cafe); menuRepository.save(menu); } @@ -69,7 +69,7 @@ public void saveMenuBoard(final Long cafeId, final Cafe cafe = cafeRepository.findById(cafeId) .orElseThrow(() -> new BadRequestException(NOT_EXISTED_CAFE)); - MenuBoard menuBoard = menuBoardRequest.toMenu(cafe, imageName); + final MenuBoard menuBoard = menuBoardRequest.toMenu(cafe, imageName); menuBoardRepository.save(menuBoard); } } From 40dcbd11b7912319115936a24c5735d8a525135c Mon Sep 17 00:00:00 2001 From: dev_kong Date: Wed, 13 Sep 2023 15:02:00 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor=20:=20ImageService=EC=9D=98=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=A6=88=20parameter=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CafeAdminController에서 Size(enum)을 알고 있다는 것이 controller의 역할에 부합하지 않는 것 같아 리팩토링 진행. --- .../controller/CafeAdminController.java | 9 ++-- .../domain/resizedimage/ImageResizer.java | 25 +++++----- .../yozmcafe/service/ImageService.java | 40 +++++++++------ .../yozmcafe/domain/ImageResizerTest.java | 49 +++++++++++++------ .../yozmcafe/service/ImageServiceTest.java | 38 +++++++------- 5 files changed, 96 insertions(+), 65 deletions(-) diff --git a/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java b/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java index 115616e4..d475e9db 100644 --- a/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java +++ b/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java @@ -22,7 +22,6 @@ import com.project.yozmcafe.controller.dto.cafe.CafeUpdateRequest; import com.project.yozmcafe.controller.dto.cafe.MenuBoardRequest; import com.project.yozmcafe.controller.dto.cafe.MenuRequest; -import com.project.yozmcafe.domain.resizedimage.Size; import com.project.yozmcafe.service.CafeAdminService; import com.project.yozmcafe.service.ImageService; import com.project.yozmcafe.service.MenuService; @@ -45,7 +44,7 @@ public CafeAdminController(final CafeAdminService cafeAdminService, final ImageS @PostMapping public ResponseEntity save(@RequestPart final CafeRequest request, @RequestPart final List images) { - final List uploadedFileNames = imageService.resizeAndUpload(images, List.of(Size.values())); + final List uploadedFileNames = imageService.resizeToAllSizesAndUpload(images); final Long savedId = cafeAdminService.save(request, uploadedFileNames); return ResponseEntity.created(URI.create("/admin/cafes/" + savedId)).build(); @@ -58,7 +57,7 @@ public ResponseEntity update(@PathVariable("cafeId") final Long cafeId, final List originalImages = cafeAdminService.findImagesByCafeId(cafeId); imageService.deleteAll(originalImages); - final List savedImages = imageService.resizeAndUpload(images, List.of(Size.values())); + final List savedImages = imageService.resizeToAllSizesAndUpload(images); cafeAdminService.update(cafeId, request, savedImages); return ResponseEntity.noContent().build(); @@ -93,7 +92,7 @@ public ResponseEntity saveMenus(@PathVariable("cafeId") final Long cafeI menuService.saveMenuWithoutImage(cafeId, menuRequest); } if (nonNull(image)) { - String uploadedFileName = imageService.resizeAndUpload(image, Size.THUMBNAIL); + String uploadedFileName = imageService.resizeToThumbnailSizeAndUpload(image); menuService.saveMenu(cafeId, menuRequest, uploadedFileName); } @@ -104,7 +103,7 @@ public ResponseEntity saveMenus(@PathVariable("cafeId") final Long cafeI public ResponseEntity saveMenuBoards(@PathVariable("cafeId") final Long cafeId, @RequestPart final MenuBoardRequest menuBoardRequest, @RequestPart final MultipartFile image) { - String uploadedFileName = imageService.resizeAndUpload(image, Size.MOBILE); + String uploadedFileName = imageService.resizeToMobileSizeAndUpload(image); menuService.saveMenuBoard(cafeId, menuBoardRequest, uploadedFileName); return ResponseEntity.created(URI.create("/admin/cafes/" + cafeId)).build(); diff --git a/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java b/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java index 87c18cf2..6c8ef664 100644 --- a/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java +++ b/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java @@ -1,20 +1,23 @@ package com.project.yozmcafe.domain.resizedimage; -import com.project.yozmcafe.exception.BadRequestException; -import org.springframework.web.multipart.MultipartFile; +import static com.project.yozmcafe.exception.ErrorCode.INVALID_IMAGE_SIZE; +import static com.project.yozmcafe.exception.ErrorCode.NOT_IMAGE; +import static java.util.Objects.isNull; +import static java.util.Objects.requireNonNull; -import javax.imageio.ImageIO; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.Arrays; import java.util.List; -import static com.project.yozmcafe.exception.ErrorCode.INVALID_IMAGE_SIZE; -import static com.project.yozmcafe.exception.ErrorCode.NOT_IMAGE; -import static java.util.Objects.isNull; -import static java.util.Objects.requireNonNull; +import javax.imageio.ImageIO; + +import org.springframework.web.multipart.MultipartFile; + +import com.project.yozmcafe.exception.BadRequestException; public class ImageResizer { @@ -46,13 +49,13 @@ private boolean isNotImage(final MultipartFile image) { return !requireNonNull(contentType).startsWith(IMAGE_FORMAT_PREFIX); } - public List getResizedImages(final List sizes) { - return sizes.stream() - .map(this::getResizedImage) + public List resizeImageToAllSizes() { + return Arrays.stream(Size.values()) + .map(this::resizeToFixedImage) .toList(); } - public MultipartFile getResizedImage(final Size size) { + public MultipartFile resizeToFixedImage(final Size size) { final BufferedImage bufferedImage = getBufferedImage(); final int width = size.getWidth(); diff --git a/server/src/main/java/com/project/yozmcafe/service/ImageService.java b/server/src/main/java/com/project/yozmcafe/service/ImageService.java index a385ce2d..3f80dfb8 100644 --- a/server/src/main/java/com/project/yozmcafe/service/ImageService.java +++ b/server/src/main/java/com/project/yozmcafe/service/ImageService.java @@ -1,5 +1,8 @@ package com.project.yozmcafe.service; +import static com.project.yozmcafe.domain.resizedimage.Size.MOBILE; +import static com.project.yozmcafe.domain.resizedimage.Size.THUMBNAIL; + import java.util.List; import org.springframework.stereotype.Service; @@ -19,17 +22,16 @@ public ImageService(final S3Client s3Client) { this.s3Client = s3Client; } - public List resizeAndUpload(final List files, final List sizes) { - final List resizers = files.stream() + public List resizeToAllSizesAndUpload(final List files) { + final List imageResizers = files.stream() .map(this::multipartfileToImageResizer) .toList(); - resizers.parallelStream() - .forEach(resizer -> resizer.getResizedImages(sizes) - .forEach(s3Client::upload) - ); + imageResizers.parallelStream() + .forEach(imageResizer -> imageResizer.resizeImageToAllSizes() + .forEach(s3Client::upload)); - return resizers.stream() + return imageResizers.stream() .map(ImageResizer::getFileName) .toList(); } @@ -39,19 +41,27 @@ private ImageResizer multipartfileToImageResizer(final MultipartFile file) { return new ImageResizer(file, imageName.get()); } - public void deleteAll(final List imageNames) { - imageNames.stream() - .map(Size::getFileNamesWithPath) - .flatMap(List::stream) - .forEach(s3Client::delete); + public String resizeToThumbnailSizeAndUpload(MultipartFile file) { + return resizeToFixedImageAndUpload(file, THUMBNAIL); + } + + public String resizeToMobileSizeAndUpload(MultipartFile file) { + return resizeToFixedImageAndUpload(file, MOBILE); } - public String resizeAndUpload(final MultipartFile image, final Size size) { - final ImageResizer imageResizer = multipartfileToImageResizer(image); + private String resizeToFixedImageAndUpload(final MultipartFile file, final Size size) { + final ImageResizer imageResizer = multipartfileToImageResizer(file); - final MultipartFile resizedImages = imageResizer.getResizedImage(size); + final MultipartFile resizedImages = imageResizer.resizeToFixedImage(size); s3Client.upload(resizedImages); return imageResizer.getFileName(); } + + public void deleteAll(final List imageNames) { + imageNames.stream() + .map(Size::getFileNamesWithPath) + .flatMap(List::stream) + .forEach(s3Client::delete); + } } diff --git a/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java b/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java index bcd48380..c6c7bfc5 100644 --- a/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java +++ b/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java @@ -1,14 +1,8 @@ package com.project.yozmcafe.domain; -import com.project.yozmcafe.domain.resizedimage.ImageResizer; -import com.project.yozmcafe.domain.resizedimage.Size; -import com.project.yozmcafe.exception.BadRequestException; -import com.project.yozmcafe.exception.ErrorCode; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.web.multipart.MultipartFile; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.io.File; import java.io.FileInputStream; @@ -16,9 +10,18 @@ import java.io.InputStream; import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.web.multipart.MultipartFile; + +import com.project.yozmcafe.domain.resizedimage.ImageResizer; +import com.project.yozmcafe.domain.resizedimage.Size; +import com.project.yozmcafe.exception.BadRequestException; +import com.project.yozmcafe.exception.ErrorCode; class ImageResizerTest { @@ -75,14 +78,14 @@ void construct() throws Exception { } @Test - @DisplayName("리사이즈된 이미지들을 리턴한다") - void getResizedImages() throws Exception { + @DisplayName("모든 사이즈로 리사이즈된 이미지들을 리턴한다") + void resizeImageToAllSize() throws Exception { //given final MultipartFile image = makeMultipartFile(); final ImageResizer imageResizer = new ImageResizer(image, "fileName.png"); //when - final List results = imageResizer.getResizedImages(List.of(Size.values())); + final List results = imageResizer.resizeImageToAllSizes(); final List fileNameWithPathResult = results.stream() .map(MultipartFile::getOriginalFilename) .toList(); @@ -94,6 +97,22 @@ void getResizedImages() throws Exception { ); } + @ParameterizedTest + @EnumSource(value = Size.class) + @DisplayName("특정 사이즈로 리사이즈된 이미지들을 리턴한다") + void resizeImageToMobileSize(final Size size) throws Exception { + //given + final String fileName = "fileName.png"; + final MultipartFile image = makeMultipartFile(); + final ImageResizer imageResizer = new ImageResizer(image, fileName); + + //when + final MultipartFile resizedImage = imageResizer.resizeToFixedImage(size); + + //then + assertThat(resizedImage.getOriginalFilename()).isEqualTo(size.getFileNameWithPath(fileName)); + } + private MultipartFile makeMultipartFile() throws IOException { final File file = new File("src/test/resources/image.png"); final FileInputStream fileInputStream = new FileInputStream(file); diff --git a/server/src/test/java/com/project/yozmcafe/service/ImageServiceTest.java b/server/src/test/java/com/project/yozmcafe/service/ImageServiceTest.java index f1be7b1b..d4ef090e 100644 --- a/server/src/test/java/com/project/yozmcafe/service/ImageServiceTest.java +++ b/server/src/test/java/com/project/yozmcafe/service/ImageServiceTest.java @@ -1,9 +1,18 @@ package com.project.yozmcafe.service; -import com.project.yozmcafe.BaseTest; -import com.project.yozmcafe.domain.S3Client; -import com.project.yozmcafe.domain.resizedimage.Size; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.anyString; +import static org.mockito.BDDMockito.times; +import static org.mockito.BDDMockito.verify; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -11,17 +20,9 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.anyString; -import static org.mockito.BDDMockito.times; -import static org.mockito.BDDMockito.verify; +import com.project.yozmcafe.BaseTest; +import com.project.yozmcafe.domain.S3Client; +import com.project.yozmcafe.domain.resizedimage.Size; class ImageServiceTest extends BaseTest { @@ -32,14 +33,14 @@ class ImageServiceTest extends BaseTest { private S3Client s3Client; @Test - @DisplayName("리사이즈 이후 업로드 한다") + @DisplayName("모든 사이즈로 리사이즈 이후 업로드 한다") void resizeAndUpload1() { //given final MockMultipartFile image = makeMultipartFile(); final List images = List.of(image, image, image); //when - final List names = imageService.resizeAndUpload(images, List.of(Size.values())); + final List names = imageService.resizeToAllSizesAndUpload(images); //then final int expectedUploadCount = images.size() * Size.values().length; @@ -50,17 +51,16 @@ void resizeAndUpload1() { } @Test - @DisplayName("리사이즈 이후 업로드한다") + @DisplayName("모바일 사이즈로 리사이즈 이후 업로드한다") void resizeAndUpload2() { //given final MockMultipartFile file = makeMultipartFile(); //when - imageService.resizeAndUpload(file, Size.MOBILE); + imageService.resizeToMobileSizeAndUpload(file); //then verify(s3Client, times(1)).upload(any()); - } @Test From d0292bdc2fbab4e8f92f9bc36251fa27780316cb Mon Sep 17 00:00:00 2001 From: dev_kong Date: Thu, 14 Sep 2023 12:53:08 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor=20:=20final=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20&=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/yozmcafe/controller/CafeAdminController.java | 4 ++-- .../yozmcafe/domain/resizedimage/ImageResizer.java | 4 ++-- .../java/com/project/yozmcafe/service/ImageService.java | 8 ++++---- .../com/project/yozmcafe/domain/ImageResizerTest.java | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java b/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java index d475e9db..33939de2 100644 --- a/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java +++ b/server/src/main/java/com/project/yozmcafe/controller/CafeAdminController.java @@ -92,7 +92,7 @@ public ResponseEntity saveMenus(@PathVariable("cafeId") final Long cafeI menuService.saveMenuWithoutImage(cafeId, menuRequest); } if (nonNull(image)) { - String uploadedFileName = imageService.resizeToThumbnailSizeAndUpload(image); + final String uploadedFileName = imageService.resizeToThumbnailSizeAndUpload(image); menuService.saveMenu(cafeId, menuRequest, uploadedFileName); } @@ -103,7 +103,7 @@ public ResponseEntity saveMenus(@PathVariable("cafeId") final Long cafeI public ResponseEntity saveMenuBoards(@PathVariable("cafeId") final Long cafeId, @RequestPart final MenuBoardRequest menuBoardRequest, @RequestPart final MultipartFile image) { - String uploadedFileName = imageService.resizeToMobileSizeAndUpload(image); + final String uploadedFileName = imageService.resizeToMobileSizeAndUpload(image); menuService.saveMenuBoard(cafeId, menuBoardRequest, uploadedFileName); return ResponseEntity.created(URI.create("/admin/cafes/" + cafeId)).build(); diff --git a/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java b/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java index 6c8ef664..f5da56d8 100644 --- a/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java +++ b/server/src/main/java/com/project/yozmcafe/domain/resizedimage/ImageResizer.java @@ -51,11 +51,11 @@ private boolean isNotImage(final MultipartFile image) { public List resizeImageToAllSizes() { return Arrays.stream(Size.values()) - .map(this::resizeToFixedImage) + .map(this::resizeToFixedSize) .toList(); } - public MultipartFile resizeToFixedImage(final Size size) { + public MultipartFile resizeToFixedSize(final Size size) { final BufferedImage bufferedImage = getBufferedImage(); final int width = size.getWidth(); diff --git a/server/src/main/java/com/project/yozmcafe/service/ImageService.java b/server/src/main/java/com/project/yozmcafe/service/ImageService.java index 3f80dfb8..88f19862 100644 --- a/server/src/main/java/com/project/yozmcafe/service/ImageService.java +++ b/server/src/main/java/com/project/yozmcafe/service/ImageService.java @@ -42,17 +42,17 @@ private ImageResizer multipartfileToImageResizer(final MultipartFile file) { } public String resizeToThumbnailSizeAndUpload(MultipartFile file) { - return resizeToFixedImageAndUpload(file, THUMBNAIL); + return resizeToFixedSizeAndUpload(file, THUMBNAIL); } public String resizeToMobileSizeAndUpload(MultipartFile file) { - return resizeToFixedImageAndUpload(file, MOBILE); + return resizeToFixedSizeAndUpload(file, MOBILE); } - private String resizeToFixedImageAndUpload(final MultipartFile file, final Size size) { + private String resizeToFixedSizeAndUpload(final MultipartFile file, final Size size) { final ImageResizer imageResizer = multipartfileToImageResizer(file); - final MultipartFile resizedImages = imageResizer.resizeToFixedImage(size); + final MultipartFile resizedImages = imageResizer.resizeToFixedSize(size); s3Client.upload(resizedImages); return imageResizer.getFileName(); diff --git a/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java b/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java index c6c7bfc5..4c2dd4cf 100644 --- a/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java +++ b/server/src/test/java/com/project/yozmcafe/domain/ImageResizerTest.java @@ -107,7 +107,7 @@ void resizeImageToMobileSize(final Size size) throws Exception { final ImageResizer imageResizer = new ImageResizer(image, fileName); //when - final MultipartFile resizedImage = imageResizer.resizeToFixedImage(size); + final MultipartFile resizedImage = imageResizer.resizeToFixedSize(size); //then assertThat(resizedImage.getOriginalFilename()).isEqualTo(size.getFileNameWithPath(fileName));