IconUtils { public static File findIcon( AbstractApplication app ) { return findIcon( app.getDirectory()); } private  IconUtils(); static String encodeIconUrl( String name, String version, File iconFile ); static Map.Entry<String,String> decodeIconUrl( String path ); static File findIcon( AbstractApplication app ); static String findIconUrl( AbstractApplication app ); static String findMimeType( File imgFile ); static File findIcon( File rootDirectory ); static final String MIME_JPG; static final String MIME_PNG; static final String MIME_SVG; static final String MIME_GIF; static final String MIME_BINARY; }
@Test public void testFindIcon_app() throws Exception { File appDir = this.folder.newFolder(); File descDir = new File( appDir, Constants.PROJECT_DIR_DESC ); Assert.assertTrue( descDir.mkdirs()); File trickFile = new File( descDir, "directory.jpg" ); Assert.assertTrue( trickFile.mkdirs()); Application app = new Application( "app", new TestApplicationTemplate()).directory( appDir ); Assert.assertNull( IconUtils.findIcon( app )); File singleJpgFile = new File( descDir, "whatever.jpg" ); Assert.assertTrue( singleJpgFile.createNewFile()); Assert.assertEquals( singleJpgFile, IconUtils.findIcon( app )); File defaultFile = new File( descDir, "application.sVg" ); Assert.assertTrue( defaultFile.createNewFile()); Assert.assertEquals( defaultFile, IconUtils.findIcon( app )); }
@Test public void testFindIcon_tpl() throws Exception { File appDir = this.folder.newFolder(); ApplicationTemplate tpl = new ApplicationTemplate( "app" ).version( "v1" ).directory( appDir ); File descDir = new File( appDir, Constants.PROJECT_DIR_DESC ); Assert.assertTrue( descDir.mkdirs()); File trickFile = new File( descDir, "file.txt" ); Assert.assertTrue( trickFile.createNewFile()); Assert.assertNull( IconUtils.findIcon( tpl )); File singleJpgFile = new File( descDir, "whatever.jpg" ); Assert.assertTrue( singleJpgFile.createNewFile()); Assert.assertEquals( singleJpgFile, IconUtils.findIcon( tpl )); File defaultFile = new File( descDir, "application.sVg" ); Assert.assertTrue( defaultFile.createNewFile()); Assert.assertEquals( defaultFile, IconUtils.findIcon( tpl )); Assert.assertNull( IconUtils.findIcon( new ApplicationTemplate( "app" ).version( "" ))); Assert.assertNull( IconUtils.findIcon( new ApplicationTemplate( "app" ).version( "" ))); Assert.assertNull( IconUtils.findIcon( new ApplicationTemplate( "app" ).version( "v2" ))); }
@Test public void testFindIcon_nullConfigDirectory() throws Exception { ApplicationTemplate tpl = new ApplicationTemplate( "app" ).version( "v1" ); Assert.assertNull( IconUtils.findIcon( tpl )); }