示例#1
0
 private static boolean resultsMatch(
     QueryResult controlResult, QueryResult testResult, int precision) {
   SortedMultiset<List<Object>> control =
       ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResult.getResults());
   SortedMultiset<List<Object>> test =
       ImmutableSortedMultiset.copyOf(rowComparator(precision), testResult.getResults());
   try {
     return control.equals(test);
   } catch (TypesDoNotMatchException e) {
     return false;
   }
 }
示例#2
0
  public String getResultsComparison(int precision) {
    List<List<Object>> controlResults = controlResult.getResults();
    List<List<Object>> testResults = testResult.getResults();

    if (valid() || (controlResults == null) || (testResults == null)) {
      return "";
    }

    Multiset<List<Object>> control =
        ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResults);
    Multiset<List<Object>> test =
        ImmutableSortedMultiset.copyOf(rowComparator(precision), testResults);

    try {
      Iterable<ChangedRow> diff =
          ImmutableSortedMultiset.<ChangedRow>naturalOrder()
              .addAll(
                  Iterables.transform(
                      Multisets.difference(control, test),
                      row -> new ChangedRow(Changed.REMOVED, row, precision)))
              .addAll(
                  Iterables.transform(
                      Multisets.difference(test, control),
                      row -> new ChangedRow(Changed.ADDED, row, precision)))
              .build();
      diff = Iterables.limit(diff, 100);

      StringBuilder sb = new StringBuilder();

      sb.append(format("Control %s rows, Test %s rows%n", control.size(), test.size()));
      if (verboseResultsComparison) {
        Joiner.on("\n").appendTo(sb, diff);
      } else {
        sb.append("RESULTS DO NOT MATCH\n");
      }

      return sb.toString();
    } catch (TypesDoNotMatchException e) {
      return e.getMessage();
    }
  }