BlankFormsListViewModel extends ViewModel { public LiveData<Boolean> isOutOfSync() { return Transformations.map(syncRepository.getSyncError(), Objects::nonNull); } BlankFormsListViewModel(Application application, Scheduler scheduler, SyncStatusRepository syncRepository, ServerFormsSynchronizer serverFormsSynchronizer, PreferencesProvider preferencesProvider, Notifier notifier, ChangeLock changeLock, Analytics analytics); boolean isMatchExactlyEnabled(); LiveData<Boolean> isSyncing(); LiveData<Boolean> isOutOfSync(); LiveData<Boolean> isAuthenticationRequired(); LiveData<Boolean> syncWithServer();  }
@Test public void isOutOfSync_followsRepositorySyncError() { MutableLiveData<FormApiException> liveData = new MutableLiveData<>(new FormApiException(FormApiException.Type.FETCH_ERROR)); when(syncRepository.getSyncError()).thenReturn(liveData); BlankFormsListViewModel viewModel = new BlankFormsListViewModel(mock(Application.class), mock(Scheduler.class), syncRepository, mock(ServerFormsSynchronizer.class), preferencesProvider, mock(Notifier.class), changeLock, analytics); LiveData<Boolean> outOfSync = liveDataTester.activate(viewModel.isOutOfSync()); assertThat(outOfSync.getValue(), is(true)); liveData.setValue(null); assertThat(outOfSync.getValue(), is(false)); }