use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class SessionsPresenterTest method shouldDeleteSessionsSuccessfully.
@Test
public void shouldDeleteSessionsSuccessfully() {
for (Session session : sessionsPresenter.getSessions()) {
sessionsPresenter.getSelectedSessions().get(session.getId()).set(true);
}
for (Long sessionId : sessionsPresenter.getSelectedSessions().keySet()) {
when(sessionRepository.deleteSession(sessionId)).thenReturn(Completable.complete());
}
sessionsPresenter.deleteSelectedSessions();
InOrder inOrder = Mockito.inOrder(sessionsView);
inOrder.verify(sessionsView).showProgress(true);
inOrder.verify(sessionsView).showMessage(SESSION_DELETION_SUCCESS);
inOrder.verify(sessionsView).showProgress(false);
assertEquals(sessionsPresenter.getSelectedSessions().size(), 0);
}
use of com.eventyay.organizer.data.session.Session 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.session.Session 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.session.Session in project open-event-orga-app by fossasia.
the class SessionsPresenterTest method testProgressbarOnSwipeRefreshNoItem.
@Test
public void testProgressbarOnSwipeRefreshNoItem() {
List<Session> emptyList = new ArrayList<>();
when(sessionRepository.getSessions(ID, true)).thenReturn(Observable.fromIterable(emptyList));
sessionsPresenter.loadSessions(true);
InOrder inOrder = Mockito.inOrder(sessionsView);
inOrder.verify(sessionsView).showProgress(true);
inOrder.verify(sessionsView).onRefreshComplete(true);
inOrder.verify(sessionsView).showProgress(false);
}
use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class CreateSessionViewModelTest method shouldAcceptCorrectDates.
@Test
public void shouldAcceptCorrectDates() {
Session session = createSessionViewModel.getSession();
when(sessionRepository.createSession(session)).thenReturn(Observable.empty());
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
session.setStartsAt(isoDateNow);
session.setEndsAt(isoDateThen);
InOrder inOrder = Mockito.inOrder(sessionRepository, error);
createSessionViewModel.getError().observeForever(error);
createSessionViewModel.createSession(TRACK_ID, EVENT_ID);
inOrder.verify(error, never()).onChanged(anyString());
inOrder.verify(sessionRepository).createSession(session);
}
Aggregations