### Question:
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++ ) { IValueMeta 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 ( HopValueException 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, IVariables variables, int style, String transformName,
                            IRowMeta rowMeta, List<Object[]> rowBuffer );  PreviewRowsDialog( Shell parent, IVariables variables, int style, String transformName,
                            IRowMeta 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 IRowMeta rowMeta, final Object[] rowData ); void addDialogClosedListener( IDialogClosedListener listener ); static final int MAX_BINARY_STRING_PREVIEW_SIZE; }### Answer:
@Test public void getDataForRow() throws Exception { IRowMeta iRowMeta = Mockito.mock( IRowMeta.class ); Mockito.when( iRowMeta.size() ).thenReturn( 3 ); Mockito.when( iRowMeta.getValueMeta( Mockito.anyInt() ) ).thenReturn( Mockito.mock( IValueMeta.class ) ); PreviewRowsDialog previewRowsDialog = new PreviewRowsDialog( Mockito.mock( Shell.class ), Mockito.mock( IVariables.class ), SWT.None, "test", iRowMeta, Collections.emptyList() ); int actualResult = previewRowsDialog.getDataForRow( Mockito.mock( TableItem.class ), null ); Assert.assertEquals( 0, actualResult ); }