diff --git a/infer/tests/utils/matchers/ResultContainsLineNumbers.java b/infer/tests/utils/matchers/ResultContainsLineNumbers.java index 7b68fcefe..a6df40f55 100644 --- a/infer/tests/utils/matchers/ResultContainsLineNumbers.java +++ b/infer/tests/utils/matchers/ResultContainsLineNumbers.java @@ -9,12 +9,13 @@ package utils.matchers; +import com.google.common.base.Optional; + import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; import java.util.Arrays; -import java.util.Optional; import java.util.Vector; import utils.InferError; @@ -29,10 +30,10 @@ public class ResultContainsLineNumbers extends BaseMatcher { public ResultContainsLineNumbers( int[] lines, boolean strict, - String bugType) { + Optional bugType) { this.lines = lines; this.strict = strict; - this.bugType = Optional.ofNullable(bugType); + this.bugType = bugType; } @Override @@ -45,7 +46,7 @@ public class ResultContainsLineNumbers extends BaseMatcher { for (int line : lines) { boolean isContained = false; for (InferError error : errors) { - String bugType = this.bugType.orElse(error.getErrorType()); + String bugType = this.bugType.or(error.getErrorType()); boolean isSameErrType = bugType.equals(error.getErrorType()); isContained = isContained || (line == error.getErrorLine() && isSameErrType); } @@ -71,19 +72,19 @@ public class ResultContainsLineNumbers extends BaseMatcher { } public static Matcher containsLines(int[] lines) { - return new ResultContainsLineNumbers(lines, false, null); + return new ResultContainsLineNumbers(lines, false, Optional.absent()); } public static Matcher containsOnlyLines(int[] lines) { - return new ResultContainsLineNumbers(lines, true, null); + return new ResultContainsLineNumbers(lines, true, Optional.absent()); } public static Matcher containsLinesOfError(int[] lines, String bugType) { - return new ResultContainsLineNumbers(lines, false, bugType); + return new ResultContainsLineNumbers(lines, false, Optional.of(bugType)); } public static Matcher containsOnlyLinesOfError(int[] lines, String bugType) { - return new ResultContainsLineNumbers(lines, true, bugType); + return new ResultContainsLineNumbers(lines, true, Optional.of(bugType)); } private int[] findLineNumbersInReport(InferResults results) {