FEST

FEST-225 implementation behaves wrongly - matches any value given

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: FEST-Swing 1.2a4
  • Fix Version/s: FEST-Swing 1.2rc
  • Component/s: Swing
  • Labels:
    None
  • Number of attachments :
    0

Description

From TableCellInRowByValue

@RunsInCurrentThread
  private static boolean matchingRow(JTable table, JTableCellReader cellReader, String[] values, int row) {
    int columnCount = table.getColumnCount();
    for (int col = 0; col < columnCount; col++) {
      if (areEqual(cellReader.valueAt(table, row, col), values[col])) return true;
    }
    return false;
  }

This returns true if any of the values in the columns match.
I cannot imagine this is intended?

Activity

Hide
Alex Ruiz added a comment -

Wow! this is pretty serious! I'll give this bug first priority. Thanks Morten for reporting this!

Cheers!

Show
Alex Ruiz added a comment - Wow! this is pretty serious! I'll give this bug first priority. Thanks Morten for reporting this! Cheers!
Hide
Alex Ruiz added a comment -

Hi Morten,

I went through the code and my test cases, and it behaves correctly. It matches the value in the given array with the value at the cell (with matching column index.) A test case would help figure out if this is really a bug.

Show
Alex Ruiz added a comment - Hi Morten, I went through the code and my test cases, and it behaves correctly. It matches the value in the given array with the value at the cell (with matching column index.) A test case would help figure out if this is really a bug.
Hide
Morten Breum Mikkelsen added a comment -

Hi.
I think it's pretty obvious that:
private static boolean matchingRow():
for (int col = 0; col < columnCount; col++) { if (areEqual(cellReader.valueAt(table, row, col), values[col])) return true; will return true if either of the cells in the row match the value in the correct place in the array I don't have the time right now to provide a finished test case, so I'm just going to provide the data that will produce the misbehaviour: Table contents: 'billy', 'willy', 'dilly' 'billy', 'willy', 'alone' 'billy', 'all', 'alone' provided array: ['billy', 'all', 'alone'] This will match all three rows, since the testing stops and returns when it finds that the cell containing 'billy' matches all right. This could be the intended behaviour, but if so, I suggest the method be renamed to "matchingAnyCellInRow" and another one introduced that looks more like this: would need an extra method that {code:java}
@RunsInCurrentThread
private static boolean matchingAllCellsInRow(JTable table, JTableCellReader cellReader, String[] values, int row) {
int columnCount = table.getColumnCount();
for (int col = 0; col < columnCount; col++) { if (!areEqual(cellReader.valueAt(table, row, col), values[col])) return false; //perhaps values[col] != null && areEquals(... }
return true;
}


Is this gibberish?

Show
Morten Breum Mikkelsen added a comment - Hi. I think it's pretty obvious that: private static boolean matchingRow(): for (int col = 0; col < columnCount; col++) { if (areEqual(cellReader.valueAt(table, row, col), values[col])) return true; will return true if either of the cells in the row match the value in the correct place in the array I don't have the time right now to provide a finished test case, so I'm just going to provide the data that will produce the misbehaviour: Table contents: 'billy', 'willy', 'dilly' 'billy', 'willy', 'alone' 'billy', 'all', 'alone' provided array: ['billy', 'all', 'alone'] This will match all three rows, since the testing stops and returns when it finds that the cell containing 'billy' matches all right. This could be the intended behaviour, but if so, I suggest the method be renamed to "matchingAnyCellInRow" and another one introduced that looks more like this: would need an extra method that {code:java} @RunsInCurrentThread private static boolean matchingAllCellsInRow(JTable table, JTableCellReader cellReader, String[] values, int row) { int columnCount = table.getColumnCount(); for (int col = 0; col < columnCount; col++) { if (!areEqual(cellReader.valueAt(table, row, col), values[col])) return false; //perhaps values[col] != null && areEquals(... } return true; }

Is this gibberish?
Hide
Alex Ruiz added a comment -

I got it. My test case is wrong. I'll be fixing this behavior shortly. Thanks!

Show
Alex Ruiz added a comment - I got it. My test case is wrong. I'll be fixing this behavior shortly. Thanks!

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: