use of com.eventyay.organizer.data.speakerscall.SpeakersCall in project open-event-orga-app by fossasia.
the class CreateSpeakersCallViewModelTest method shouldRejectWrongFormatDates.
@Test
public void shouldRejectWrongFormatDates() {
SPEAKERS_CALL.setStartsAt("2011/12/03");
SPEAKERS_CALL.setEndsAt("2011/03/03");
createSpeakersCallViewModel.setSpeakersCall(SPEAKERS_CALL);
LiveData<SpeakersCall> speakersCallLiveData = createSpeakersCallViewModel.getSpeakersCall();
when(speakersCallRepository.createSpeakersCall(speakersCallLiveData.getValue())).thenReturn(Observable.error(new Throwable(ERROR)));
createSpeakersCallViewModel.getError().observeForever(error);
createSpeakersCallViewModel.createSpeakersCall(EVENT_ID);
InOrder inOrder = Mockito.inOrder(speakersCallRepository, error);
inOrder.verify(speakersCallRepository, never()).createSpeakersCall(any());
inOrder.verify(error).onChanged("Please enter date in correct format");
}
use of com.eventyay.organizer.data.speakerscall.SpeakersCall in project open-event-orga-app by fossasia.
the class SpeakersCallRepositoryTest method shouldSaveCreatedSpeakersCall.
@Test
public void shouldSaveCreatedSpeakersCall() {
SpeakersCall created = mock(SpeakersCall.class);
when(repository.isConnected()).thenReturn(true);
when(speakersCallApi.postSpeakersCall(SPEAKERS_CALL)).thenReturn(Observable.just(created));
when(repository.save(eq(SpeakersCall.class), eq(created))).thenReturn(Completable.complete());
speakersCallRepository.createSpeakersCall(SPEAKERS_CALL).subscribe();
verify(repository).save(SpeakersCall.class, created);
}
use of com.eventyay.organizer.data.speakerscall.SpeakersCall in project open-event-orga-app by fossasia.
the class CreateSpeakersCallViewModelTest method shouldShowErrorOnUpdationFailure.
@Test
public void shouldShowErrorOnUpdationFailure() {
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
SPEAKERS_CALL.setStartsAt(isoDateNow);
SPEAKERS_CALL.setEndsAt(isoDateMax);
createSpeakersCallViewModel.setSpeakersCall(SPEAKERS_CALL);
LiveData<SpeakersCall> speakersCallLiveData = createSpeakersCallViewModel.getSpeakersCall();
when(speakersCallRepository.updateSpeakersCall(speakersCallLiveData.getValue())).thenReturn(Observable.error(new Throwable(ERROR)));
createSpeakersCallViewModel.getError().observeForever(error);
createSpeakersCallViewModel.updateSpeakersCall(EVENT_ID);
InOrder inOrder = Mockito.inOrder(speakersCallRepository, error);
inOrder.verify(speakersCallRepository).updateSpeakersCall(SPEAKERS_CALL);
inOrder.verify(error).onChanged(ERROR);
}
use of com.eventyay.organizer.data.speakerscall.SpeakersCall in project open-event-orga-app by fossasia.
the class CreateSpeakersCallViewModelTest method shouldRejectEndAfterStartDates.
@Test
public void shouldRejectEndAfterStartDates() {
String isoDate = DateUtils.formatDateToIso(LocalDateTime.now());
SPEAKERS_CALL.setStartsAt(isoDate);
SPEAKERS_CALL.setEndsAt(isoDate);
createSpeakersCallViewModel.setSpeakersCall(SPEAKERS_CALL);
LiveData<SpeakersCall> speakersCallLiveData = createSpeakersCallViewModel.getSpeakersCall();
when(speakersCallRepository.createSpeakersCall(speakersCallLiveData.getValue())).thenReturn(Observable.error(new Throwable(ERROR)));
createSpeakersCallViewModel.getError().observeForever(error);
createSpeakersCallViewModel.createSpeakersCall(EVENT_ID);
InOrder inOrder = Mockito.inOrder(speakersCallRepository, error);
inOrder.verify(speakersCallRepository, never()).createSpeakersCall(any());
inOrder.verify(error).onChanged("End time should be after start time");
}
use of com.eventyay.organizer.data.speakerscall.SpeakersCall in project open-event-orga-app by fossasia.
the class CreateSpeakersCallViewModelTest method shouldShowSuccessOnCreated.
@Test
public void shouldShowSuccessOnCreated() {
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
SPEAKERS_CALL.setStartsAt(isoDateNow);
SPEAKERS_CALL.setEndsAt(isoDateMax);
createSpeakersCallViewModel.setSpeakersCall(SPEAKERS_CALL);
LiveData<SpeakersCall> speakersCallLiveData = createSpeakersCallViewModel.getSpeakersCall();
when(speakersCallRepository.createSpeakersCall(speakersCallLiveData.getValue())).thenReturn(Observable.just(SPEAKERS_CALL));
createSpeakersCallViewModel.getSuccess().observeForever(success);
createSpeakersCallViewModel.createSpeakersCall(EVENT_ID);
InOrder inOrder = Mockito.inOrder(speakersCallRepository, success);
inOrder.verify(speakersCallRepository).createSpeakersCall(SPEAKERS_CALL);
inOrder.verify(success).onChanged("Speakers Call Created Successfully");
}
Aggregations