BrandingMojo extends AbstractNbmMojo { static String destinationFileName( String brandingFilePath, String branding ) { int lastSeparator = brandingFilePath.lastIndexOf( File.separator ); String infix = "_" + branding; int lastDot = brandingFilePath.lastIndexOf( "." ); if (lastDot == -1 || lastDot < lastSeparator) { return brandingFilePath + infix; } return brandingFilePath.substring( 0, lastDot ) + infix + brandingFilePath.substring( lastDot ); }  void execute();  }
@Test public void testDestinationFileName() { assertEquals( "cut_brandingToken.gif", BrandingMojo.destinationFileName( "cut.gif", "brandingToken" ) ); assertEquals( "cut_brandingToken", BrandingMojo.destinationFileName( "cut", "brandingToken" ) ); assertEquals( "cut_pressed_brandingToken.gif", BrandingMojo.destinationFileName( "cut_pressed.gif", "brandingToken" ) ); assertEquals( "path1" + File.separator + "path2" + File.separator + "cut_brandingToken", BrandingMojo.destinationFileName( "path1" + File.separator + "path2" + File.separator + "cut", "brandingToken" ) ); assertEquals( "path.1" + File.separator + "path.2" + File.separator + "cut_brandingToken", BrandingMojo.destinationFileName( "path.1" + File.separator + "path.2" + File.separator + "cut", "brandingToken" ) ); assertEquals( "path.1" + File.separator + "cut_pressed_brandingToken.gif", BrandingMojo.destinationFileName( "path.1" + File.separator + "cut_pressed.gif", "brandingToken" ) ); }