Last active
August 29, 2015 13:59
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.tom; | |
import com.tom.zombie.Zombie; | |
import org.hamcrest.Matcher; | |
public class ZombieMatcher { | |
public static Matcher<Zombie> is(Zombie.Type type) { | |
return new FuncTypeSafeMatcher<Zombie>(z -> z.getType() == type, | |
(d) -> d.appendText("Zombie should be " + type), | |
(z, d) -> d.appendText("was " + z.getType())); | |
} | |
public static Matcher<Zombie> isKilled() { | |
return new FuncTypeSafeMatcher<Zombie>(z -> !z.isAlive(), | |
(d) -> d.appendText("Zombie should be killed"), | |
(z, d) -> d.appendText("was alive")); | |
} | |
public static Matcher<Zombie> isAlive() { | |
return new FuncTypeSafeMatcher<Zombie>(Zombie::isAlive, | |
(d) -> d.appendText("Zombie should be alive"), | |
(z, d) -> d.appendText("was killed")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment