LocaleFilesProcessor { public void processLocaleFiles( IPlatformImporter importer ) throws PlatformImportException { RepositoryFileImportBundle.Builder bundleBuilder = new RepositoryFileImportBundle.Builder(); IPlatformMimeResolver mimeResolver = PentahoSystem.get( IPlatformMimeResolver.class ); String mimeType = mimeResolver.resolveMimeForFileName( FILE_LOCALE_RESOLVER ); List<String> filesWithLocaleFiles = new ArrayList<>(); for ( LocaleFileDescriptor localeFile : localeFiles ) { String extension = localeFile.getExtension(); if ( !StringUtils.isEmpty( extension ) && extension.equals( LOCALE_EXT ) ) { String actualFileName = localeFile.getFile().getName().indexOf( "." ) != -1 ? localeFile.getFile().getName().substring( 0, localeFile.getFile().getName().indexOf( "." ) ) : localeFile.getFile().getName(); filesWithLocaleFiles.add( localeFile.getPath() + actualFileName ); } } for ( LocaleFileDescriptor localeFile : localeFiles ) { String extension = localeFile.getExtension(); if ( !StringUtils.isEmpty( extension ) && extension.equals( PROPERTIES_EXT ) ) { String actualFileName = localeFile.getFile().getName().indexOf( "." ) != -1 ? localeFile.getFile().getName().substring( 0, localeFile.getFile().getName().indexOf( "." ) ) : localeFile.getFile().getName(); if ( filesWithLocaleFiles.contains( localeFile.getPath() + actualFileName ) ) { continue; } } proceed( importer, bundleBuilder, mimeType, localeFile ); } } LocaleFilesProcessor(); boolean isLocaleFile( IRepositoryFileBundle file, String parentPath, byte[] bytes ); Properties loadProperties( InputStream inputStream ); boolean createLocaleEntry( String filePath, String name, String title, String description,
      RepositoryFile file, InputStream is ); boolean createLocaleEntry( String filePath, String name, String title, String description,
      RepositoryFile file, InputStream is, int sourceVersion ); void processLocaleFiles( IPlatformImporter importer );  }
@Test public void testProcessLocaleFilesTwoLocaleFiles() throws Exception { IRepositoryContentConverterHandler converterHandler = new DefaultRepositoryContentConverterHandler( new HashMap<String, Converter>() ); List<IMimeType> localeMimeList = new ArrayList<IMimeType>(); localeMimeList.add( new MimeType( "text/locale", "locale" ) ); LocaleImportHandler localeImportHandler = new LocaleImportHandler( localeMimeList, null ); LocaleImportHandler localeImportHandlerSpy = spy( localeImportHandler ); Log log = mock( Log.class ); doReturn( log ).when( localeImportHandlerSpy ).getLogger(); String localeFileName = "SampleTransformationWithParameters"; List<IPlatformImportHandler> handlers = new ArrayList<IPlatformImportHandler>(); handlers.add( localeImportHandlerSpy ); importer = new PentahoPlatformImporter( handlers, converterHandler ); importer.setRepositoryImportLogger( new Log4JRepositoryImportLogger() ); localeFilesProcessor = new LocaleFilesProcessor(); StringBuffer localePropertiesContent = new StringBuffer(); localePropertiesContent.append( "description=This runs a simple Kettle transformation filtering records from the Quandrant_Actuals sample data " + "table, and sending a Hello message to each position.\n" ); localePropertiesContent.append( "name=1. Hello ETL" ); assertTrue( processIsLocalFile( "SampleTransformation.properties", localePropertiesContent ) ); StringBuffer localeContent = new StringBuffer(); localeContent.append( "file.title=" + localeFileName + "\n" ); localeContent.append( "title=SampleTransformation\n" ); localeContent.append( "file.description=" ); assertTrue( processIsLocalFile( "SampleTransformation.xaction.locale", localeContent ) ); localeFilesProcessor.processLocaleFiles( importer ); Mockito.verify( localeImportHandlerSpy, times( 1 ) ).importFile( any( IPlatformImportBundle.class ) ); ArgumentCaptor<IPlatformImportBundle> argument = ArgumentCaptor.forClass( IPlatformImportBundle.class ); Mockito.verify( localeImportHandlerSpy ).importFile( argument.capture() ); assertEquals( localeFileName, argument.getValue().getName() ); }