Search in sources :

Example 11 with Track

use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.

the class UpdateTrackViewModelTest method shouldShowSuccessOnUpdate.

@Test
public void shouldShowSuccessOnUpdate() {
    String successString = "Track Updated";
    Track track = updateTrackViewModel.getTrack();
    when(trackRepository.updateTrack(track)).thenReturn(Observable.just(track));
    ContextManager.setSelectedEvent(event);
    InOrder inOrder = Mockito.inOrder(progress, dismiss, success);
    updateTrackViewModel.getProgress().observeForever(progress);
    updateTrackViewModel.getDismiss().observeForever(dismiss);
    updateTrackViewModel.getSuccess().observeForever(success);
    updateTrackViewModel.updateTrack();
    inOrder.verify(progress).onChanged(true);
    inOrder.verify(success).onChanged(successString);
    inOrder.verify(dismiss).onChanged(null);
    inOrder.verify(progress).onChanged(false);
    ContextManager.setSelectedEvent(null);
}
Also used : InOrder(org.mockito.InOrder) Track(com.eventyay.organizer.data.tracks.Track) Test(org.junit.Test)

Example 12 with Track

use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.

the class TrackRepositoryTest method shouldSaveCreatedTrack.

@Test
public void shouldSaveCreatedTrack() {
    Track created = mock(Track.class);
    when(repository.isConnected()).thenReturn(true);
    when(trackApi.postTrack(TRACK)).thenReturn(Observable.just(created));
    when(repository.save(eq(Track.class), eq(created))).thenReturn(Completable.complete());
    trackRepository.createTrack(TRACK).subscribe();
    verify(repository).save(Track.class, created);
}
Also used : Track(com.eventyay.organizer.data.tracks.Track) Test(org.junit.Test)

Aggregations

Track (com.eventyay.organizer.data.tracks.Track)12 Test (org.junit.Test)8 InOrder (org.mockito.InOrder)5 LiveData (androidx.lifecycle.LiveData)4 ViewModel (androidx.lifecycle.ViewModel)4 SingleEventLiveData (com.eventyay.organizer.common.livedata.SingleEventLiveData)4 Event (com.eventyay.organizer.data.event.Event)4 ErrorUtils (com.eventyay.organizer.utils.ErrorUtils)4 StringUtils (com.eventyay.organizer.utils.StringUtils)4 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)4 Inject (javax.inject.Inject)4 Color (android.graphics.Color)2 ContextManager (com.eventyay.organizer.common.ContextManager)2 Session (com.eventyay.organizer.data.session.Session)2 SessionRepository (com.eventyay.organizer.data.session.SessionRepository)2 TrackRepository (com.eventyay.organizer.data.tracks.TrackRepository)2 DateUtils (com.eventyay.organizer.utils.DateUtils)2 LocalDateTime (org.threeten.bp.LocalDateTime)2 ZonedDateTime (org.threeten.bp.ZonedDateTime)2 DateTimeParseException (org.threeten.bp.format.DateTimeParseException)2