Search in sources :

Example 1 with SpeakersCall

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");
}
Also used : InOrder(org.mockito.InOrder) SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) Test(org.junit.Test)

Example 2 with SpeakersCall

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);
}
Also used : SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) Test(org.junit.Test)

Example 3 with SpeakersCall

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);
}
Also used : InOrder(org.mockito.InOrder) SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) Test(org.junit.Test)

Example 4 with SpeakersCall

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");
}
Also used : InOrder(org.mockito.InOrder) SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) Test(org.junit.Test)

Example 5 with SpeakersCall

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");
}
Also used : InOrder(org.mockito.InOrder) SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) Test(org.junit.Test)

Aggregations

SpeakersCall (com.eventyay.organizer.data.speakerscall.SpeakersCall)9 Test (org.junit.Test)9 InOrder (org.mockito.InOrder)6