|
1 | 1 | package com.baeldung.extension; |
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | | -import static org.junit.Assert.assertArrayEquals; |
5 | 4 | import static org.junit.Assert.assertEquals; |
6 | 5 |
|
7 | 6 | import java.util.Arrays; |
@@ -32,29 +31,28 @@ public void whenUsingTika_thenGetFileExtension() throws MimeTypeException { |
32 | 31 |
|
33 | 32 | @Test |
34 | 33 | public void whenUsingJodd_thenGetFileExtension() { |
35 | | - String[] expectedExtensions = {"jpeg","jpg","jpe"}; |
| 34 | + List<String> expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe"); |
36 | 35 | String[] detectedExtensions = jodd.net.MimeTypes.findExtensionsByMimeTypes(IMAGE_JPEG_MIME_TYPE, false); |
37 | | - assertThat(detectedExtensions).containsExactly(expectedExtensions); |
| 36 | + assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); |
38 | 37 | } |
39 | 38 |
|
40 | 39 | @Test |
41 | 40 | public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() { |
42 | | - String[] expectedExtensions = {"jpeg","jpg","jpe"}; |
| 41 | + List<String> expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe"); |
43 | 42 | ContentInfo contentInfo = new ContentInfo("", IMAGE_JPEG_MIME_TYPE, "", true); |
44 | 43 | String[] detectedExtensions = contentInfo.getFileExtensions(); |
45 | | - assertThat(detectedExtensions).containsExactly(expectedExtensions); |
| 44 | + assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); |
46 | 45 | } |
47 | 46 |
|
48 | 47 | @Test |
49 | 48 | public void whenUsingCustomLogic_thenGetFileExtension() { |
50 | 49 | Map<String, Set<String>> mimeExtensionsMap = new HashMap<>(); |
51 | | - Set<String> expectedExtensions = new HashSet<>(Arrays.asList(".jpeg",".jpg",".jpe")); |
52 | | - addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpeg"); |
| 50 | + List<String> expectedExtensions = Arrays.asList(".jpg", ".jpe", ".jpeg"); |
53 | 51 | addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpg"); |
54 | 52 | addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpe"); |
| 53 | + addMimeExtensions(mimeExtensionsMap, "image/jpeg", ".jpeg"); |
55 | 54 |
|
56 | | - String mimeTypeToLookup = "image/jpeg"; |
57 | | - Set<String> detectedExtensions = mimeExtensionsMap.get(mimeTypeToLookup); |
| 55 | + Set<String> detectedExtensions = mimeExtensionsMap.get(IMAGE_JPEG_MIME_TYPE); |
58 | 56 | assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); |
59 | 57 | } |
60 | 58 |
|
|
0 commit comments