GateKeeper { public boolean showAlert(@NonNull final Bootstrap bootstrap) { final Alert alert = bootstrap.getAlert(); return alert != null && (versionChecker.showAlert(alert) || !historyChecker.contains(alert)); } GateKeeper(@NonNull final Context context, @NonNull VersionChecker versionChecker, @NonNull HistoryChecker historyChecker); boolean updateIsRequired(@NonNull final Bootstrap bootstrap); boolean updateIsOptional(@NonNull final Bootstrap bootstrap); boolean showAlert(@NonNull final Bootstrap bootstrap);  }
@Test public void showAlertShouldBeFalseWhenAlertIsNull() { when(mockBootstrap.getAlert()).thenReturn(null); Assert.assertFalse("Alert is null, should be false", subject.showAlert(mockBootstrap)); }
@Test public void showAlertShouldBeTrueIfShowIsTrue() { setAlertScenario(true, false); Assert.assertTrue(ASSERT_TRUE_MESSAGE, subject.showAlert(mockBootstrap)); }
@Test public void showAlertShouldBeTrueIfShowIsTrueAndHistoryMatches() { setAlertScenario(true, true); Assert.assertTrue(ASSERT_TRUE_MESSAGE, subject.showAlert(mockBootstrap)); }
@Test public void showAlertShouldBeTrueIfNotContainedInHistory() { setAlertScenario(false, false); Assert.assertTrue(ASSERT_TRUE_MESSAGE, subject.showAlert(mockBootstrap)); }
@Test public void showAlertShouldBeFalseIfHistoryMatchesAndShowIsFalse() { setAlertScenario(false, true); Assert.assertFalse(ASSERT_FALSE_MESSAGE, subject.showAlert(mockBootstrap)); }