@Test public void getDropTablesTest() { when( teraDataBulkLoaderMetaMock.getDropErrorTable() ).thenReturn( true ); when( teraDataBulkLoaderMetaMock.getDropErrorTable2() ).thenReturn( true ); when( teraDataBulkLoaderMetaMock.getDropLogTable() ).thenReturn( true ); when( teraDataBulkLoaderMetaMock.getDropWorkTable() ).thenReturn( true ); when( teraDataBulkLoaderMetaMock.getLogTable() ).thenReturn( "logTable" ); when( teraDataBulkLoaderMetaMock.getWorkTable() ).thenReturn( "workTable" ); when( teraDataBulkLoaderMetaMock.getErrorTable() ).thenReturn( "errorTable" ); when( teraDataBulkLoaderMetaMock.getErrorTable2() ).thenReturn( "errorTable2" ); String expectedDropTables = "STEP Setup_tables(\n" + "APPLY \n" + " ('DROP TABLE logTable'),\n" + " ('DROP TABLE workTable'),\n" + " ('DROP TABLE errorTable'),\n" + " ('DROP TABLE errorTable2')\n" + "\n" + "TO OPERATOR ( DDL_OPERATOR )\n" + ";\n" + "\n" + ");\n"; String dropTables = teraDataBulkLoaderRoutines.getDropTables( true ); assertEquals( expectedDropTables, dropTables ); }
@VisibleForTesting String getDropTables( boolean isPreview ) { String dropTables = null; boolean drop = false; ApplyClause dropClauses = new ApplyClause(); if ( this.meta.getDropLogTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ), "" ) ) ); drop = true; } if ( this.meta.getDropWorkTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ), "WT" ) ) ); drop = true; } if ( this.meta.getDropErrorTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ), "ET" ) ) ); drop = true; } if ( this.meta.getDropErrorTable2() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ), "UV" ) ) ); drop = true; } if ( drop ) { dropTables = createStep( "Setup_tables", dropClauses.toString(), toSelectOperator( "DDL_OPERATOR", null ) ); } return dropTables; }
TeraDataBulkLoaderRoutines { @VisibleForTesting String getDropTables( boolean isPreview ) { String dropTables = null; boolean drop = false; ApplyClause dropClauses = new ApplyClause(); if ( this.meta.getDropLogTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ), "" ) ) ); drop = true; } if ( this.meta.getDropWorkTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ), "WT" ) ) ); drop = true; } if ( this.meta.getDropErrorTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ), "ET" ) ) ); drop = true; } if ( this.meta.getDropErrorTable2() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ), "UV" ) ) ); drop = true; } if ( drop ) { dropTables = createStep( "Setup_tables", dropClauses.toString(), toSelectOperator( "DDL_OPERATOR", null ) ); } return dropTables; } }
TeraDataBulkLoaderRoutines { @VisibleForTesting String getDropTables( boolean isPreview ) { String dropTables = null; boolean drop = false; ApplyClause dropClauses = new ApplyClause(); if ( this.meta.getDropLogTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ), "" ) ) ); drop = true; } if ( this.meta.getDropWorkTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ), "WT" ) ) ); drop = true; } if ( this.meta.getDropErrorTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ), "ET" ) ) ); drop = true; } if ( this.meta.getDropErrorTable2() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ), "UV" ) ) ); drop = true; } if ( drop ) { dropTables = createStep( "Setup_tables", dropClauses.toString(), toSelectOperator( "DDL_OPERATOR", null ) ); } return dropTables; } TeraDataBulkLoaderRoutines( TeraDataBulkLoader parent, TeraDataBulkLoaderMeta meta ); }
TeraDataBulkLoaderRoutines { @VisibleForTesting String getDropTables( boolean isPreview ) { String dropTables = null; boolean drop = false; ApplyClause dropClauses = new ApplyClause(); if ( this.meta.getDropLogTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ), "" ) ) ); drop = true; } if ( this.meta.getDropWorkTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ), "WT" ) ) ); drop = true; } if ( this.meta.getDropErrorTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ), "ET" ) ) ); drop = true; } if ( this.meta.getDropErrorTable2() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ), "UV" ) ) ); drop = true; } if ( drop ) { dropTables = createStep( "Setup_tables", dropClauses.toString(), toSelectOperator( "DDL_OPERATOR", null ) ); } return dropTables; } 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 String getDropTables( boolean isPreview ) { String dropTables = null; boolean drop = false; ApplyClause dropClauses = new ApplyClause(); if ( this.meta.getDropLogTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getLogTable() : parent.environmentSubstitute( this.meta.getLogTable() ), "" ) ) ); drop = true; } if ( this.meta.getDropWorkTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getWorkTable() : parent.environmentSubstitute( this.meta.getWorkTable() ), "WT" ) ) ); drop = true; } if ( this.meta.getDropErrorTable() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable() : parent.environmentSubstitute( this.meta.getErrorTable() ), "ET" ) ) ); drop = true; } if ( this.meta.getDropErrorTable2() ) { dropClauses.addClause( quote( dropTable( isPreview, isPreview ? this.meta.getErrorTable2() : parent.environmentSubstitute( this.meta.getErrorTable2() ), "UV" ) ) ); drop = true; } if ( drop ) { dropTables = createStep( "Setup_tables", dropClauses.toString(), toSelectOperator( "DDL_OPERATOR", null ) ); } return dropTables; } 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 );  }