### Question:
ImageConverter { public BufferedImage resizeImage(BufferedImage image, int type) { Dimension largestDimension = new Dimension(maxImageWidth, maxImageHeight); int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); float aspectRatio = (float) imageWidth / imageHeight; if (imageWidth > largestDimension.width || imageHeight > largestDimension.height) { if ((float) largestDimension.width / largestDimension.height > aspectRatio) { largestDimension.width = (int) Math.ceil(largestDimension.height * aspectRatio); } else { largestDimension.height = (int) Math.ceil(largestDimension.width / aspectRatio); } imageWidth = largestDimension.width; imageHeight = largestDimension.height; } if (imageWidth < MINIMUM_ICO_WIDTH && format.equals("ico")) { aspectRatio = (float) MINIMUM_ICO_WIDTH / (float)imageWidth; imageWidth = MINIMUM_ICO_WIDTH; imageHeight *= aspectRatio; if (imageHeight > maxImageHeight) { imageHeight = maxImageHeight; } } return createBufferedImage(image, type, imageWidth, imageHeight); } ImageConverter(String format, int imageType, int maxImageWidth, int maxImageHeight); String getFormat(); String getHtmlSrcImagePrefix(); static ImageConverter createConverter(String format, int maxImageWidth, int maxImageHeight); byte[] convertImageToByteArray(BufferedImage image); BufferedImage convertByteArrayToImage(byte[] bytes); BufferedImage resizeImage(BufferedImage image, int type); byte[] preprocessImage(BufferedImage image); String prepareHtmlImgSrc(byte[] avatar);  }### Answer:
@Test(dataProvider = "parameterResizeImage") public void testResizeImage(int maxWidth, int maxHeight, int imageType, String format) throws IOException { int expectedWidth = 4; int expectedHeight = 4; imageConverter = new ImageConverter(format, imageType, maxWidth, maxHeight); BufferedImage originalImage = ImageIO.read(new MockMultipartFile("test_image", "test_image", "image/png", originalImageByteArray).getInputStream()); Image modifiedImage = imageConverter.resizeImage(originalImage, imageType); assertEquals(modifiedImage.getWidth(null), expectedWidth); assertEquals(modifiedImage.getHeight(null), expectedHeight); }