@Test public void testInit_unsupportedConnection() { TableOutputMeta meta = mock( TableOutputMeta.class ); TableOutputData data = mock( TableOutputData.class ); DatabaseInterface dbInterface = mock( DatabaseInterface.class ); doNothing().when( tableOutputSpy ).logError( anyString() ); when( meta.getCommitSize() ).thenReturn( "1" ); when( meta.getDatabaseMeta() ).thenReturn( databaseMeta ); when( databaseMeta.getDatabaseInterface() ).thenReturn( dbInterface ); String unsupportedTableOutputMessage = "unsupported exception"; when( dbInterface.getUnsupportedTableOutputMessage() ).thenReturn( unsupportedTableOutputMessage ); //Will cause the Kettle Exception when( dbInterface.supportsStandardTableOutput() ).thenReturn( false ); tableOutputSpy.init( meta, data ); KettleException ke = new KettleException( unsupportedTableOutputMessage ); verify( tableOutputSpy, times( 1 ) ).logError( "An error occurred intialising this step: " + ke.getMessage() ); } }
protected void isConnectionSupported() { final String tableName = wTable.getText(), connectionName = wConnection.getText(); if ( !Utils.isEmpty( tableName ) ) { DatabaseMeta dbmeta = transMeta.findDatabase( connectionName ); if ( dbmeta != null && !dbmeta.getDatabaseInterface().supportsStandardTableOutput() ) { showUnsupportedConnectionMessageBox( dbmeta.getDatabaseInterface() ); } } }
if ( !dbInterface.supportsStandardTableOutput() ) { throw new KettleException( dbInterface.getUnsupportedTableOutputMessage() );