src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void deleteAllVersions( RepositoryElementInterface element ) throws KettleException { Serializable fileId = element.getObjectId().getId(); deleteAllVersions( fileId ); } UnifiedRepositoryPurgeService( IUnifiedRepository unifiedRepository ); @Over...
@Test public void deleteAllVersionsTest() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); Strin...
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void deleteVersion( RepositoryElementInterface element, String versionId ) throws KettleException { String fileId = element.getObjectId().getId(); deleteVersion( fileId, versionId ); } UnifiedRepositoryPurgeService( IUnifiedRepository unifiedRepo...
@Test public void deleteVersionTest() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); String fi...
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void keepNumberOfVersions( RepositoryElementInterface element, int versionCount ) throws KettleException { String fileId = element.getObjectId().getId(); keepNumberOfVersions( fileId, versionCount ); } UnifiedRepositoryPurgeService( IUnifiedRepos...
@Test public void keepNumberOfVersions0Test() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); S...
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void deleteVersionsBeforeDate( RepositoryElementInterface element, Date beforeDate ) throws KettleException { try { Serializable fileId = element.getObjectId().getId(); deleteVersionsBeforeDate( fileId, beforeDate ); } catch ( Exception e ) { pro...
@Test public void deleteVersionsBeforeDate() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); St...
UnifiedRepositoryPurgeService implements IPurgeService { public void doDeleteRevisions( PurgeUtilitySpecification purgeSpecification ) throws PurgeDeletionException { if ( purgeSpecification != null ) { getLogger().setCurrentFilePath( purgeSpecification.getPath() ); logConfiguration( purgeSpecification ); if ( purgeSpe...
@Test public void doPurgeUtilVersionCountTest() throws PurgeDeletionException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = getPurgeService( mockRepo ); PurgeUtili...
RepositoryConnectController { @SuppressWarnings( "unchecked" ) public String getPlugins() { List<PluginInterface> plugins = pluginRegistry.getPlugins( RepositoryPluginType.class ); JSONArray list = new JSONArray(); for ( PluginInterface pluginInterface : plugins ) { if ( !pluginInterface.getIds()[0].equals( "PentahoEnt...
@Test public void testGetPlugins() throws Exception { String plugins = controller.getPlugins(); assertEquals( "[{\"name\":\"PLUGIN NAME\",\"description\":\"PLUGIN DESCRIPTION\",\"id\":\"ID\"}]", plugins ); }
RepositoryConnectController { public boolean createRepository( String id, Map<String, Object> items ) { try { RepositoryMeta repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ); repositoryMeta.populate( items, repositoriesMeta ); if ( repositoryMeta.getName() != null ) { Re...
@Test public void testCreateRepository() throws Exception { String id = ID; Map<String, Object> items = new HashMap<>(); when( pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ) ) .thenReturn( repositoryMeta ); when( pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getI...
RepositoryConnectController { @SuppressWarnings( "unchecked" ) public String getRepositories() { JSONArray list = new JSONArray(); if ( repositoriesMeta != null ) { for ( int i = 0; i < repositoriesMeta.nrRepositories(); i++ ) { list.add( repositoriesMeta.getRepository( i ).toJSONObject() ); } } return list.toString();...
@Test public void testGetRepositories() { when( repositoriesMeta.nrRepositories() ).thenReturn( 1 ); when( repositoriesMeta.getRepository( 0 ) ).thenReturn( repositoryMeta ); JSONObject json = new JSONObject(); json.put( "displayName", REPOSITORY_NAME ); json.put( "isDefault", false ); json.put( "description", REPOSITO...
RepositoryConnectController { public void connectToRepository() throws KettleException { connectToRepository( currentRepository ); } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier, RepositoriesMeta repositoriesMeta ); RepositoryConnectCon...
@Test public void testConnectToRepository() throws Exception { when( pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ) ) .thenReturn( repository ); controller.setCurrentRepository( repositoryMeta ); controller.connectToRepository(); verify( repository ).init( repositoryMet...
RepositoryConnectController { @SuppressWarnings( "unchecked" ) public String getDatabases() { JSONArray list = new JSONArray(); for ( int i = 0; i < repositoriesMeta.nrDatabases(); i++ ) { JSONObject databaseJSON = new JSONObject(); databaseJSON.put( "name", repositoriesMeta.getDatabase( i ).getName() ); list.add( data...
@Test public void testGetDatabases() throws Exception { when( repositoriesMeta.nrDatabases() ).thenReturn( 1 ); when( repositoriesMeta.getDatabase( 0 ) ).thenReturn( databaseMeta ); when( databaseMeta.getName() ).thenReturn( DATABASE_NAME ); String databases = controller.getDatabases(); assertEquals( "[{\"name\":\"DATA...
RepositoryConnectController { public boolean deleteRepository( String name ) { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name ); int index = repositoriesMeta.indexOfRepository( repositoryMeta ); if ( index != -1 ) { Spoon spoon = spoonSupplier.get(); if ( spoon.getRepositoryName() != null && spoo...
@Test public void testDeleteRepository() throws Exception { int index = 1; when( repositoriesMeta.findRepository( REPOSITORY_NAME ) ).thenReturn( repositoryMeta ); when( repositoriesMeta.indexOfRepository( repositoryMeta ) ).thenReturn( index ); when( repositoriesMeta.getRepository( index ) ).thenReturn( repositoryMeta...
RepositoryConnectController { public boolean setDefaultRepository( String name ) { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name ); for ( int i = 0; i < repositoriesMeta.nrRepositories(); i++ ) { repositoriesMeta.getRepository( i ).setDefault( false ); } if ( repositoryMeta != null ) { repositor...
@Test public void testSetDefaultRepository() { int index = 1; when( repositoriesMeta.findRepository( REPOSITORY_NAME ) ).thenReturn( repositoryMeta ); when( repositoriesMeta.indexOfRepository( repositoryMeta ) ).thenReturn( index ); boolean result = controller.setDefaultRepository( REPOSITORY_NAME ); assertEquals( true...
RepositoryConnectController { public void addDatabase( DatabaseMeta databaseMeta ) { if ( databaseMeta != null ) { repositoriesMeta.addDatabase( databaseMeta ); save(); } } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier, RepositoriesMeta r...
@Test public void testAddDatabase() throws Exception { controller.addDatabase( databaseMeta ); verify( repositoriesMeta ).addDatabase( databaseMeta ); verify( repositoriesMeta ).writeData(); }
RepositoryConnectController { public String getDefaultUrl() { ResourceBundle resourceBundle = PropertyResourceBundle.getBundle( PKG.getPackage().getName() + ".plugin" ); return resourceBundle.getString( DEFAULT_URL ); } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier, ...
@Test public void testGetDefaultUrl() throws Exception { String defaultUrl = controller.getDefaultUrl(); assertNotNull( defaultUrl ); }
StepWithMappingMeta extends BaseStepMeta { public static TransMeta loadMappingMeta( StepWithMappingMeta mappingMeta, Repository rep, IMetaStore metaStore, VariableSpace space ) throws KettleException { return loadMappingMeta( mappingMeta, rep, metaStore, space, true ); } static TransMeta loadMappingMeta( StepWithMappi...
@Test public void loadMappingMeta() throws Exception { String variablePath = "Internal.Entry.Current.Directory"; String virtualDir = "/testFolder/CDA-91"; String fileName = "testTrans.ktr"; VariableSpace variables = new Variables(); variables.setVariable( variablePath, virtualDir ); StepWithMappingMeta mappingMetaMock ...
RepositoryConnectController { public String getRepository( String name ) { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name ); if ( repositoryMeta != null ) { currentRepository = repositoryMeta; return repositoryMeta.toJSONObject().toString(); } return ""; } RepositoryConnectController( PluginRegis...
@Test public void testGetRepository() throws Exception { KettleFileRepositoryMeta kettleFileRepositoryMeta = new KettleFileRepositoryMeta(); kettleFileRepositoryMeta.setId( REPOSITORY_ID ); kettleFileRepositoryMeta.setDescription( REPOSITORY_DESCRIPTION ); kettleFileRepositoryMeta.setName( REPOSITORY_NAME ); when( repo...
RepositoryConnectController { @VisibleForTesting boolean isDatabaseWithNameExist( DatabaseMeta databaseMeta, boolean isNew ) { for ( int i = 0; i < repositoriesMeta.nrDatabases(); i++ ) { final DatabaseMeta iterDatabase = repositoriesMeta.getDatabase( i ); if ( iterDatabase.getName().trim().equalsIgnoreCase( databaseMe...
@Test public void testIsDatabaseWithNameExist() throws Exception { final DatabaseMeta databaseMeta1 = new DatabaseMeta(); databaseMeta1.setName( "TestDB1" ); controller.addDatabase( databaseMeta1 ); final DatabaseMeta databaseMeta2 = new DatabaseMeta(); databaseMeta2.setName( "TestDB2" ); controller.addDatabase( databa...
RepositorySessionTimeoutHandler implements InvocationHandler { boolean connectedToRepository() { return repository.isConnected(); } RepositorySessionTimeoutHandler( ReconnectableRepository repository, RepositoryConnectController repositoryConnectController ); @SuppressWarnings( "unchecked" ) @Override Object invo...
@Test public void connectedToRepository() { when( repository.isConnected() ).thenReturn( true ); assertTrue( timeoutHandler.connectedToRepository() ); } @Test public void connectedToRepositoryReturnsFalse() { when( repository.isConnected() ).thenReturn( false ); assertFalse( timeoutHandler.connectedToRepository() ); }
RepositorySessionTimeoutHandler implements InvocationHandler { static IMetaStore wrapMetastoreWithTimeoutHandler( IMetaStore metaStore, SessionTimeoutHandler sessionTimeoutHandler ) { MetaStoreSessionTimeoutHandler metaStoreSessionTimeoutHandler = new MetaStoreSessionTimeoutHandler( metaStore, sessionTimeoutHandler ); ...
@Test public void wrapMetastoreWithTimeoutHandler() throws Throwable { IMetaStore metaStore = mock( IMetaStore.class ); doThrow( KettleRepositoryLostException.class ).when( metaStore ).createNamespace( any() ); SessionTimeoutHandler sessionTimeoutHandler = mock( SessionTimeoutHandler.class ); IMetaStore wrappedMetaStor...
RepositoryServiceSessionTimeoutHandler implements InvocationHandler { @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { try { return method.invoke( repositoryService, args ); } catch ( InvocationTargetException ex ) { return sessionTimeoutHandler.handle( repositoryService, ...
@SuppressWarnings( "unchecked" ) @Test public void testHandlerCallOnException() throws Throwable { when( repositoryService.getUsers() ).thenThrow( KettleRepositoryLostException.class ); Method method = RepositorySecurityManager.class.getMethod( "getUsers" ); metaStoresessionTimeoutHandler.invoke( mock( Proxy.class ), m...
SessionTimeoutHandler { public Object handle( Object objectToHandle, Throwable exception, Method method, Object[] args ) throws Throwable { if ( lookupForConnectTimeoutError( exception ) && !calledFromThisHandler() ) { try { return method.invoke( objectToHandle, args ); } catch ( InvocationTargetException ex2 ) { if ( ...
@Test public void handle() throws Throwable { when( repository.readTransSharedObjects( any() ) ).thenReturn( mock( SharedObjects.class ) ); Method method = Repository.class.getMethod( "readTransSharedObjects", TransMeta.class ); sessionTimeoutHandler.handle( repository, mock( Exception.class ), method, new Object[] { m...
MetaStoreSessionTimeoutHandler implements InvocationHandler { @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { try { return method.invoke( metaStore, args ); } catch ( InvocationTargetException ex ) { return sessionTimeoutHandler.handle( metaStore, ex.getCause(), method, a...
@SuppressWarnings( "unchecked" ) @Test public void testHandlerCallOnException() throws Throwable { when( metaStore.getName() ).thenThrow( KettleRepositoryLostException.class ); Method method = IMetaStore.class.getMethod( "getName" ); metaStoresessionTimeoutHandler.invoke( mock( Proxy.class ), method, new Object[0] ); v...
Log4jPipedAppender implements Appender { public void setPipedOutputStream( PipedOutputStream pipedOutputStream ) { this.pipedOutputStream = pipedOutputStream; } Log4jPipedAppender(); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName...
@Test public void setPipedOutputStream() { PipedOutputStream pipedOutputStream = new PipedOutputStream(); log4jPipedAppender.setPipedOutputStream( pipedOutputStream ); assertThat( log4jPipedAppender.getPipedOutputStream(), is( pipedOutputStream ) ); }
Log4jPipedAppender implements Appender { public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { pipedOutputStream.write( line.getBytes() ); } catch ( IOException e ) { System.out.println( "Unable to write to piped output stream : " + e.getMessage() ); } } Log4jPipedAppender(...
@Test public void doAppend() throws IOException { PipedOutputStream pipedOutputStream = mock( PipedOutputStream.class ); LoggingEvent loggingEvent = mock( LoggingEvent.class ); Layout testLayout = mock( Layout.class ); when( testLayout.format( loggingEvent ) ).thenReturn( "LOG_TEST_LINE" ); log4jPipedAppender.setLayout...
SubtransExecutor { public Result execute( List<RowMetaAndData> rows ) throws KettleException { if ( rows.isEmpty() ) { return null; } this.transExecutorData.groupTimeStart = System.currentTimeMillis(); Trans subtrans = this.createSubtrans(); this.transExecutorData.setExecutorTrans( subtrans ); passParametersToTrans( su...
@Test public void testRunsATrans() throws Exception { TransMeta parentMeta = new TransMeta( this.getClass().getResource( "subtrans-executor-parent.ktr" ).getPath(), new Variables() ); TransMeta subMeta = new TransMeta( this.getClass().getResource( "subtrans-executor-sub.ktr" ).getPath(), new Variables() ); LoggingObjec...
Log4jPipedAppender implements Appender { public void close() { try { pipedOutputStream.close(); } catch ( IOException e ) { System.out.println( "Unable to close piped output stream: " + e.getMessage() ); } } Log4jPipedAppender(); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); vo...
@Test public void close() throws IOException { PipedOutputStream pipedOutputStream = mock( PipedOutputStream.class ); log4jPipedAppender.setPipedOutputStream( pipedOutputStream ); log4jPipedAppender.close(); verify( pipedOutputStream ).close(); }
Log4jLogging implements LoggingPluginInterface { @Override public void eventAdded( KettleLoggingEvent event ) { switch ( event.getLevel() ) { case ERROR: pentahoLogger.log( Level.ERROR, event.getMessage() ); break; case DEBUG: case ROWLEVEL: pentahoLogger.log( Level.DEBUG, event.getMessage() ); break; default: pentahoL...
@Test public void eventAddedError() { log4jPlugin.eventAdded( new KettleLoggingEvent( "ERROR_TEST_MESSAGE", 0L, LogLevel.ERROR ) ); verify( logger ).log( Level.ERROR, "ERROR_TEST_MESSAGE" ); } @Test public void eventAddedDebug() { log4jPlugin.eventAdded( new KettleLoggingEvent( "DEBUG_TEST_MESSAGE", 0L, LogLevel.DEBUG ...
Log4jKettleLayout extends Layout implements Log4JLayoutInterface { public String format( LoggingEvent event ) { StringBuffer line = new StringBuffer(); String dateTimeString = ""; if ( timeAdded ) { dateTimeString = LOCAL_SIMPLE_DATE_PARSER.get().format( new Date( event.timeStamp ) ) + " - "; } Object object = event.ge...
@Test public void formatNonLogMessage_without_add_time() { Log4jKettleLayout layout = new Log4jKettleLayout( false ); String actualResult = layout.format( mock( LoggingEvent.class ) ); assertThat( actualResult, equalTo( "<null>" ) ); } @Test public void formatNonLogMessage_with_add_time() { Log4jKettleLayout layout = n...
TransExecutionConfiguration implements ExecutionConfiguration { public Repository connectRepository( RepositoriesMeta repositoriesMeta, String repositoryName, String username, String password ) throws KettleException { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( repositoryName ); if ( repositoryMet...
@Test public void testConnectRepository() throws KettleException { TransExecutionConfiguration transExecConf = new TransExecutionConfiguration(); final RepositoriesMeta repositoriesMeta = mock( RepositoriesMeta.class ); final RepositoryMeta repositoryMeta = mock( RepositoryMeta.class ); final Repository repository = mo...
Log4jFileAppender implements Appender { public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { fileOutputStream.write( line.getBytes( Const.XML_ENCODING ) ); } catch ( IOException e ) { System.out.println( "Unable to close Logging file [" + file.getName() + "] : " + e.getMes...
@Test public void doAppend() throws IOException { LoggingEvent loggingEvent = mock( LoggingEvent.class ); Layout testLayout = mock( Layout.class ); when( testLayout.format( loggingEvent ) ).thenReturn( "LOG_TEST_LINE" ); log4jFileAppender.setLayout( testLayout ); log4jFileAppender.doAppend( loggingEvent ); verify( outp...
Log4jFileAppender implements Appender { public void close() { try { fileOutputStream.close(); } catch ( IOException e ) { System.out.println( "Unable to close Logging file [" + file.getName() + "] : " + e.getMessage() ); } } Log4jFileAppender( FileObject file ); Log4jFileAppender( FileObject file, boolean append ); vo...
@Test public void close() throws IOException { log4jFileAppender.close(); verify( outputStream ).close(); }
KettleReportBuilder { public void createReport() throws Exception { report = new MasterReport(); KettleFileTableModel transMetaTableModel = new KettleFileTableModel( parentObject, filenames ); TableDataFactory dataFactory = new TableDataFactory( "default", transMetaTableModel ); report.setDataFactory( dataFactory ); Re...
@Test public void createReport() throws Exception { LoggingObjectInterface log = mock( LoggingObjectInterface.class ); AutoDocOptionsInterface options = mock( AutoDocOptionsInterface.class ); when( options.isIncludingImage() ).thenReturn( Boolean.TRUE ); KettleReportBuilder builder = new KettleReportBuilder( log, Colle...
ElasticSearchBulkMeta extends BaseStepMeta implements StepMetaInterface { public int getBatchSizeInt( VariableSpace vars ) { return Const.toInt( vars.environmentSubstitute( this.batchSize ), DEFAULT_BATCH_SIZE ); } ElasticSearchBulkMeta(); String getJsonField(); void setJsonField( String jsonField ); String getIdOutFie...
@Test public void testGetBatchSizeInt() { ElasticSearchBulkMeta esbm = new ElasticSearchBulkMeta(); int batchSize = esbm.getBatchSizeInt( new VariableSpaceImpl() ); assertEquals( batchSize, ElasticSearchBulkMeta.DEFAULT_BATCH_SIZE ); }
ElasticSearchBulkMeta extends BaseStepMeta implements StepMetaInterface { public Object clone() { ElasticSearchBulkMeta retval = (ElasticSearchBulkMeta) super.clone(); return retval; } ElasticSearchBulkMeta(); String getJsonField(); void setJsonField( String jsonField ); String getIdOutField(); void setIdOutField( Stri...
@Test public void testClone() { ElasticSearchBulkMeta esbm = new ElasticSearchBulkMeta(); ElasticSearchBulkMeta esbmClone = (ElasticSearchBulkMeta) esbm.clone(); assertNotNull( esbmClone ); }
ElasticSearchBulkMeta extends BaseStepMeta implements StepMetaInterface { public boolean supportsErrorHandling() { return true; } ElasticSearchBulkMeta(); String getJsonField(); void setJsonField( String jsonField ); String getIdOutField(); void setIdOutField( String idField ); boolean isJsonInsert(); void setJsonInser...
@Test public void testSupportsErrorHandling() { ElasticSearchBulkMeta esbm = new ElasticSearchBulkMeta(); boolean supportsError = esbm.supportsErrorHandling(); assertTrue( supportsError ); }
ElasticSearchBulkMeta extends BaseStepMeta implements StepMetaInterface { public StepDataInterface getStepData() { return new ElasticSearchBulkData(); } ElasticSearchBulkMeta(); String getJsonField(); void setJsonField( String jsonField ); String getIdOutField(); void setIdOutField( String idField ); boolean isJsonInse...
@Test public void testGetStepData() { ElasticSearchBulkMeta esbm = new ElasticSearchBulkMeta(); StepDataInterface sdi = esbm.getStepData(); assertTrue( sdi instanceof ElasticSearchBulkData ); }
GlobalMessages extends AbstractMessageHandler { public static ResourceBundle getBundle( String packageName ) throws MissingResourceException { return getBundle( packageName, GlobalMessages.getInstance().getClass() ); } GlobalMessages(); static synchronized MessageHandler getInstance(); static synchronized Locale getLoc...
@Test public void testGetBundleNewUTF8() throws Exception { res = GlobalMessages.getBundle( Locale.JAPAN, "org/pentaho/di/i18n/messages/test_utf8_messages" ); assertEquals( "環境変数の選択", res.getString( "System.Dialog.SelectEnvironmentVar.Title" ) ); res = GlobalMessages.getBundle( Locale.CHINA, "org/pentaho/di/i18n/messag...
MetaStoreConst { public static IMetaStore openLocalPentahoMetaStore() throws MetaStoreException { return MetaStoreConst.openLocalPentahoMetaStore( true ); } static final String getDefaultPentahoMetaStoreLocation(); static IMetaStore openLocalPentahoMetaStore(); static IMetaStore openLocalPentahoMetaStore( boolean allo...
@Test public void testOpenLocalPentahoMetaStore() throws Exception { MetaStoreConst.disableMetaStore = false; File tempDir = Files.createTempDir(); String tempPath = tempDir.getAbsolutePath(); System.setProperty( Const.PENTAHO_METASTORE_FOLDER, tempPath ); String metaFolder = tempPath + File.separator + XmlUtil.META_FO...
TransExecutionConfiguration implements ExecutionConfiguration { public Long getPassedBatchId() { return passedBatchId; } TransExecutionConfiguration(); TransExecutionConfiguration( Node trecNode ); Object clone(); Map<String, String> getArguments(); void setArguments( Map<String, String> arguments ); void setParams( M...
@Test public void testDefaultPassedBatchId() { TransExecutionConfiguration tec = new TransExecutionConfiguration(); assertEquals( "default passedBatchId value must be null", null, tec.getPassedBatchId() ); }
StringObjectId implements ObjectId, Comparable<StringObjectId> { public StringObjectId( String id ) { this.id = id; } StringObjectId( String id ); StringObjectId( ObjectId objectId ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override int compareTo( StringObjectId o ); @Override String toStrin...
@Test public void testStringObjectId() { String expectedId = UUID.randomUUID().toString(); StringObjectId obj = new StringObjectId( expectedId ); assertEquals( expectedId, obj.getId() ); assertEquals( expectedId, obj.toString() ); assertEquals( expectedId.hashCode(), obj.hashCode() ); assertFalse( obj.equals( null ) );...
Condition implements Cloneable, XMLInterface { public boolean evaluate( RowMetaInterface rowMeta, Object[] r ) { boolean retval = false; try { if ( isAtomic() ) { if ( function == FUNC_TRUE ) { return !negate; } if ( left_valuename != null && left_valuename.length() > 0 ) { left_fieldnr = rowMeta.indexOfValue( left_val...
@Test public void testNegatedTrueFuncEvaluatesAsFalse() throws Exception { String left = "test_filed"; String right = "test_value"; int func = Condition.FUNC_TRUE; boolean negate = true; Condition condition = new Condition( negate, left, func, right, null ); assertFalse( condition.evaluate( new RowMeta(), new Object[]{...
DateCache { public DateCache() { cache = new HashMap<String, Date>(); } DateCache(); void populate( String datePattern, int fromYear, int toYear ); void addDate( String dateString, Date date ); Date lookupDate( String dateString ); int getSize(); static void main( String[] args ); }
@SuppressWarnings( "deprecation" ) @Test public void testDateCache() { DateCache cache = new DateCache(); cache.populate( "yyyy-MM-dd", 2016, 2016 ); assertEquals( 366, cache.getSize() ); assertEquals( Calendar.FEBRUARY, cache.lookupDate( "2016-02-29" ).getMonth() ); assertEquals( 29, cache.lookupDate( "2016-02-29" ).g...
LookupReferencesException extends KettleException { public String objectTypePairsToString() { StringBuilder result = new StringBuilder(); for ( Map.Entry entry : objectTypePairs.entrySet() ) { if ( entry.getKey() != null ) { result.append( Const.CR ); result.append( "\"" ); result.append( entry.getKey() ); result.appen...
@Test public void testObjectTypePairsToString() throws Exception { Exception cause = new NullPointerException(); Map<String, RepositoryObjectType> notFoundedReferences = new LinkedHashMap<String, RepositoryObjectType>(); String pathToTransStub = "/path/Trans.ktr"; String pathToJobStub = "/path/Job.ktr"; notFoundedRefer...
FileInputList { public String[] getUrlStrings() { String[] fileStrings = new String[ files.size() ]; for ( int i = 0; i < fileStrings.length; i++ ) { fileStrings[ i ] = files.get( i ).getPublicURIString(); } return fileStrings; } static String getRequiredFilesDescription( List<FileObject> nonExistantFiles ); static St...
@Test public void testGetUrlStrings() throws Exception { String sFileA = "hdfs: String sFileB = "file: FileObject fileA = mock( FileObject.class ); FileObject fileB = mock( FileObject.class ); when( fileA.getPublicURIString() ).thenReturn( sFileA ); when( fileB.getPublicURIString() ).thenReturn( sFileB ); FileInputList...
Const { public static String initCap( String string ) { StringBuilder change = new StringBuilder( string ); boolean new_word; int i; char lower, upper, ch; new_word = true; for ( i = 0; i < string.length(); i++ ) { lower = change.substring( i, i + 1 ).toLowerCase().charAt( 0 ); upper = change.substring( i, i + 1 ).toUp...
@Test public void testInitCap() { assertEquals( "Sven", Const.initCap( "Sven" ) ); assertEquals( "Matt", Const.initCap( "MATT" ) ); assertEquals( "Sven Boden", Const.initCap( "sven boden" ) ); assertEquals( "Sven Boden ", Const.initCap( "sven boden " ) ); assertEquals( "Sven Boden Was Here", Const.initCap( "sven boden ...
Const { public static String[] sortStrings( String[] input ) { Arrays.sort( input ); return input; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, ...
@Test public void testSortStrings() { String[] arr1 = { "Red", "Blue", "Black", "Black", "Green" }; String[] arr2 = { "aaa", "zzz", "yyy", "sss", "ttt", "t" }; String[] arr3 = { "A", "B", "C", "D" }; String[] results = Const.sortStrings( arr1 ); assertTrue( isArraySorted( arr1 ) ); assertTrue( isArraySorted( results ) ...
Const { @Deprecated public static boolean isEmpty( String val ) { return Utils.isEmpty( val ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int ...
@Test public void testIsEmpty() { assertTrue( Const.isEmpty( (String) null ) ); assertTrue( Const.isEmpty( "" ) ); assertFalse( Const.isEmpty( "test" ) ); } @Test public void testIsEmptyStringArray() { assertTrue( Const.isEmpty( (String[]) null ) ); assertTrue( Const.isEmpty( new String[] {} ) ); assertFalse( Const.isE...
TransMetaConverter { public static Transformation convert( TransMeta transMeta ) { final org.pentaho.di.engine.model.Transformation transformation = new org.pentaho.di.engine.model.Transformation( createTransformationId( transMeta ) ); try { TransMeta copyTransMeta = (TransMeta) transMeta.realClone( false ); cleanupDis...
@Test public void simpleConvert() { TransMeta meta = new TransMeta(); meta.setFilename( "fileName" ); meta.addStep( new StepMeta( "stepName", stepMetaInterface ) ); Transformation trans = TransMetaConverter.convert( meta ); assertThat( trans.getId(), is( meta.getFilename() ) ); assertThat( trans.getOperations().size(),...
Const { public static String NVL( String source, String def ) { if ( source == null || source.length() == 0 ) { return def; } return source; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ...
@Test public void testNVL() { assertNull( Const.NVL( null, null ) ); assertEquals( "test", Const.NVL( "test", "test1" ) ); assertEquals( "test", Const.NVL( "test", null ) ); assertEquals( "test1", Const.NVL( null, "test1" ) ); }
Const { public static int nrSpacesBefore( String field ) { int nr = 0; int len = field.length(); while ( nr < len && field.charAt( nr ) == ' ' ) { nr++; } return nr; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int ...
@Test public void testNrSpacesBefore() { try { Const.nrSpacesBefore( null ); fail( "Expected NullPointerException" ); } catch ( NullPointerException ex ) { } assertEquals( 0, Const.nrSpacesBefore( "" ) ); assertEquals( 1, Const.nrSpacesBefore( " " ) ); assertEquals( 3, Const.nrSpacesBefore( " " ) ); assertEquals( 0, Co...
Const { public static int nrSpacesAfter( String field ) { int nr = 0; int len = field.length(); while ( nr < len && field.charAt( field.length() - 1 - nr ) == ' ' ) { nr++; } return nr; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round...
@Test public void testNrSpacesAfter() { try { Const.nrSpacesAfter( null ); fail( "Expected NullPointerException" ); } catch ( NullPointerException ex ) { } assertEquals( 0, Const.nrSpacesAfter( "" ) ); assertEquals( 1, Const.nrSpacesAfter( " " ) ); assertEquals( 3, Const.nrSpacesAfter( " " ) ); assertEquals( 0, Const.n...
Const { public static String ltrim( String source ) { if ( source == null ) { return null; } int from = 0; while ( from < source.length() && isSpace( source.charAt( from ) ) ) { from++; } return source.substring( from ); } static double round( double f, int places ); static double round( double f, int places, int roun...
@Test public void testLtrim() { assertEquals( null, Const.ltrim( null ) ); assertEquals( "", Const.ltrim( "" ) ); assertEquals( "", Const.ltrim( " " ) ); assertEquals( "test ", Const.ltrim( "test " ) ); assertEquals( "test ", Const.ltrim( " test " ) ); }
Const { public static String rtrim( String source ) { if ( source == null ) { return null; } int max = source.length(); while ( max > 0 && isSpace( source.charAt( max - 1 ) ) ) { max--; } return source.substring( 0, max ); } static double round( double f, int places ); static double round( double f, int places, int ro...
@Test public void testRtrim() { assertEquals( null, Const.rtrim( null ) ); assertEquals( "", Const.rtrim( "" ) ); assertEquals( "", Const.rtrim( " " ) ); assertEquals( "test", Const.rtrim( "test " ) ); assertEquals( "test ", Const.ltrim( " test " ) ); }
Const { public static String trim( String str ) { if ( str == null ) { return null; } int max = str.length() - 1; int min = 0; while ( min <= max && isSpace( str.charAt( min ) ) ) { min++; } while ( max >= 0 && isSpace( str.charAt( max ) ) ) { max--; } if ( max < min ) { return ""; } return str.substring( min, max + 1 ...
@Test public void testTrim() { assertEquals( null, Const.trim( null ) ); assertEquals( "", Const.trim( "" ) ); assertEquals( "", Const.trim( " " ) ); assertEquals( "test", Const.trim( "test " ) ); assertEquals( "test", Const.trim( " test " ) ); }
Const { public static boolean onlySpaces( String str ) { for ( int i = 0; i < str.length(); i++ ) { if ( !isSpace( str.charAt( i ) ) ) { return false; } } return true; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, in...
@Test public void testOnlySpaces() { try { Const.onlySpaces( null ); fail( "Expected NullPointerException" ); } catch ( NullPointerException ex ) { } assertEquals( true, Const.onlySpaces( "" ) ); assertEquals( true, Const.onlySpaces( " " ) ); assertEquals( false, Const.onlySpaces( " test " ) ); }
Const { public static String[] splitString( String string, String separator ) { List<String> list = new ArrayList<>(); if ( string == null || string.length() == 0 ) { return new String[] {}; } int sepLen = separator.length(); int from = 0; int end = string.length() - sepLen + 1; for ( int i = from; i < end; i += sepLen...
@Test public void testSplitString() { assertEquals( 0, Const.splitString( "", ";" ).length ); assertEquals( 0, Const.splitString( null, ";" ).length ); String[] a = Const.splitString( ";", ";" ); assertEquals( 1, a.length ); assertEquals( "", a[0] ); a = Const.splitString( "a;b;c;d", ";" ); assertEquals( 4, a.length );...
DataHandler extends AbstractXulEventHandler { public void clearOptionsData() { getControls(); if ( optionsParameterTree != null ) { optionsParameterTree.getRootChildren().removeAll(); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOpt...
@Test public void testClearOptionsData() throws Exception { }
Const { public static String[] splitPath( String path, String separator ) { if ( path == null || path.length() == 0 || path.equals( separator ) ) { return new String[] {}; } while ( path.endsWith( separator ) ) { path = path.substring( 0, path.length() - 1 ); } int sepLen = separator.length(); int nr_separators = 1; in...
@Test public void testSplitPath() { String[] a = Const.splitPath( "", "/" ); assertEquals( 0, a.length ); a = Const.splitPath( null, "/" ); assertEquals( 0, a.length ); a = Const.splitPath( "/", "/" ); assertEquals( 0, a.length ); a = Const.splitPath( "/level1", "/" ); assertEquals( 1, a.length ); assertEquals( "level1...
Const { public static double round( double f, int places ) { return round( f, places, java.math.BigDecimal.ROUND_HALF_EVEN ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long ...
@Test public void testRound_BigDecimal() { assertEquals( new BigDecimal( "1.0" ), Const.round( new BigDecimal( "1.0" ), 0, BigDecimal.ROUND_UP ) ); assertEquals( new BigDecimal( "1.0" ), Const.round( new BigDecimal( "1.0" ), 0, BigDecimal.ROUND_DOWN ) ); assertEquals( new BigDecimal( "1.0" ), Const.round( new BigDecima...
Const { public static int toInt( String str, int def ) { int retval; try { retval = Integer.parseInt( str ); } catch ( Exception e ) { retval = def; } return retval; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int ...
@Test public void testToInt() { assertEquals( 123, Const.toInt( "123", -12 ) ); assertEquals( -12, Const.toInt( "123f", -12 ) ); }
Const { public static long toLong( String str, long def ) { long retval; try { retval = Long.parseLong( str ); } catch ( Exception e ) { retval = def; } return retval; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, in...
@Test public void testToLong() { assertEquals( 1447252914241L, Const.toLong( "1447252914241", -12 ) ); assertEquals( -1447252914241L, Const.toLong( "1447252914241L", -1447252914241L ) ); }
Const { public static double toDouble( String str, double def ) { double retval; try { retval = Double.parseDouble( str ); } catch ( Exception e ) { retval = def; } return retval; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigD...
@Test public void testToDouble() { Assert.assertEquals( 123.45, Const.toDouble( "123.45", -12.34 ), 1e-15 ); Assert.assertEquals( -12.34, Const.toDouble( "123asd", -12.34 ), 1e-15 ); }
Const { public static String rightPad( String ret, int limit ) { if ( ret == null ) { return rightPad( new StringBuilder(), limit ); } else { return rightPad( new StringBuilder( ret ), limit ); } } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDec...
@Test public void testRightPad() { final String s = "Pad me baby one more time"; assertEquals( " ", Const.rightPad( (String) null, 5 ) ); assertEquals( "Pad", Const.rightPad( s, 3 ) ); final StringBuffer sb = new StringBuffer( s ); assertEquals( s + " ", Const.rightPad( sb, 28 ) ); assertEquals( "Pad me baby", Const.ri...
Const { public static String replace( String string, String repl, String with ) { if ( string != null && repl != null && with != null ) { return string.replaceAll( Pattern.quote( repl ), Matcher.quoteReplacement( with ) ); } else { return null; } } static double round( double f, int places ); static double round( doub...
@Test public void testReplace() { final String source = "A journey of a thousand miles never begins"; assertEquals( "A journey of a thousand miles begins with a single step", Const.replace( source, "never begins", "begins with a single step" ) ); assertEquals( source, Const.replace( source, "evil", "good" ) ); assertEq...
Const { public static void repl( StringBuffer str, String code, String repl ) { if ( ( code == null ) || ( repl == null ) || ( code.length() == 0 ) || ( repl.length() == 0 ) || ( str == null ) || ( str.length() == 0 ) ) { return; } String aString = str.toString(); str.setLength( 0 ); str.append( aString.replaceAll( Pat...
@Test public void testRepl() { String source = "A journey of a thousand miles never begins"; StringBuffer sb = new StringBuffer( source ); Const.repl( sb, "never begins", "begins with a single step" ); assertEquals( "A journey of a thousand miles begins with a single step", sb.toString() ); sb = new StringBuffer( sourc...
Const { public static String getOS() { return System.getProperty( "os.name" ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); ...
@Test public void testGetOS() { final String key = "os.name"; final String os = System.getProperty( key ); System.setProperty( key, "BeOS" ); assertEquals( "BeOS", Const.getOS() ); System.setProperty( key, os ); }
Const { public static String getQuoteCharByOS() { if ( isWindows() ) { return "\""; } else { return "'"; } } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int ...
@Test public void testQuoteCharByOS() { assertEquals( SystemUtils.IS_OS_WINDOWS ? "\"" : "'", Const.getQuoteCharByOS() ); }
Const { public static boolean isWindows() { return getOS().startsWith( "Windows" ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMod...
@Test public void testIsWindows() { assertEquals( SystemUtils.IS_OS_WINDOWS, Const.isWindows() ); }
Const { public static boolean isLinux() { return getOS().startsWith( "Linux" ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode );...
@Test public void testIsLinux() { assertEquals( SystemUtils.IS_OS_LINUX, Const.isLinux() ); }
Const { public static boolean isOSX() { return getOS().toUpperCase().contains( "OS X" ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundi...
@Test public void testIsOSX() { assertEquals( SystemUtils.IS_OS_MAC_OSX, Const.isOSX() ); }
Const { public static boolean isKDE() { return StringUtils.isNotBlank( System.getenv( "KDE_SESSION_VERSION" ) ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f...
@Test public void testIsKDE() { final String kdeVersion = System.getProperty( "KDE_SESSION_VERSION" ); assertEquals( kdeVersion != null && !kdeVersion.isEmpty(), Const.isKDE() ); }
Const { public static String getHostname() { if ( cachedHostname != null ) { return cachedHostname; } String systemHostname = EnvUtil.getSystemProperty( KETTLE_SYSTEM_HOSTNAME ); if ( !Utils.isEmpty( systemHostname ) ) { cachedHostname = systemHostname; return systemHostname; } String lastHostname = "localhost"; try { ...
@Test public void testGetHostName() { assertFalse( Const.getHostname().isEmpty() ); }
Const { public static String getHostnameReal() { String systemHostname = EnvUtil.getSystemProperty( KETTLE_SYSTEM_HOSTNAME ); if ( !Utils.isEmpty( systemHostname ) ) { return systemHostname; } if ( isWindows() ) { return System.getenv( "COMPUTERNAME" ); } else { String hostname = System.getenv( "HOSTNAME" ); if ( hostn...
@Test public void testGetHostnameReal() { doWithModifiedSystemProperty( "KETTLE_SYSTEM_HOSTNAME", "MyHost", new Runnable() { @Override public void run() { assertEquals( "MyHost", Const.getHostnameReal() ); } } ); }
Const { @Deprecated public static String replEnv( String string ) { if ( string == null ) { return null; } StringBuilder str = new StringBuilder( string ); int idx = str.indexOf( "%%" ); while ( idx >= 0 ) { int to = str.indexOf( "%%", idx + 2 ); if ( to >= 0 ) { String marker = str.substring( idx, to + 2 ); String var...
@Test public void testReplEnv() { assertNull( Const.replEnv( (String) null ) ); System.setProperty( "testProp", "testValue" ); assertEquals( "Value for testProp property is testValue.", Const.replEnv( "Value for testProp property is %%testProp%%." ) ); assertEquals( "Value for testProp property is testValue.", Const.re...
Const { public static String nullToEmpty( String source ) { if ( source == null ) { return ""; } return source; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f,...
@Test public void testNullToEmpty() { assertEquals( "", Const.nullToEmpty( null ) ); assertEquals( "value", Const.nullToEmpty( "value" ) ); }
Const { public static int indexOfString( String lookup, String[] array ) { if ( array == null ) { return -1; } if ( lookup == null ) { return -1; } for ( int i = 0; i < array.length; i++ ) { if ( lookup.equalsIgnoreCase( array[i] ) ) { return i; } } return -1; } static double round( double f, int places ); static doub...
@Test public void testIndexOfString() { assertEquals( -1, Const.indexOfString( null, (String[]) null ) ); assertEquals( -1, Const.indexOfString( null, new String[] {} ) ); assertEquals( 1, Const.indexOfString( "bar", new String[] { "foo", "bar" } ) ); assertEquals( -1, Const.indexOfString( "baz", new String[] { "foo", ...
Const { public static int[] indexsOfStrings( String[] lookup, String[] array ) { int[] indexes = new int[lookup.length]; for ( int i = 0; i < indexes.length; i++ ) { indexes[i] = indexOfString( lookup[i], array ); } return indexes; } static double round( double f, int places ); static double round( double f, int place...
@Test public void testIndexsOfStrings() { Assert.assertArrayEquals( new int[] { 2, 1, -1 }, Const.indexsOfStrings( new String[] { "foo", "bar", "qux" }, new String[] { "baz", "bar", "foo" } ) ); }
Const { public static int[] indexsOfFoundStrings( String[] lookup, String[] array ) { List<Integer> indexesList = new ArrayList<>(); for ( int i = 0; i < lookup.length; i++ ) { int idx = indexOfString( lookup[i], array ); if ( idx >= 0 ) { indexesList.add( Integer.valueOf( idx ) ); } } int[] indexes = new int[indexesLi...
@Test public void testIndexsOfFoundStrings() { Assert.assertArrayEquals( new int[] { 2, 1 }, Const.indexsOfFoundStrings( new String[] { "qux", "foo", "bar" }, new String[] { "baz", "bar", "foo" } ) ); }
Const { public static String[] getDistinctStrings( String[] strings ) { if ( strings == null ) { return null; } if ( strings.length == 0 ) { return new String[] {}; } String[] sorted = sortStrings( strings ); List<String> result = new ArrayList<>(); String previous = ""; for ( int i = 0; i < sorted.length; i++ ) { if (...
@Test public void testGetDistinctStrings() { assertNull( Const.getDistinctStrings( null ) ); assertTrue( Const.getDistinctStrings( new String[] {} ).length == 0 ); Assert.assertArrayEquals( new String[] { "bar", "foo" }, Const.getDistinctStrings( new String[] { "foo", "bar", "foo", "bar" } ) ); }
Const { public static String getStackTracker( Throwable e ) { return getClassicStackTrace( e ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int...
@Test public void testStackTracker() { assertTrue( Const.getStackTracker( new Exception() ).contains( getClass().getName() + ".testStackTracker(" + getClass().getSimpleName() + ".java:" ) ); }
Const { public static String getCustomStackTrace( Throwable aThrowable ) { final StringBuilder result = new StringBuilder(); String errorMessage = aThrowable.toString(); result.append( errorMessage ); if ( !errorMessage.contains( Const.CR ) ) { result.append( CR ); } for ( StackTraceElement element : aThrowable.getStac...
@Test public void testGetCustomStackTrace() { assertTrue( Const.getCustomStackTrace( new Exception() ).contains( getClass().getName() + ".testGetCustomStackTrace(" + getClass().getSimpleName() + ".java:" ) ); }
Const { public static ClassLoader createNewClassLoader() throws KettleException { try { URL[] urls = new URL[] {}; URLClassLoader ucl = new URLClassLoader( urls ); return ucl; } catch ( Exception e ) { throw new KettleException( "Unexpected error during classloader creation", e ); } } static double round( double f, in...
@Test public void testCreateNewClassLoader() throws KettleException { ClassLoader cl = Const.createNewClassLoader(); assertTrue( cl instanceof URLClassLoader && ( (URLClassLoader) cl ).getURLs().length == 0 ); }
Const { public static byte[] createByteArray( int size ) { return new byte[size]; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ...
@Test public void testCreateByteArray() { assertTrue( Const.createByteArray( 5 ).length == 5 ); }
Const { public static String createFilename( String name ) { StringBuilder filename = new StringBuilder(); for ( int i = 0; i < name.length(); i++ ) { char c = name.charAt( i ); if ( Character.isUnicodeIdentifierPart( c ) ) { filename.append( c ); } else if ( Character.isWhitespace( c ) ) { filename.append( '_' ); } } ...
@Test public void testCreateFilename() { assertEquals( "dir" + Const.FILE_SEPARATOR + "file__1.ext", Const.createFilename( "dir" + Const.FILE_SEPARATOR, "File\t~ 1", ".ext" ) ); assertEquals( "dir" + Const.FILE_SEPARATOR + "file__1.ext", Const.createFilename( "dir", "File\t~ 1", ".ext" ) ); }
Const { public static String createName( String filename ) { if ( Utils.isEmpty( filename ) ) { return filename; } String pureFilename = filenameOnly( filename ); if ( pureFilename.endsWith( ".ktr" ) || pureFilename.endsWith( ".kjb" ) || pureFilename.endsWith( ".xml" ) ) { pureFilename = pureFilename.substring( 0, pure...
@Test public void testCreateName() { assertNull( Const.createName( null ) ); assertEquals( "test - trans", Const.createName( "transformations" + Const.FILE_SEPARATOR + "test\t~- trans.ktr" ) ); }
Const { public static String filenameOnly( String sFullPath ) { if ( Utils.isEmpty( sFullPath ) ) { return sFullPath; } int idx = sFullPath.lastIndexOf( FILE_SEPARATOR ); if ( idx != -1 ) { return sFullPath.substring( idx + 1 ); } else { idx = sFullPath.lastIndexOf( '/' ); if ( idx != -1 ) { return sFullPath.substring(...
@Test public void testFilenameOnly() { assertNull( Const.filenameOnly( null ) ); assertTrue( Const.filenameOnly( "" ).isEmpty() ); assertEquals( "file.txt", Const.filenameOnly( "dir" + Const.FILE_SEPARATOR + "file.txt" ) ); assertEquals( "file.txt", Const.filenameOnly( "file.txt" ) ); }
Const { public static String[] getDateFormats() { if ( dateFormats == null ) { int dateFormatsCount = toInt( BaseMessages.getString( PKG, "Const.DateFormat.Count" ), 0 ); dateFormats = new String[dateFormatsCount]; for ( int i = 1; i <= dateFormatsCount; i++ ) { dateFormats[i - 1] = BaseMessages.getString( PKG, "Const....
@Test public void testGetDateFormats() { final String[] formats = Const.getDateFormats(); assertTrue( formats.length > 0 ); for ( String format : formats ) { assertTrue( format != null && !format.isEmpty() ); } }
Const { public static String[] getNumberFormats() { if ( numberFormats == null ) { int numberFormatsCount = toInt( BaseMessages.getString( PKG, "Const.NumberFormat.Count" ), 0 ); numberFormats = new String[numberFormatsCount + 1]; numberFormats[0] = DEFAULT_NUMBER_FORMAT; for ( int i = 1; i <= numberFormatsCount; i++ )...
@Test public void testGetNumberFormats() { final String[] formats = Const.getNumberFormats(); assertTrue( formats.length > 0 ); for ( String format : formats ) { assertTrue( format != null && !format.isEmpty() ); } }
Const { public static String[] getConversionFormats() { String[] dats = Const.getDateFormats(); String[] nums = Const.getNumberFormats(); int totsize = dats.length + nums.length; String[] formats = new String[totsize]; for ( int x = 0; x < dats.length; x++ ) { formats[x] = dats[x]; } for ( int x = 0; x < nums.length; x...
@Test public void testGetConversionFormats() { final List<String> dateFormats = Arrays.asList( Const.getDateFormats() ); final List<String> numberFormats = Arrays.asList( Const.getNumberFormats() ); final List<String> conversionFormats = Arrays.asList( Const.getConversionFormats() ); assertEquals( dateFormats.size() + ...
Const { public static String[] getTransformationAndJobFilterNames() { if ( STRING_TRANS_AND_JOB_FILTER_NAMES == null ) { STRING_TRANS_AND_JOB_FILTER_NAMES = new String[] { BaseMessages.getString( PKG, "Const.FileFilter.TransformationJob" ), BaseMessages.getString( PKG, "Const.FileFilter.Transformations" ), BaseMessages...
@Test public void testGetTransformationAndJobFilterNames() { List<String> filters = Arrays.asList( Const.getTransformationAndJobFilterNames() ); assertTrue( filters.size() == 5 ); for ( String filter : filters ) { assertFalse( filter.isEmpty() ); } }
Const { public static String[] getTransformationFilterNames() { if ( STRING_TRANS_FILTER_NAMES == null ) { STRING_TRANS_FILTER_NAMES = new String[] { BaseMessages.getString( PKG, "Const.FileFilter.Transformations" ), BaseMessages.getString( PKG, "Const.FileFilter.XML" ), BaseMessages.getString( PKG, "Const.FileFilter.A...
@Test public void testGetTransformationFilterNames() { List<String> filters = Arrays.asList( Const.getTransformationFilterNames() ); assertTrue( filters.size() == 3 ); for ( String filter : filters ) { assertFalse( filter.isEmpty() ); } }
Const { public static String[] getJobFilterNames() { if ( STRING_JOB_FILTER_NAMES == null ) { STRING_JOB_FILTER_NAMES = new String[] { BaseMessages.getString( PKG, "Const.FileFilter.Jobs" ), BaseMessages.getString( PKG, "Const.FileFilter.XML" ), BaseMessages.getString( PKG, "Const.FileFilter.All" ) }; } return STRING_J...
@Test public void testGetJobFilterNames() { List<String> filters = Arrays.asList( Const.getJobFilterNames() ); assertTrue( filters.size() == 3 ); for ( String filter : filters ) { assertFalse( filter.isEmpty() ); } }
Const { public static long nanoTime() { return new Date().getTime() * 1000; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); sta...
@Test public void testNanoTime() { assertTrue( String.valueOf( Const.nanoTime() ).endsWith( "000" ) ); }
Const { public static String trimToType( String string, int trimType ) { switch ( trimType ) { case ValueMetaInterface.TRIM_TYPE_BOTH: return trim( string ); case ValueMetaInterface.TRIM_TYPE_LEFT: return ltrim( string ); case ValueMetaInterface.TRIM_TYPE_RIGHT: return rtrim( string ); case ValueMetaInterface.TRIM_TYPE...
@Test public void testTrimToType() { final String source = " trim me hard "; assertEquals( "trim me hard", Const.trimToType( source, ValueMetaInterface.TRIM_TYPE_BOTH ) ); assertEquals( "trim me hard ", Const.trimToType( source, ValueMetaInterface.TRIM_TYPE_LEFT ) ); assertEquals( " trim me hard", Const.trimToType( sou...
Const { public static String safeAppendDirectory( String dir, String file ) { boolean dirHasSeparator = ( ( dir.lastIndexOf( FILE_SEPARATOR ) ) == dir.length() - 1 ); boolean fileHasSeparator = ( file.indexOf( FILE_SEPARATOR ) == 0 ); if ( ( dirHasSeparator && !fileHasSeparator ) || ( !dirHasSeparator && fileHasSeparat...
@Test public void testSafeAppendDirectory() { final String expected = "dir" + Const.FILE_SEPARATOR + "file"; assertEquals( expected, Const.safeAppendDirectory( "dir", "file" ) ); assertEquals( expected, Const.safeAppendDirectory( "dir" + Const.FILE_SEPARATOR, "file" ) ); assertEquals( expected, Const.safeAppendDirector...
Const { public static String[] getEmptyPaddedStrings() { if ( emptyPaddedSpacesStrings == null ) { emptyPaddedSpacesStrings = new String[250]; for ( int i = 0; i < emptyPaddedSpacesStrings.length; i++ ) { emptyPaddedSpacesStrings[i] = rightPad( "", i ); } } return emptyPaddedSpacesStrings; } static double round( doubl...
@Test public void testGetEmptyPaddedStrings() { final String[] strings = Const.getEmptyPaddedStrings(); for ( int i = 0; i < 250; i++ ) { assertEquals( i, strings[i].length() ); } }
Const { public static int getPercentageFreeMemory() { Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); long totalFreeMemory = ( freeMemory + ( maxMemory - allocatedMemory ) ); return (int) Math.round( 100 ...
@Test public void testGetPercentageFreeMemory() { assertTrue( Const.getPercentageFreeMemory() > 0 ); }
Const { public static String removeDigits( String input ) { if ( Utils.isEmpty( input ) ) { return null; } StringBuilder digitsOnly = new StringBuilder(); char c; for ( int i = 0; i < input.length(); i++ ) { c = input.charAt( i ); if ( !Character.isDigit( c ) ) { digitsOnly.append( c ); } } return digitsOnly.toString()...
@Test public void testRemoveDigits() { assertNull( Const.removeDigits( null ) ); assertEquals( "foobar", Const.removeDigits( "123foo456bar789" ) ); }
Const { public static String getDigitsOnly( String input ) { if ( Utils.isEmpty( input ) ) { return null; } StringBuilder digitsOnly = new StringBuilder(); char c; for ( int i = 0; i < input.length(); i++ ) { c = input.charAt( i ); if ( Character.isDigit( c ) ) { digitsOnly.append( c ); } } return digitsOnly.toString()...
@Test public void testGetDigitsOnly() { assertNull( Const.removeDigits( null ) ); assertEquals( "123456789", Const.getDigitsOnly( "123foo456bar789" ) ); }
Const { public static Date removeTimeFromDate( Date input ) { if ( input == null ) { return null; } Calendar calendar = Calendar.getInstance(); calendar.setLenient( false ); calendar.setTime( input ); calendar.set( Calendar.HOUR_OF_DAY, 0 ); calendar.set( Calendar.MINUTE, 0 ); calendar.set( Calendar.SECOND, 0 ); calend...
@Test public void testRemoveTimeFromDate() { final Date date = Const.removeTimeFromDate( new Date() ); assertEquals( 0, date.getHours() ); assertEquals( 0, date.getMinutes() ); assertEquals( 0, date.getSeconds() ); }