public void shuffleColumnValues ( ArrayList < String > columns ) throws Exception { doubleValues . clear ( ) ; ArrayList < String > rows = this . getDataRows ( ) ; for ( String column : columns ) { //shuffle all values in the column ArrayList < Integer > rowIndex = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < rows . size ( ) ; i ++ ) { rowIndex . add ( i ) ; } Collections . shuffle ( rowIndex ) ; for ( int i = 0 ; i < rows . size ( ) ; i ++ ) { String row = rows . get ( i ) ; int randomIndex = rowIndex . get ( i ) ; String destinationRow = rows . get ( randomIndex ) ; String temp = this . getCell ( destinationRow , column ) ; String value = this . getCell ( row , column ) ; this . addCell ( destinationRow , column , value ) ; this . addCell ( row , column , temp ) ; } } }
Need to shuffle column values to allow for randomized testing . The columns in the list will be shuffled together