Skip to content

Instantly share code, notes, and snippets.

@ohade
Last active May 10, 2019 09:15
Show Gist options
  • Save ohade/e3a248d281cebc66e3c6b9ab9c584256 to your computer and use it in GitHub Desktop.
Save ohade/e3a248d281cebc66e3c6b9ab9c584256 to your computer and use it in GitHub Desktop.
@RunWith(MockitoJUnitRunner.class)
public class BouncerTest {
@Mock
private EntranceChecker entranceChecker;
private Bouncer bouncer;
@Mock
Person inListPerson;
@Mock
Person notInListPerson;
@Before
public init() {
Mockito.when(entranceChecker.isInTheGuestList(inListPerson)).thenReturn(true);
Mockito.when(entranceChecker.isInTheGuestList(notInListPerson)).thenReturn(false);
this.bouncer = new Bouncer(entranceChecker);
}
@Test
public boolean shouldBlock_nullPerson_notBlock() {
boolean result = bouncer.shouldBlock(inListPerson);
Assert.assertTrue(result);
}
@Test
public boolean shouldBlock_nullPerson_block() {
boolean result = bouncer.shouldBlock(notInListPerson);
Assert.assertTrue(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment