MimeTypeManagerImpl implements MimeTypeManager { @Override public boolean isMimeTypeCompliant(final MimeType mimeType, final Collection<String> availableMimeTypes) { return mimeType == null || isNullOrEmpty(mimeType.getMimeType()) || isCompliant(mimeType, availableMimeTypes) || isAliasMimeTypeCompliant(mimeType, availableMimeTypes); } @Inject  MimeTypeManagerImpl(final MimeTypeDao mimeTypeDao); @Override MimeType getMimeType(final String fileName); @Override boolean isMimeTypeCompliant(final MimeType mimeType, final Collection<String> availableMimeTypes);  }
@Test public void testIsMimeTypeCompliant() { MimeTypeManager mimeTypeManager = new MimeTypeManagerImpl(new MimeTypeDaoImpl("/mimetypes.properties")); MimeType mimeType = MimeType.valueOf("video/avi"); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("video/avi"))); assertFalse(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("audio/mpeg"))); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, new ArrayList<>(0))); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, null)); assertTrue(mimeTypeManager.isMimeTypeCompliant(null, null)); mimeType = MimeType.valueOf("video/x-msvideo"); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("video/avi"))); assertFalse(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("audio/mpeg"))); mimeType = MimeType.valueOf(""); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("video/avi"))); mimeType = MimeType.valueOf("audio/mpeg"); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("audio/mpeg"))); assertTrue(mimeTypeManager.isMimeTypeCompliant(mimeType, newArrayList("audio*"))); }