TeraDataBulkLoader extends BaseStep implements StepInterface { public String createCommandLine() throws KettleException { if ( StringUtils.isBlank( this.meta.getTbuildPath() ) ) { throw new KettleException( BaseMessages.getString( PKG, "TeraDataBulkLoader.Exception.BuildPathNotSet" ) ); } final StringBuilder builder = new StringBuilder(); try { final FileObject fileObject = KettleVFS.getFileObject( environmentSubstitute( this.meta.getTbuildPath() ) ); final String tbuildExec = KettleVFS.getFilename( fileObject ); builder.append( tbuildExec + " " ); builder.append( "-f " + this.tempScriptFile + " " ); if ( !this.meta.getGenerateScript() ) { String varfile = environmentSubstitute( this.meta.getVariableFile() ); if ( varfile != null && !varfile.equals( "" ) ) { builder.append( "-v " + varfile + " " ); } } builder.append( environmentSubstitute( this.meta.getJobName() ) ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "TeraDataBulkLoader.Exception.ErrorBuildAppString" ), e ); } return builder.toString(); } TeraDataBulkLoader( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ); boolean execute( TeraDataBulkLoaderMeta meta ); String createCommandLine(); String[] createEnvironmentVariables(); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); static String[] ActionTypes; static String[] ScriptTypes; static final long DEFAULT_ERROR_CODE; }
@Test public void createCommandLineTest() { setInternalState( teraDataBulkLoader, "tempScriptFile", "scriptValue" ); when( teraDataBulkLoaderMetaMock.getTbuildPath() ).thenReturn( "buildpathvalue" ); when( teraDataBulkLoaderMetaMock.getVariableFile() ).thenReturn( "variablefilevalue" ); when( teraDataBulkLoaderMetaMock.getJobName() ).thenReturn( "jobnamevalue" ); try { String commandLine = teraDataBulkLoader.createCommandLine(); String expected = "buildpathvalue -f scriptValue -v variablefilevalue jobnamevalue"; assertTrue( commandLine.contains( expected ) ); } catch ( KettleException e ) { fail( e.getMessage() ); } }
@Test public void createCommandLineWithEnvVarTest() { teraDataBulkLoader.setVariable( "TbuilPath", "buildpathvalue" ); teraDataBulkLoader.setVariable( "VariableFile", "variablefilevalue" ); teraDataBulkLoader.setVariable( "JobName", "jobnamevalue" ); setInternalState( teraDataBulkLoader, "tempScriptFile", "scriptValue" ); when( teraDataBulkLoaderMetaMock.getTbuildPath() ).thenReturn( "${TbuilPath}" ); when( teraDataBulkLoaderMetaMock.getVariableFile() ).thenReturn( "${VariableFile}" ); when( teraDataBulkLoaderMetaMock.getJobName() ).thenReturn( "${JobName}" ); try { String commandLine = teraDataBulkLoader.createCommandLine(); String expected = "buildpathvalue -f scriptValue -v variablefilevalue jobnamevalue"; assertTrue( commandLine.contains( expected ) ); } catch ( KettleException e ) { fail( e.getMessage() ); } }