### Question:
SingleLabelEvaluator implements Evaluator { @Override public void evaluate(AppAnalysisReport expectedResults, AppAnalysisReport results) throws EvaluationException { Set<Labelable> referenceComponents = new HashSet<Labelable>(); referenceComponents.addAll(expectedResults.getComponents()); for (Labelable labelable : results.getComponents()) { Set<Label> resultingLabels = results.getLabels(labelable); if (resultingLabels.size() != 1) { throw new EvaluationException("Multiple labels for " + labelable.getName()); } String resultingLabel = resultingLabels.iterator().next().getName(); Set<Label> referenceLabels = expectedResults.getLabels(labelable); String referenceLabel = null; if (referenceLabels == null || referenceLabels.isEmpty()) { referenceLabel = mNormalLabel; } else if (referenceLabels.size() != 1) { throw new EvaluationException("Multiple reference labels for " + labelable.getName()); } else { referenceLabel = referenceLabels.iterator().next().getName(); } mEvaluationResults.increaseTotal(labelable); if (resultingLabel.equals(referenceLabel)) { mEvaluationResults.increaseCorrect(labelable); EvaluationResult label = getResult(resultingLabel); label.increaseCorrect(labelable); label.increaseTotal(labelable); } else { mEvaluationResults.increaseWrong(labelable); EvaluationResult label = getResult(resultingLabel); label.increaseFalsePositives(labelable); label.increaseWrong(labelable); label = getResult(referenceLabel); label.increaseFalseNegatives(labelable); label.increaseTotal(labelable); label.increaseWrong(labelable); } referenceComponents.remove(labelable); } for (Labelable labelable : referenceComponents) { Set<Label> referenceLabels = expectedResults.getLabels(labelable); String referenceLabel = null; if (referenceLabels == null || referenceLabels.isEmpty()) { referenceLabel = mNormalLabel; } else if (referenceLabels.size() != 1) { throw new EvaluationException("Multiple reference labels for " + labelable.getName()); } else { referenceLabel = referenceLabels.iterator().next().getName(); } if (referenceLabel.equals(mNormalLabel)) { continue; } else { mEvaluationResults.increaseTotal(labelable); mEvaluationResults.increaseWrong(labelable); EvaluationResult label = getResult(referenceLabel); label.increaseWrong(labelable); label.increaseTotal(labelable); label.increaseFalseNegatives(labelable); if (mNormalLabel != null) { label = getResult(mNormalLabel); label.increaseWrong(labelable); label.increaseFalsePositives(labelable); } } } } SingleLabelEvaluator(String name);  SingleLabelEvaluator(String name, String normalLabel); @Override void evaluate(AppAnalysisReport expectedResults, AppAnalysisReport results); @Override EvaluationResults getResults();  }### Answer:
@Test public void testEvaluate() throws Exception { mEvaluator.evaluate(mExpected, mReport); EvaluationResults results = mEvaluator.getResults(); print("TOTAL", results.getTotalComponents()); assertEquals(9, results.getTotal()); System.out.println("OK"); print("CORRECT", results.getCorrectComponents()); assertEquals(3, results.getCorrect()); System.out.println("OK"); print("WRONG", results.getWrongComponents()); assertEquals(6, results.getWrong()); System.out.println("OK"); EvaluationResult a = results.getResult("A"); assertEvaluationResult(a, 4, 1, 6, 3, 3); EvaluationResult b = results.getResult("B"); assertEvaluationResult(b, 1, 0, 2, 1, 1); EvaluationResult n = results.getResult("NORMAL"); assertEvaluationResult(n, 4, 2, 4, 2, 2); }