Search in sources :

Example 16 with Event

use of org.fossasia.openevent.app.data.models.Event in project open-event-orga-app by fossasia.

the class CreateEventPresenterTest method shouldShowErrorOnFailure.

@Test
public void shouldShowErrorOnFailure() {
    Event event = createEventPresenter.getEvent();
    when(eventRepository.createEvent(event)).thenReturn(Observable.error(new Throwable("Error")));
    String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
    String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
    event.getStartsAt().set(isoDateNow);
    event.getEndsAt().set(isoDateMax);
    createEventPresenter.createEvent();
    verify(createEventView).showError("Error");
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 17 with Event

use of org.fossasia.openevent.app.data.models.Event in project open-event-orga-app by fossasia.

the class CreateEventPresenterTest method shouldCloseOnCreated.

@Test
public void shouldCloseOnCreated() {
    Event event = createEventPresenter.getEvent();
    when(eventRepository.createEvent(event)).thenReturn(Observable.just(event));
    String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
    String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
    event.getStartsAt().set(isoDateNow);
    event.getEndsAt().set(isoDateMax);
    createEventPresenter.createEvent();
    verify(createEventView).close();
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 18 with Event

use of org.fossasia.openevent.app.data.models.Event in project open-event-orga-app by fossasia.

the class CreateEventPresenterTest method shouldShowSuccessOnCreated.

@Test
public void shouldShowSuccessOnCreated() {
    Event event = createEventPresenter.getEvent();
    when(eventRepository.createEvent(event)).thenReturn(Observable.just(event));
    String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
    String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
    event.getStartsAt().set(isoDateNow);
    event.getEndsAt().set(isoDateMax);
    createEventPresenter.createEvent();
    verify(createEventView).onSuccess("Event Created Successfully");
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 19 with Event

use of org.fossasia.openevent.app.data.models.Event in project open-event-orga-app by fossasia.

the class CreateEventPresenterTest method shouldInitializeEvent.

@Test
public void shouldInitializeEvent() {
    Event event = createEventPresenter.getEvent();
    assertNotNull(event.getStartsAt());
    assertNotNull(event.getEndsAt());
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) Test(org.junit.Test)

Example 20 with Event

use of org.fossasia.openevent.app.data.models.Event in project open-event-orga-app by fossasia.

the class EventDashboardPresenterTest method shouldNotToggleEventStateOnError.

@Test
public void shouldNotToggleEventStateOnError() {
    when(eventRepository.updateEvent(any(Event.class))).thenReturn(ERROR_OBSERVABLE);
    // Defined locally as a work around for unexpected failureg
    Event event = Event.builder().id(6L).state(Event.STATE_PUBLISHED).build();
    eventDashboardPresenter.setEvent(event);
    eventDashboardPresenter.toggleState();
    assertNotEquals(event.state, Event.STATE_DRAFT);
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) Test(org.junit.Test)

Aggregations

Event (org.fossasia.openevent.app.data.models.Event)24 Test (org.junit.Test)19 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 ObservableString (org.fossasia.openevent.app.data.models.dto.ObservableString)4 InOrder (org.mockito.InOrder)3 Completable (io.reactivex.Completable)2 TestObserver (io.reactivex.observers.TestObserver)2 Place (com.google.android.gms.location.places.Place)1 ArrayList (java.util.ArrayList)1 Logger (org.fossasia.openevent.app.common.rx.Logger)1 DatabaseRepository (org.fossasia.openevent.app.data.db.DatabaseRepository)1 Attendee (org.fossasia.openevent.app.data.models.Attendee)1 Ticket (org.fossasia.openevent.app.data.models.Ticket)1 TicketRepository (org.fossasia.openevent.app.data.repository.TicketRepository)1