GateKeeper { public boolean updateIsOptional(@NonNull final Bootstrap bootstrap) { final OptionalUpdate optionalUpdate = bootstrap.getOptionalUpdate(); return optionalUpdate != null && !historyChecker.contains(optionalUpdate) && versionChecker.showOptionalUpdate(optionalUpdate, appVersionDetails); } 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 showOptionalUpdateShouldBeFalseIfOptionalUpdateIsNull() { when(mockBootstrap.getOptionalUpdate()).thenReturn(null); Assert.assertFalse("OptionalUpdate is null, should be false", subject.updateIsOptional(mockBootstrap)); }
@Test public void showOptionalUpdateShouldBeTrueWithAvailableTrueAndHistoryFalse() { setOptionalUpdateScenario(true, false); Assert.assertTrue(ASSERT_TRUE_MESSAGE, subject.updateIsOptional(mockBootstrap)); }
@Test public void showOptionalUpdateShouldBeFalseWithAvailableTrueAndHistoryTrue() { setOptionalUpdateScenario(true, true); Assert.assertFalse(ASSERT_FALSE_MESSAGE, subject.updateIsOptional(mockBootstrap)); }
@Test public void showOptionalUpdateShouldBeFalseWithAvailableFalseAndHistoryFalse() { setOptionalUpdateScenario(false, false); Assert.assertFalse(ASSERT_FALSE_MESSAGE, subject.updateIsOptional(mockBootstrap)); }
@Test public void showOptionalUpdateShouldBeFalseWithAvailableFalseAndHistoryTrue() { setOptionalUpdateScenario(false, true); Assert.assertFalse(ASSERT_FALSE_MESSAGE, subject.updateIsOptional(mockBootstrap)); }