ColorSelector implements Predicate<Creature> { @Override public boolean test(Creature t) { return t.getColor().equals(c); } ColorSelector(Color c); @Override boolean test(Creature t);  }
@Test public void testColor() { final Creature greenCreature = mock(Creature.class); when(greenCreature.getColor()).thenReturn(Color.GREEN); final Creature redCreature = mock(Creature.class); when(redCreature.getColor()).thenReturn(Color.RED); final ColorSelector greenSelector = new ColorSelector(Color.GREEN); assertTrue(greenSelector.test(greenCreature)); assertFalse(greenSelector.test(redCreature)); }