Created
June 12, 2019 19:07
-
-
Save jbleduigou/afc01f75579fbac6f61918a9d5f75754 to your computer and use it in GitHub Desktop.
MatcherV1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.jbleduigou.beer.matchers; | |
import com.github.jbleduigou.beer.model.Beer; | |
import org.hamcrest.Description; | |
import org.hamcrest.TypeSafeMatcher; | |
import java.util.Objects; | |
class BeerWithName extends TypeSafeMatcher<Beer> { | |
private final String name; | |
BeerWithName(String name) { | |
this.name = name; | |
} | |
@Override | |
protected boolean matchesSafely(Beer beer) { | |
return Objects.equals(beer.getName(), name); | |
} | |
@Override | |
public void describeTo(Description description) { | |
description.appendText("beer with name ").appendValue(name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment