NameBaseMimeResolver implements IPlatformMimeResolver { @Override public String resolveMimeForBundle( IPlatformImportBundle bundle ) { if ( bundle.getMimeType() != null ) { return bundle.getMimeType(); } else { IMimeType mimeType = extensionToMimeMap.get( extractExtension( bundle.getName() ) ); if ( mimeType == null ) { return null; } return mimeType.getName(); } } NameBaseMimeResolver(); @Override String resolveMimeForFileName( String fileName ); @Override String resolveMimeForBundle( IPlatformImportBundle bundle ); @Override IMimeType resolveMimeTypeForFileName( String fileName ); @Override void addMimeType( IMimeType mimeType );  }
@Test public void testResolveMimeForBundle_with_defined_mime_type() { IPlatformImportBundle bundle = mock( IPlatformImportBundle.class ); when( bundle.getMimeType() ).thenReturn( "bundle/mime-from-bundle" ); when( bundle.getName() ).thenReturn( "testFile.smt" ); String actualMime = resolver.resolveMimeForBundle( bundle ); assertEquals( actualMime, "bundle/mime-from-bundle" ); }
@Test public void testResolveMimeForBundle_without_defined_mime_type() { IPlatformImportBundle bundle = mock( IPlatformImportBundle.class ); when( bundle.getName() ).thenReturn( "testFile.smt" ); String actualMime = resolver.resolveMimeForBundle( bundle ); assertEquals( actualMime, "othertest/other-test-mime" ); }