Franziska Sauerwein
@Singsalad
https://github.com/franziskas/RefactoringJUnitTests
allOf(..)
anyOf(..)
not(..)
equalTo(..) / sameInstance(..)
instanceOf(..) / isCompatibleType(..)
notNullValue(..) / nullValue(..)
array(..) / hasItemInArray(..)
hasEntry(..) / hasKey(..) / hasValue(..)
hasItem(..), hasItems(..)
closeTo(..)
greaterThan(..) / greaterThanOrEqualTo(..)
lessThan(..) / lessThanOrEqualTo(..)
equalToIgnoringCase(..)
equalToIgnoringWhiteSpace(..)
containsString(..)
endsWith(..) / startsWith(..)
private Matcher<User> hasEmail() {
return new TypeSafeDiagnosingMatcher<Foo>() {
@Override
public void describeTo(final Description description) {
description.appendText("expected user to have an email");
}
@Override
protected boolean matchesSafely(final User user,
final Description mismatchDescription) {
mismatchDescription
.appendText(" was ")
.appendValue(user.getEmail();
return user.getEmail()!= null
&& user.getEmail().length() > 3;
} };}
private Matcher<User> hasEmail() {
return new TypeSafeDiagnosingMatcher<Foo>() {
@Override
public void describeTo(final Description description) {
description.appendText("expected user to have an email");
}
@Override
protected boolean matchesSafely(final User user,
final Description mismatchDescription) {
mismatchDescription
.appendText(" was ")
.appendValue(user.getEmail();
return user.getEmail()!= null
&& user.getEmail().length() > 3;
} };}
private Matcher<User> hasEmail() {
return new TypeSafeDiagnosingMatcher<Foo>() {
@Override
public void describeTo(final Description description) {
description.appendText("expected user to have an email");
}
@Override
protected boolean matchesSafely(final User user,
final Description mismatchDescription) {
mismatchDescription
.appendText(" was ")
.appendValue(user.getEmail();
return user.getEmail()!= null
&& user.getEmail().length() > 3;
} };}
private Matcher<User> hasEmail() {
return new TypeSafeDiagnosingMatcher<Foo>() {
@Override
public void describeTo(final Description description) {
description.appendText("expected user to have an email");
}
@Override
protected boolean matchesSafely(final User user,
final Description mismatchDescription) {
mismatchDescription
.appendText(" was ")
.appendValue(user.getEmail();
return user.getEmail()!= null
&& user.getEmail().length() > 3;
} };}