@Test public void allEvaluatorsAreCalledInSequence() { Evaluator e1 = new Evaluator(ComparisonResult.SIMILAR); Evaluator e2 = new Evaluator(ComparisonResult.EQUAL); DifferenceEvaluator d = DifferenceEvaluators.chain(e1, e2); assertEquals(ComparisonResult.EQUAL, d.evaluate(null, ComparisonResult.DIFFERENT)); assertTrue(e1.called); assertThat(e1.orig, is(ComparisonResult.DIFFERENT)); assertTrue(e2.called); assertThat(e2.orig, is(ComparisonResult.SIMILAR)); }
public static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators) { return new DifferenceEvaluator() { @Override public ComparisonResult evaluate(Comparison comparison, ComparisonResult orig) { ComparisonResult finalResult = orig; for (DifferenceEvaluator ev : evaluators) { ComparisonResult evaluated = ev.evaluate(comparison, finalResult); finalResult = evaluated; } return finalResult; } }; }
DifferenceEvaluators { public static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators) { return new DifferenceEvaluator() { @Override public ComparisonResult evaluate(Comparison comparison, ComparisonResult orig) { ComparisonResult finalResult = orig; for (DifferenceEvaluator ev : evaluators) { ComparisonResult evaluated = ev.evaluate(comparison, finalResult); finalResult = evaluated; } return finalResult; } }; } }
DifferenceEvaluators { public static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators) { return new DifferenceEvaluator() { @Override public ComparisonResult evaluate(Comparison comparison, ComparisonResult orig) { ComparisonResult finalResult = orig; for (DifferenceEvaluator ev : evaluators) { ComparisonResult evaluated = ev.evaluate(comparison, finalResult); finalResult = evaluated; } return finalResult; } }; } private  DifferenceEvaluators(); }
DifferenceEvaluators { public static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators) { return new DifferenceEvaluator() { @Override public ComparisonResult evaluate(Comparison comparison, ComparisonResult orig) { ComparisonResult finalResult = orig; for (DifferenceEvaluator ev : evaluators) { ComparisonResult evaluated = ev.evaluate(comparison, finalResult); finalResult = evaluated; } return finalResult; } }; } private  DifferenceEvaluators(); static DifferenceEvaluator first(final DifferenceEvaluator... evaluators); static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators); static DifferenceEvaluator downgradeDifferencesToEqual(ComparisonType... types); static DifferenceEvaluator downgradeDifferencesToSimilar(ComparisonType... types); static DifferenceEvaluator upgradeDifferencesToDifferent(ComparisonType... types); static DifferenceEvaluator ignorePrologDifferences(); static DifferenceEvaluator ignorePrologDifferencesExceptDoctype(); }
DifferenceEvaluators { public static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators) { return new DifferenceEvaluator() { @Override public ComparisonResult evaluate(Comparison comparison, ComparisonResult orig) { ComparisonResult finalResult = orig; for (DifferenceEvaluator ev : evaluators) { ComparisonResult evaluated = ev.evaluate(comparison, finalResult); finalResult = evaluated; } return finalResult; } }; } private  DifferenceEvaluators(); static DifferenceEvaluator first(final DifferenceEvaluator... evaluators); static DifferenceEvaluator chain(final DifferenceEvaluator... evaluators); static DifferenceEvaluator downgradeDifferencesToEqual(ComparisonType... types); static DifferenceEvaluator downgradeDifferencesToSimilar(ComparisonType... types); static DifferenceEvaluator upgradeDifferencesToDifferent(ComparisonType... types); static DifferenceEvaluator ignorePrologDifferences(); static DifferenceEvaluator ignorePrologDifferencesExceptDoctype(); static final DifferenceEvaluator Accept; static final DifferenceEvaluator Default; }