### Question:
ColorExtractor { public ImageMetaInfo colorExtraction(final String path) throws IOException, InterruptedException { boolean success = true; int retry = 3; do { try { if (MediaChecker.getMimeType(path).startsWith("image")) { final ImageMetaInfo imageMetaInfo = MediaMetaDataUtils.extractImageMetadata(path, colorMapPath); return new ImageMetaInfo(null, null, null, null, null, null, imageMetaInfo.getColorPalette(), null); } } catch (Exception e) { e.printStackTrace(); if (retry > 0) { success = false; Thread.sleep(1000); retry = -1; } else { success = true; } } } while (!success); return null; } ColorExtractor(String colorMapPath); ImageMetaInfo colorExtraction(final String path);  }### Answer:
@Test public void test_ColorPaletteExtraction_Image1() throws Exception { final ImageMetaInfo metaInfo = new ColorExtractor(PATH_COLORMAP).colorExtraction(getPath(Image1)); assertNotNull("Image meta info must not be null!", metaInfo); assertNull(metaInfo.getMimeType()); assertNull(metaInfo.getFileSize()); assertNull(metaInfo.getWidth()); assertNull(metaInfo.getHeight()); assertArrayEquals(MediaChecker.getImageInfo(getPath(Image1), PATH_COLORMAP).getPalette(), metaInfo.getColorPalette()); assertNull(metaInfo.getColorSpace()); assertNull(metaInfo.getFileFormat()); }
@Test public void test_ColorPaletteExtraction_Image2() throws Exception { final ImageMetaInfo metaInfo = new ColorExtractor(PATH_COLORMAP).colorExtraction(getPath(Image2)); assertNotNull("Image meta info must not be null!", metaInfo); assertNull(metaInfo.getMimeType()); assertNull(metaInfo.getFileSize()); assertNull(metaInfo.getWidth()); assertNull(metaInfo.getHeight()); assertArrayEquals(MediaChecker.getImageInfo(getPath(Image2), PATH_COLORMAP).getPalette(), metaInfo.getColorPalette()); assertNull(metaInfo.getColorSpace()); assertNull(metaInfo.getFileFormat()); }
@Test public void test_ColorPaletteExtraction_FailForVideo() throws Exception { final ImageMetaInfo metaInfo = new ColorExtractor(PATH_COLORMAP).colorExtraction(getPath(Video1)); assertNull(metaInfo); }
@Test public void test_ColorPaletteExtraction_FailForPDF() throws Exception { final ImageMetaInfo metaInfo = new ColorExtractor(PATH_COLORMAP).colorExtraction(getPath(PDF1)); assertNull(metaInfo); }
@Test public void test_ColorPaletteExtraction_FailForTextPlain() throws Exception { final ImageMetaInfo metaInfo = new ColorExtractor(PATH_COLORMAP).colorExtraction(getPath(Text1)); assertNull(metaInfo); }