use of com.eventyay.organizer.data.tracks.Track in project open-event-orga-app by fossasia.
the class CreateSessionViewModel method updateSession.
// Method called for updating an session
public void updateSession(long trackId, long eventId) {
Track track = new Track();
Event event = new Event();
track.setId(trackId);
event.setId(eventId);
session.setTrack(track);
session.setEvent(event);
nullifyEmptyFields(session);
compositeDisposable.add(sessionRepository.updateSession(session).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedSession -> {
success.setValue("Session Updated Successfully");
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 CreateSessionViewModel method createSession.
public void createSession(long trackId, long eventId) {
if (!verify())
return;
Track track = new Track();
Event event = new Event();
track.setId(trackId);
event.setId(eventId);
session.setTrack(track);
session.setEvent(event);
nullifyEmptyFields(session);
compositeDisposable.add(sessionRepository.createSession(session).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdSession -> {
success.setValue("Session 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 CreateTrackViewModelTest method shouldShowErrorOnFailure.
@Test
public void shouldShowErrorOnFailure() {
Track track = createTrackViewModel.getTrack();
track.setDescription(null);
when(trackRepository.createTrack(track)).thenReturn(Observable.error(new Throwable("Error")));
ContextManager.setSelectedEvent(event);
InOrder inOrder = Mockito.inOrder(progress, error);
createTrackViewModel.getProgress().observeForever(progress);
createTrackViewModel.getError().observeForever(error);
createTrackViewModel.createTrack();
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 CreateTrackViewModelTest method shouldShowSuccessOnCreated.
@Test
public void shouldShowSuccessOnCreated() {
String successString = "Track Created";
Track track = createTrackViewModel.getTrack();
when(trackRepository.createTrack(track)).thenReturn(Observable.just(track));
ContextManager.setSelectedEvent(event);
InOrder inOrder = Mockito.inOrder(progress, dismiss, success);
createTrackViewModel.getProgress().observeForever(progress);
createTrackViewModel.getDismiss().observeForever(dismiss);
createTrackViewModel.getSuccess().observeForever(success);
createTrackViewModel.createTrack();
inOrder.verify(progress).onChanged(true);
inOrder.verify(success).onChanged(successString);
inOrder.verify(dismiss).onChanged(null);
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 TracksPresenterTest method testProgressbarOnSwipeRefreshNoItem.
@Test
public void testProgressbarOnSwipeRefreshNoItem() {
List<Track> emptyList = new ArrayList<>();
when(trackRepository.getTracks(ID, true)).thenReturn(Observable.fromIterable(emptyList));
tracksPresenter.loadTracks(true);
InOrder inOrder = Mockito.inOrder(tracksView);
inOrder.verify(tracksView).showProgress(true);
inOrder.verify(tracksView).onRefreshComplete(true);
inOrder.verify(tracksView).showProgress(false);
}
Aggregations