Skip to content

Instantly share code, notes, and snippets.

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