Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

EventCollector always uses TypeSafeMatcher.

  • Loading branch information...
commit f3ae021fb078fc3b1576febbce1b02e249329516 1 parent a538d25
@stefanbirkner stefanbirkner authored
View
18 src/test/java/org/junit/tests/experimental/rules/EventCollector.java
@@ -6,7 +6,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.hamcrest.BaseMatcher;
import org.hamcrest.Matcher;
import org.junit.internal.matchers.TypeSafeMatcher;
import org.junit.runner.Description;
@@ -21,9 +20,10 @@
private static Matcher<EventCollector> hasNumberOfFailures(
final int numberOfFailures) {
- return new BaseMatcher<EventCollector>() {
- public boolean matches(Object item) {
- return ((EventCollector) item).fFailures.size() == numberOfFailures;
+ return new TypeSafeMatcher<EventCollector>() {
+ @Override
+ public boolean matchesSafely(EventCollector item) {
+ return item.fFailures.size() == numberOfFailures;
}
public void describeTo(org.hamcrest.Description description) {
@@ -72,12 +72,12 @@ public void describeTo(org.hamcrest.Description description) {
static Matcher<EventCollector> hasSingleFailureWithMessage(
final Matcher<String> messageMatcher) {
- return new BaseMatcher<EventCollector>() {
- public boolean matches(Object item) {
+ return new TypeSafeMatcher<EventCollector>() {
+ @Override
+ public boolean matchesSafely(EventCollector item) {
return hasSingleFailure().matches(item)
- && messageMatcher
- .matches(((EventCollector) item).fFailures
- .get(0).getMessage());
+ && messageMatcher.matches(item.fFailures.get(0)
+ .getMessage());
}
public void describeTo(org.hamcrest.Description description) {
Please sign in to comment.
Something went wrong with that request. Please try again.