@Test public void getUpdateOptionsPreviewTest() { when( teraDataBulkLoaderMetaMock.getDatabaseMeta() ).thenReturn( dataBaseMetaDataMock ); when( dataBaseMetaDataMock.getHostname() ).thenReturn( "hostname" ); when( dataBaseMetaDataMock.getUsername() ).thenReturn( "username" ); when( teraDataBulkLoaderMetaMock.getUpdateLogFile() ).thenReturn( "logFile" ); when( teraDataBulkLoaderMetaMock.getLogTable() ).thenReturn( "logTable" ); when( teraDataBulkLoaderMetaMock.getTableName() ).thenReturn( "tableName" ); when( teraDataBulkLoaderMetaMock.getWorkTable() ).thenReturn( "workTable" ); when( teraDataBulkLoaderMetaMock.getErrorTable() ).thenReturn( "errorTable" ); when( teraDataBulkLoaderMetaMock.getErrorTable2() ).thenReturn( "errorTable2" ); when( teraDataBulkLoaderMetaMock.getDbName() ).thenReturn( "dbName" ); String password = "myPassword"; String expectedUpdataOptionsPreview = "DEFINE OPERATOR UPDATE_OPERATOR\n" + "TYPE UPDATE\n" + "SCHEMA *\n" + "ATTRIBUTES\n" + " (\n" + " VARCHAR TdpId = 'hostname',\n" + " VARCHAR PrivateLogName = 'logFile',\n" + " VARCHAR UserName = 'username',\n" + " VARCHAR UserPassword = 'myPassword',\n" + " VARCHAR LogTable = 'logTable',\n" + " VARCHAR TargetTable = 'dbName.tableName',\n" + " VARCHAR WorkTable = 'workTable',\n" + " VARCHAR ErrorTable1 = 'errorTable',\n" + " VARCHAR ErrorTable2 = 'errorTable2'\n" + " );\n"; assertEquals( expectedUpdataOptionsPreview, teraDataBulkLoaderRoutines.getUpdateOptions( true, password ).toString() ); }
@VisibleForTesting DefineSchema getUpdateOptions( boolean isPreview, String hiddenPassword ) { DefineSchema updateOptions = new DefineSchema( "UPDATE_OPERATOR", "UPDATE", "*" ); updateOptions.addField( "TdpId ", this.meta.getDatabaseMeta().getHostname() ); updateOptions.addField( "PrivateLogName ", isPreview ? this.meta.getUpdateLogFile() : parent.environmentSubstitute( this.meta.getUpdateLogFile() ) ); updateOptions.addField( "UserName ", this.meta.getDatabaseMeta().getUsername() ); updateOptions.addField( "UserPassword ", isPreview ? hiddenPassword : this.meta.getDatabaseMeta() .getPassword() ); updateOptions.addField( "LogTable ", isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ) ); updateOptions.addField( "TargetTable ", getTargetSchema( isPreview ) + "." + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) ) ); updateOptions.addField( "WorkTable ", isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ) ); updateOptions.addField( "ErrorTable1 ", isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ) ); updateOptions.addField( "ErrorTable2 ", isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ) ); return updateOptions; }
TeraDataBulkLoaderRoutines { @VisibleForTesting DefineSchema getUpdateOptions( boolean isPreview, String hiddenPassword ) { DefineSchema updateOptions = new DefineSchema( "UPDATE_OPERATOR", "UPDATE", "*" ); updateOptions.addField( "TdpId ", this.meta.getDatabaseMeta().getHostname() ); updateOptions.addField( "PrivateLogName ", isPreview ? this.meta.getUpdateLogFile() : parent.environmentSubstitute( this.meta.getUpdateLogFile() ) ); updateOptions.addField( "UserName ", this.meta.getDatabaseMeta().getUsername() ); updateOptions.addField( "UserPassword ", isPreview ? hiddenPassword : this.meta.getDatabaseMeta() .getPassword() ); updateOptions.addField( "LogTable ", isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ) ); updateOptions.addField( "TargetTable ", getTargetSchema( isPreview ) + "." + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) ) ); updateOptions.addField( "WorkTable ", isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ) ); updateOptions.addField( "ErrorTable1 ", isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ) ); updateOptions.addField( "ErrorTable2 ", isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ) ); return updateOptions; } }
TeraDataBulkLoaderRoutines { @VisibleForTesting DefineSchema getUpdateOptions( boolean isPreview, String hiddenPassword ) { DefineSchema updateOptions = new DefineSchema( "UPDATE_OPERATOR", "UPDATE", "*" ); updateOptions.addField( "TdpId ", this.meta.getDatabaseMeta().getHostname() ); updateOptions.addField( "PrivateLogName ", isPreview ? this.meta.getUpdateLogFile() : parent.environmentSubstitute( this.meta.getUpdateLogFile() ) ); updateOptions.addField( "UserName ", this.meta.getDatabaseMeta().getUsername() ); updateOptions.addField( "UserPassword ", isPreview ? hiddenPassword : this.meta.getDatabaseMeta() .getPassword() ); updateOptions.addField( "LogTable ", isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ) ); updateOptions.addField( "TargetTable ", getTargetSchema( isPreview ) + "." + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) ) ); updateOptions.addField( "WorkTable ", isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ) ); updateOptions.addField( "ErrorTable1 ", isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ) ); updateOptions.addField( "ErrorTable2 ", isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ) ); return updateOptions; } TeraDataBulkLoaderRoutines( TeraDataBulkLoader parent, TeraDataBulkLoaderMeta meta ); }
TeraDataBulkLoaderRoutines { @VisibleForTesting DefineSchema getUpdateOptions( boolean isPreview, String hiddenPassword ) { DefineSchema updateOptions = new DefineSchema( "UPDATE_OPERATOR", "UPDATE", "*" ); updateOptions.addField( "TdpId ", this.meta.getDatabaseMeta().getHostname() ); updateOptions.addField( "PrivateLogName ", isPreview ? this.meta.getUpdateLogFile() : parent.environmentSubstitute( this.meta.getUpdateLogFile() ) ); updateOptions.addField( "UserName ", this.meta.getDatabaseMeta().getUsername() ); updateOptions.addField( "UserPassword ", isPreview ? hiddenPassword : this.meta.getDatabaseMeta() .getPassword() ); updateOptions.addField( "LogTable ", isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ) ); updateOptions.addField( "TargetTable ", getTargetSchema( isPreview ) + "." + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) ) ); updateOptions.addField( "WorkTable ", isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ) ); updateOptions.addField( "ErrorTable1 ", isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ) ); updateOptions.addField( "ErrorTable2 ", isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ) ); return updateOptions; } TeraDataBulkLoaderRoutines( TeraDataBulkLoader parent, TeraDataBulkLoaderMeta meta ); String dropTable( boolean isPreview, String user, String suffix ); String createScriptFile(); void createFromExistingScriptFile(); String createGeneratedScriptFile(); String createGeneratedScriptFile( Map<String, Integer> inputFieldTypes, Map<String, Integer> inputFieldLength ); }
TeraDataBulkLoaderRoutines { @VisibleForTesting DefineSchema getUpdateOptions( boolean isPreview, String hiddenPassword ) { DefineSchema updateOptions = new DefineSchema( "UPDATE_OPERATOR", "UPDATE", "*" ); updateOptions.addField( "TdpId ", this.meta.getDatabaseMeta().getHostname() ); updateOptions.addField( "PrivateLogName ", isPreview ? this.meta.getUpdateLogFile() : parent.environmentSubstitute( this.meta.getUpdateLogFile() ) ); updateOptions.addField( "UserName ", this.meta.getDatabaseMeta().getUsername() ); updateOptions.addField( "UserPassword ", isPreview ? hiddenPassword : this.meta.getDatabaseMeta() .getPassword() ); updateOptions.addField( "LogTable ", isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ) ); updateOptions.addField( "TargetTable ", getTargetSchema( isPreview ) + "." + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) ) ); updateOptions.addField( "WorkTable ", isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ) ); updateOptions.addField( "ErrorTable1 ", isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ) ); updateOptions.addField( "ErrorTable2 ", isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ) ); return updateOptions; } TeraDataBulkLoaderRoutines( TeraDataBulkLoader parent, TeraDataBulkLoaderMeta meta ); String dropTable( boolean isPreview, String user, String suffix ); String createScriptFile(); void createFromExistingScriptFile(); String createGeneratedScriptFile(); String createGeneratedScriptFile( Map<String, Integer> inputFieldTypes, Map<String, Integer> inputFieldLength );  }