use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class CreateSessionViewModelTest method shouldShowSuccessOnCreated.
@Test
public void shouldShowSuccessOnCreated() {
Session session = createSessionViewModel.getSession();
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
session.setStartsAt(isoDateNow);
session.setEndsAt(isoDateThen);
when(sessionRepository.createSession(createSessionViewModel.getSession())).thenReturn(Observable.just(SESSION));
InOrder inOrder = Mockito.inOrder(progress, success, dismiss);
createSessionViewModel.getProgress().observeForever(progress);
createSessionViewModel.getSuccess().observeForever(success);
createSessionViewModel.getDismiss().observeForever(dismiss);
createSessionViewModel.createSession(TRACK_ID, EVENT_ID);
inOrder.verify(progress).onChanged(true);
inOrder.verify(success).onChanged(anyString());
inOrder.verify(dismiss).onChanged(null);
inOrder.verify(progress).onChanged(false);
}
use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class CreateSessionViewModelTest method shouldShowErrorOnUpdateFailure.
@Test
public void shouldShowErrorOnUpdateFailure() {
Session session = createSessionViewModel.getSession();
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
session.setStartsAt(isoDateNow);
session.setEndsAt(isoDateThen);
when(sessionRepository.updateSession(createSessionViewModel.getSession())).thenReturn(Observable.error(new Throwable(ERROR)));
InOrder inOrder = Mockito.inOrder(progress, error);
createSessionViewModel.getProgress().observeForever(progress);
createSessionViewModel.getError().observeForever(error);
createSessionViewModel.updateSession(TRACK_ID, EVENT_ID);
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged(anyString());
inOrder.verify(progress).onChanged(false);
}
use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class CreateSessionViewModelTest method shouldNullifyEmptyFields.
@Test
public void shouldNullifyEmptyFields() {
Session session = createSessionViewModel.getSession();
when(sessionRepository.createSession(session)).thenReturn(Observable.just(session));
session.setSlidesUrl("");
session.setAudioUrl("");
session.setVideoUrl("");
session.setSignupUrl("");
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
session.setStartsAt(isoDateNow);
session.setEndsAt(isoDateMax);
createSessionViewModel.createSession(TRACK_ID, EVENT_ID);
assertNull(session.getSlidesUrl());
assertNull(session.getAudioUrl());
assertNull(session.getVideoUrl());
assertNull(session.getSignupUrl());
}
use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class CreateSessionViewModelTest method shouldShowErrorOnFailure.
@Test
public void shouldShowErrorOnFailure() {
Session session = createSessionViewModel.getSession();
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
session.setStartsAt(isoDateNow);
session.setEndsAt(isoDateThen);
when(sessionRepository.createSession(createSessionViewModel.getSession())).thenReturn(Observable.error(new Throwable(ERROR)));
InOrder inOrder = Mockito.inOrder(progress, error);
createSessionViewModel.getProgress().observeForever(progress);
createSessionViewModel.getError().observeForever(error);
createSessionViewModel.createSession(TRACK_ID, EVENT_ID);
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged(anyString());
inOrder.verify(progress).onChanged(false);
}
use of com.eventyay.organizer.data.session.Session in project open-event-orga-app by fossasia.
the class CreateSessionViewModelTest method shouldRejectWrongDates.
@Test
public void shouldRejectWrongDates() {
Session session = createSessionViewModel.getSession();
String isoDate = DateUtils.formatDateToIso(LocalDateTime.now());
session.setStartsAt(isoDate);
session.setEndsAt(isoDate);
InOrder inOrder = Mockito.inOrder(sessionRepository, error);
createSessionViewModel.getError().observeForever(error);
createSessionViewModel.createSession(TRACK_ID, EVENT_ID);
inOrder.verify(error).onChanged(anyString());
inOrder.verify(sessionRepository, never()).createSession(any());
}
Aggregations