From 2b5199a2c6d8d51e214f2ff07f7a19c96ef0c7e8 Mon Sep 17 00:00:00 2001 From: rajatgarg Date: Thu, 7 Sep 2023 22:48:08 +0530 Subject: [PATCH] Address review comments --- .../extension/ExtensionFromMimeTypeUnitTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java index b476a56df8..f8f42861cc 100644 --- a/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java +++ b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java @@ -1,7 +1,6 @@ package com.baeldung.extension; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import java.util.Arrays; @@ -32,29 +31,28 @@ public class ExtensionFromMimeTypeUnitTest { @Test public void whenUsingJodd_thenGetFileExtension() { - String[] expectedExtensions = {"jpeg","jpg","jpe"}; + List expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe"); String[] detectedExtensions = jodd.net.MimeTypes.findExtensionsByMimeTypes(IMAGE_JPEG_MIME_TYPE, false); - assertThat(detectedExtensions).containsExactly(expectedExtensions); + assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); } @Test public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() { - String[] expectedExtensions = {"jpeg","jpg","jpe"}; + List expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe"); ContentInfo contentInfo = new ContentInfo("", IMAGE_JPEG_MIME_TYPE, "", true); String[] detectedExtensions = contentInfo.getFileExtensions(); - assertThat(detectedExtensions).containsExactly(expectedExtensions); + assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); } @Test public void whenUsingCustomLogic_thenGetFileExtension() { Map> mimeExtensionsMap = new HashMap<>(); - Set expectedExtensions = new HashSet<>(Arrays.asList(".jpeg",".jpg",".jpe")); - addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpeg"); + List expectedExtensions = Arrays.asList(".jpg", ".jpe", ".jpeg"); addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpg"); addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpe"); + addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpeg"); - String mimeTypeToLookup = "image/jpeg"; - Set detectedExtensions = mimeExtensionsMap.get(mimeTypeToLookup); + Set detectedExtensions = mimeExtensionsMap.get(IMAGE_JPEG_MIME_TYPE); assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); }