use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.
the class TrackRepositoryTest method shouldSetEventOnCreatedTrack.
@Test
public void shouldSetEventOnCreatedTrack() {
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(created).setEvent(EVENT);
}
use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.
the class TrackRepositoryTest method shouldUpdateUpdatedTrack.
@Test
public void shouldUpdateUpdatedTrack() {
Track updated = mock(Track.class);
when(repository.isConnected()).thenReturn(true);
when(trackApi.updateTrack(ID, TRACK)).thenReturn(Observable.just(updated));
when(repository.update(eq(Track.class), eq(updated))).thenReturn(Completable.complete());
trackRepository.updateTrack(TRACK).subscribe();
verify(repository).update(Track.class, updated);
}
use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.
the class UpdateTrackViewModelTest method shouldShowErrorOnUpdateFailure.
@Test
public void shouldShowErrorOnUpdateFailure() {
Track track = updateTrackViewModel.getTrack();
when(trackRepository.updateTrack(track)).thenReturn(Observable.error(new Throwable("Error")));
ContextManager.setSelectedEvent(event);
InOrder inOrder = Mockito.inOrder(progress, error);
updateTrackViewModel.getProgress().observeForever(progress);
updateTrackViewModel.getError().observeForever(error);
updateTrackViewModel.updateTrack();
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged("Error");
inOrder.verify(progress).onChanged(false);
ContextManager.setSelectedEvent(null);
}
use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.
the class CreateTrackViewModel method createTrack.
public void createTrack() {
nullifyEmptyFields(track);
long eventId = ContextManager.getSelectedEvent().getId();
Event event = new Event();
event.setId(eventId);
track.setEvent(event);
compositeDisposable.add(trackRepository.createTrack(track).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdTrack -> {
success.setValue("Track Created");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.
the class UpdateTrackViewModel method updateTrack.
public void updateTrack() {
nullifyEmptyFields(track);
long eventId = ContextManager.getSelectedEvent().getId();
Event event = new Event();
event.setId(eventId);
track.setEvent(event);
compositeDisposable.add(trackRepository.updateTrack(track).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedTrack -> {
success.setValue("Track Updated");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Aggregations