/*
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.gnd.ui.tos;

import static com.google.common.truth.Truth.assertThat;

import com.google.android.gnd.BaseHiltTest;
import com.google.android.gnd.repository.TermsOfServiceRepository;
import com.google.android.gnd.ui.common.Navigator;
import com.google.android.gnd.ui.home.HomeScreenFragmentDirections;
import dagger.hilt.android.testing.BindValue;
import dagger.hilt.android.testing.HiltAndroidTest;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;

@HiltAndroidTest
@RunWith(RobolectricTestRunner.class)
public class TermsOfServiceViewModelTest extends BaseHiltTest {

  @BindValue @Mock Navigator mockNavigator;
  @BindValue @Mock TermsOfServiceRepository mockRepository;

  @Inject TermsOfServiceViewModel viewModel;

  @Test
  public void testOnButtonClicked() {
    viewModel.onButtonClicked();
    Mockito.verify(mockRepository, Mockito.times(1)).setTermsOfServiceAccepted(true);
    Mockito.verify(mockNavigator, Mockito.times(1))
        .navigate(HomeScreenFragmentDirections.showHomeScreen());
  }

  @Test
  public void testTermsOfServiceText() {
    viewModel.setTermsOfServiceText("Terms Text");
    assertThat(viewModel.getTermsOfServiceText()).isEqualTo("Terms Text");
  }
}

@@ -686,16 +686,58 @@
 tThat;%0A%0A
+import androidx.navigation.NavDirections;%0A
 import c
@@ -962,54 +962,8 @@
 ns;%0A
-import dagger.hilt.android.testing.BindValue;%0A
 impo
@@ -1006,24 +1006,68 @@
 ndroidTest;%0A
+import io.reactivex.observers.TestObserver;%0A
 import javax
@@ -1142,61 +1142,8 @@
 th;%0A
-import org.mockito.Mock;%0Aimport org.mockito.Mockito;%0A
 impo
@@ -1308,31 +1308,22 @@
 t %7B%0A%0A  @
-BindValue @Mock
+Inject
  Navigat
@@ -1325,21 +1325,17 @@
 vigator 
-mockN
+n
 avigator
@@ -1343,23 +1343,14 @@
 %0A  @
-BindValue @Mock
+Inject
  Ter
@@ -1371,20 +1371,30 @@
 ository 
-mock
+termsOfService
 Reposito
@@ -1397,17 +1397,16 @@
 sitory;%0A
-%0A
   @Injec
@@ -1485,24 +1485,112 @@
 Clicked() %7B%0A
+    TestObserver%3CNavDirections%3E testObserver = navigator.getNavigateRequests().test();%0A%0A
     viewMode
@@ -1614,64 +1614,51 @@
 ();%0A
+%0A
     
-Mockito.verify(mockRepository, Mockito.times(1)).set
+assertThat(termsOfServiceRepository.is
 Term
@@ -1680,65 +1680,91 @@
 ted(
-t
+)).isT
 rue
+(
 );%0A    
-Mockito.verify(mockNavigator, Mockito.times(1)
+testObserver%0A        .assertNoErrors()%0A        .assertNotComplete(
 )%0A  
@@ -1770,23 +1770,26 @@
        .
-navigat
+assertValu
 e(HomeSc

Use actual instances instead of mocks in TermsOfServiceViewModelTest