GateKeeper { public boolean updateIsRequired(@NonNull final Bootstrap bootstrap) { final RequiredUpdate requiredUpdate = bootstrap.getRequiredUpdate(); return requiredUpdate != null && versionChecker.showRequiredUpdate(requiredUpdate, 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 showRequiredUpdateShouldReturnFalseWhenRequiredUpdateIsNull() { when(mockBootstrap.getRequiredUpdate()).thenReturn(null); Assert.assertFalse("RequiredUpdate is null, this should be false", subject.updateIsRequired(mockBootstrap)); }
@Test public void showRequiredUpdateShouldBeTrueWhenVersionCheckRequiresUpdate() { when(mockVersionChecker.showRequiredUpdate(Mockito.any(RequiredUpdate.class), Mockito.any(AppVersionDetails.class))).thenReturn(true); Assert.assertTrue(ASSERT_TRUE_MESSAGE, subject.updateIsRequired(mockBootstrap)); }
@Test public void showRequiredUpdateShouldBeFalseWhenVersionCheckFalse() { when(mockVersionChecker.showRequiredUpdate(Mockito.any(RequiredUpdate.class), Mockito.any(AppVersionDetails.class))).thenReturn(false); Assert.assertFalse(ASSERT_FALSE_MESSAGE, subject.updateIsRequired(mockBootstrap)); }