@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 testFindIconUrl() throws Exception { // Create fake icons ApplicationTemplate tpl = new ApplicationTemplate( "tpl" ).version( "v1" ).directory( this.folder.newFolder()); File descDir = new File( tpl.getDirectory(), Constants.PROJECT_DIR_DESC ); Assert.assertTrue( descDir.mkdirs()); Assert.assertTrue( new File( descDir, "tp.jpg" ).createNewFile()); Application app = new Application( "app", tpl ).directory( this.folder.newFolder()); descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC ); Assert.assertTrue( descDir.mkdirs()); Assert.assertTrue( new File( descDir, "whatever.jpg" ).createNewFile()); // Check the URLs Assert.assertEquals( "/tpl/v1/tp.jpg", IconUtils.findIconUrl( tpl )); Assert.assertEquals( "/app/whatever.jpg", IconUtils.findIconUrl( app )); // And we delete the icon Utils.deleteFilesRecursively( descDir ); Assert.assertEquals( "", IconUtils.findIconUrl( app )); }