TeraDataBulkLoaderRoutines { @VisibleForTesting DefineSchema getDdlOptions( boolean isPreview, String hiddenPassword ) { DefineSchema ddlOptions = new DefineSchema( "DDL_OPERATOR", "DDL", null ); ddlOptions.addField( "TdpId ", this.meta.getDatabaseMeta().getHostname() ); ddlOptions.addField( "UserName ", this.meta.getDatabaseMeta().getUsername() ); ddlOptions.addField( "UserPassword ", isPreview ? hiddenPassword : this.meta.getDatabaseMeta().getPassword() ); ddlOptions.addField( "ErrorList ", "3807" ); return ddlOptions; } 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 );  }
@Test public void getDdlOptionsPreviewTest() { when( teraDataBulkLoaderMetaMock.getDatabaseMeta() ).thenReturn( dataBaseMetaDataMock ); when( dataBaseMetaDataMock.getHostname() ).thenReturn( "hostname" ); when( dataBaseMetaDataMock.getUsername() ).thenReturn( "username" ); String password = "myPassword"; String expectedDdlOptionsPreview = "DEFINE OPERATOR DDL_OPERATOR\n" + "TYPE DDL\n" + "ATTRIBUTES\n" + " (\n" + " VARCHAR TdpId = 'hostname',\n" + " VARCHAR UserName = 'username',\n" + " VARCHAR UserPassword = 'myPassword',\n" + " VARCHAR ErrorList = '3807'\n" + " );\n"; assertEquals( expectedDdlOptionsPreview, teraDataBulkLoaderRoutines.getDdlOptions( true, password ).toString() ); }
@Test public void getDdlOptionsTest() { when( teraDataBulkLoaderMetaMock.getDatabaseMeta() ).thenReturn( dataBaseMetaDataMock ); when( dataBaseMetaDataMock.getHostname() ).thenReturn( "hostname" ); when( dataBaseMetaDataMock.getUsername() ).thenReturn( "username" ); when( dataBaseMetaDataMock.getPassword() ).thenReturn( "passwordFromMeta" ); setInternalState( teraDataBulkLoaderRoutines, "parent", teraDataBulkLoaderMock ); String password = "myPassword"; String expectedDdlOptionsPreview = "DEFINE OPERATOR DDL_OPERATOR\n" + "TYPE DDL\n" + "ATTRIBUTES\n" + " (\n" + " VARCHAR TdpId = 'hostname',\n" + " VARCHAR UserName = 'username',\n" + " VARCHAR UserPassword = 'passwordFromMeta',\n" + " VARCHAR ErrorList = '3807'\n" + " );\n"; assertEquals( expectedDdlOptionsPreview, teraDataBulkLoaderRoutines.getDdlOptions( false, password ).toString() ); }