private ExecutionResult markSurplusRows(final QueryResults queryResults) { List<Integer> unmatchedRows = queryResults.getUnmatchedRows(); ExecutionResult result = ExecutionResult.PASS; for (int unmatchedRow : unmatchedRows) { List<String> surplusRow = queryResults.getList(fieldNames, unmatchedRow); int newTableRow = table.addRow(surplusRow); TestResult testResult = TestResult.fail(surplusRow.get(0), null, "surplus"); table.updateContent(0, newTableRow, testResult); getTestContext().increment(result); markMissingFields(surplusRow, newTableRow); result = ExecutionResult.FAIL; } return result; }
protected TestResult markField(int tableRow, int matchedRow, int col, QueryResults queryResults) { if (col >= fieldNames.size()) return null; // ignore strange table geometry. String fieldName = fieldNames.get(col); String actualValue = queryResults.getCell(fieldName, matchedRow); String expectedValue = table.getCellContents(col, tableRow); TestResult testResult; if (actualValue == null) testResult = TestResult.fail(String.format("field %s not present", fieldName), expectedValue); else if (expectedValue == null || expectedValue.length() == 0) testResult = TestResult.ignore(actualValue); else { testResult = matchMessage(actualValue, expectedValue); // if (testResult != null) // table.substitute(col, tableRow, replaceSymbolsWithFullExpansion(message)); // else // table.substitute(col, tableRow, replaceSymbolsWithFullExpansion(expectedValue)); // else if (testResult == null) testResult = TestResult.fail(actualValue, replaceSymbolsWithFullExpansion(expectedValue)); else if (testResult.getExecutionResult() == ExecutionResult.PASS) testResult = markMatch(tableRow, matchedRow, col, testResult.getMessage()); } table.updateContent(col, tableRow, testResult); getTestContext().increment(testResult.getExecutionResult()); return testResult; }
protected void scanRowForMatch(int tableRow, QueryResults queryResults) { int matchedRow = queryResults.findBestMatch(tableRow); if (matchedRow == -1) { replaceAllvariablesInRow(tableRow); TestResult testResult = TestResult.fail(null, table.getCellContents(0, tableRow), "missing"); table.updateContent(0, tableRow, testResult); getTestContext().increment(testResult.getExecutionResult()); } else { markFieldsInMatchedRow(tableRow, matchedRow, queryResults); } }