@Test public void getDataForRow() throws Exception { RowMetaInterface rowMetaInterface = Mockito.mock( RowMetaInterface.class ); Mockito.when( rowMetaInterface.size() ).thenReturn( 3 ); Mockito.when( rowMetaInterface.getValueMeta( Mockito.anyInt() ) ).thenReturn( Mockito.mock( ValueMetaInterface.class ) ); Field propsField = Props.class.getDeclaredField( "props" ); propsField.setAccessible( true ); propsField.set( PropsUI.class, Mockito.mock( PropsUI.class ) ); PreviewRowsDialog previewRowsDialog = new PreviewRowsDialog( Mockito.mock( Shell.class ), Mockito.mock( VariableSpace.class ), SWT.None, "test", rowMetaInterface, Collections.emptyList() ); int actualResult = previewRowsDialog.getDataForRow( Mockito.mock( TableItem.class ), null ); Assert.assertEquals( 0, actualResult ); }
protected int getDataForRow( TableItem item, Object[] row ) { int nrErrors = 0; if ( row == null ) { return nrErrors; } String strNr; lineNr++; try { strNr = wFields.getNumberColumn().getValueMeta().getString( new Long( lineNr ) ); } catch ( Exception e ) { strNr = Integer.toString( lineNr ); } item.setText( 0, strNr ); for ( int c = 0; c < rowMeta.size(); c++ ) { ValueMetaInterface v = rowMeta.getValueMeta( c ); String show; try { show = v.getString( row[c] ); if ( v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE ) { show = show.substring( 0, MAX_BINARY_STRING_PREVIEW_SIZE ); } } catch ( KettleValueException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } catch ( ArrayIndexOutOfBoundsException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } if ( show != null ) { item.setText( c + 1, show ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlack() ); } else { item.setText( c + 1, "<null>" ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlue() ); } } return nrErrors; }
PreviewRowsDialog { protected int getDataForRow( TableItem item, Object[] row ) { int nrErrors = 0; if ( row == null ) { return nrErrors; } String strNr; lineNr++; try { strNr = wFields.getNumberColumn().getValueMeta().getString( new Long( lineNr ) ); } catch ( Exception e ) { strNr = Integer.toString( lineNr ); } item.setText( 0, strNr ); for ( int c = 0; c < rowMeta.size(); c++ ) { ValueMetaInterface v = rowMeta.getValueMeta( c ); String show; try { show = v.getString( row[c] ); if ( v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE ) { show = show.substring( 0, MAX_BINARY_STRING_PREVIEW_SIZE ); } } catch ( KettleValueException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } catch ( ArrayIndexOutOfBoundsException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } if ( show != null ) { item.setText( c + 1, show ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlack() ); } else { item.setText( c + 1, "<null>" ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlue() ); } } return nrErrors; } }
PreviewRowsDialog { protected int getDataForRow( TableItem item, Object[] row ) { int nrErrors = 0; if ( row == null ) { return nrErrors; } String strNr; lineNr++; try { strNr = wFields.getNumberColumn().getValueMeta().getString( new Long( lineNr ) ); } catch ( Exception e ) { strNr = Integer.toString( lineNr ); } item.setText( 0, strNr ); for ( int c = 0; c < rowMeta.size(); c++ ) { ValueMetaInterface v = rowMeta.getValueMeta( c ); String show; try { show = v.getString( row[c] ); if ( v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE ) { show = show.substring( 0, MAX_BINARY_STRING_PREVIEW_SIZE ); } } catch ( KettleValueException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } catch ( ArrayIndexOutOfBoundsException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } if ( show != null ) { item.setText( c + 1, show ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlack() ); } else { item.setText( c + 1, "<null>" ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlue() ); } } return nrErrors; } PreviewRowsDialog( Shell parent, VariableSpace space, int style, String stepName,
    RowMetaInterface rowMeta, List<Object[]> rowBuffer );  PreviewRowsDialog( Shell parent, VariableSpace space, int style, String stepName,
    RowMetaInterface rowMeta, List<Object[]> rowBuffer, String loggingText ); }
PreviewRowsDialog { protected int getDataForRow( TableItem item, Object[] row ) { int nrErrors = 0; if ( row == null ) { return nrErrors; } String strNr; lineNr++; try { strNr = wFields.getNumberColumn().getValueMeta().getString( new Long( lineNr ) ); } catch ( Exception e ) { strNr = Integer.toString( lineNr ); } item.setText( 0, strNr ); for ( int c = 0; c < rowMeta.size(); c++ ) { ValueMetaInterface v = rowMeta.getValueMeta( c ); String show; try { show = v.getString( row[c] ); if ( v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE ) { show = show.substring( 0, MAX_BINARY_STRING_PREVIEW_SIZE ); } } catch ( KettleValueException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } catch ( ArrayIndexOutOfBoundsException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } if ( show != null ) { item.setText( c + 1, show ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlack() ); } else { item.setText( c + 1, "<null>" ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlue() ); } } return nrErrors; } PreviewRowsDialog( Shell parent, VariableSpace space, int style, String stepName,
    RowMetaInterface rowMeta, List<Object[]> rowBuffer );  PreviewRowsDialog( Shell parent, VariableSpace space, int style, String stepName,
    RowMetaInterface rowMeta, List<Object[]> rowBuffer, String loggingText ); void setTitleMessage( String title, String message ); void open(); void dispose(); boolean isDisposed(); Rectangle getBounds(); void setBounds( Rectangle b ); int getHScroll(); void setHScroll( int s ); int getVScroll(); void setVScroll( int s ); int getHMax(); void setHMax( int m ); int getVMax(); void setVMax( int m ); boolean isAskingForMoreRows(); boolean isProposingToGetMoreRows(); void setProposingToGetMoreRows( boolean proposingToGetMoreRows ); boolean isAskingToStop(); boolean isProposingToStop(); void setProposingToStop( boolean proposingToStop ); void setDynamic( boolean dynamic ); synchronized void addDataRow( final RowMetaInterface rowMeta, final Object[] rowData ); void addDialogClosedListener( DialogClosedListener listener ); }
PreviewRowsDialog { protected int getDataForRow( TableItem item, Object[] row ) { int nrErrors = 0; if ( row == null ) { return nrErrors; } String strNr; lineNr++; try { strNr = wFields.getNumberColumn().getValueMeta().getString( new Long( lineNr ) ); } catch ( Exception e ) { strNr = Integer.toString( lineNr ); } item.setText( 0, strNr ); for ( int c = 0; c < rowMeta.size(); c++ ) { ValueMetaInterface v = rowMeta.getValueMeta( c ); String show; try { show = v.getString( row[c] ); if ( v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE ) { show = show.substring( 0, MAX_BINARY_STRING_PREVIEW_SIZE ); } } catch ( KettleValueException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } catch ( ArrayIndexOutOfBoundsException e ) { nrErrors++; if ( nrErrors < 25 ) { log.logError( Const.getStackTracker( e ) ); } show = null; } if ( show != null ) { item.setText( c + 1, show ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlack() ); } else { item.setText( c + 1, "<null>" ); item.setForeground( c + 1, GUIResource.getInstance().getColorBlue() ); } } return nrErrors; } PreviewRowsDialog( Shell parent, VariableSpace space, int style, String stepName,
    RowMetaInterface rowMeta, List<Object[]> rowBuffer );  PreviewRowsDialog( Shell parent, VariableSpace space, int style, String stepName,
    RowMetaInterface rowMeta, List<Object[]> rowBuffer, String loggingText ); void setTitleMessage( String title, String message ); void open(); void dispose(); boolean isDisposed(); Rectangle getBounds(); void setBounds( Rectangle b ); int getHScroll(); void setHScroll( int s ); int getVScroll(); void setVScroll( int s ); int getHMax(); void setHMax( int m ); int getVMax(); void setVMax( int m ); boolean isAskingForMoreRows(); boolean isProposingToGetMoreRows(); void setProposingToGetMoreRows( boolean proposingToGetMoreRows ); boolean isAskingToStop(); boolean isProposingToStop(); void setProposingToStop( boolean proposingToStop ); void setDynamic( boolean dynamic ); synchronized void addDataRow( final RowMetaInterface rowMeta, final Object[] rowData ); void addDialogClosedListener( DialogClosedListener listener ); static final int MAX_BINARY_STRING_PREVIEW_SIZE; }