Search in sources :

Example 1 with Event

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

the class CreateEventPresenterTest method shouldNullifyEmptyFields.

@Test
public void shouldNullifyEmptyFields() {
    Event event = createEventPresenter.getEvent();
    when(eventRepository.createEvent(event)).thenReturn(Observable.just(event));
    event.setLogoUrl("");
    event.setTicketUrl("");
    event.setOriginalImageUrl("");
    event.setExternalEventUrl("");
    event.setPaypalEmail("");
    String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
    String isoDateMax = DateUtils.formatDateToIso(LocalDateTime.MAX);
    event.getStartsAt().set(isoDateNow);
    event.getEndsAt().set(isoDateMax);
    createEventPresenter.createEvent();
    assertNull(event.getLogoUrl());
    assertNull(event.getTicketUrl());
    assertNull(event.getOriginalImageUrl());
    assertNull(event.getExternalEventUrl());
    assertNull(event.getPaypalEmail());
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 2 with Event

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

the class CreateEventPresenterTest method shouldRejectWrongFormatDates.

@Test
public void shouldRejectWrongFormatDates() {
    createEventPresenter.createEvent();
    Event event = createEventPresenter.getEvent();
    event.getStartsAt().set("2011/12/03");
    event.getEndsAt().set("2011/03/03");
    createEventPresenter.createEvent();
    verify(createEventView).showError("Please enter date in correct format");
    verify(eventRepository, never()).createEvent(any());
}
Also used : Event(org.fossasia.openevent.app.data.models.Event) Test(org.junit.Test)

Example 3 with Event

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

the class CreateEventPresenterTest method shouldAcceptCorrectEventDates.

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

Example 4 with Event

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

the class EventDashboardPresenterTest method shouldHideProgressbarOnToggleSuccess.

@Test
public void shouldHideProgressbarOnToggleSuccess() {
    when(eventRepository.updateEvent(any(Event.class))).thenReturn(Observable.just(TOGGLED_EVENT));
    eventDashboardPresenter.setEvent(EVENT);
    eventDashboardPresenter.toggleState();
    InOrder inOrder = Mockito.inOrder(eventDetailView, eventRepository);
    inOrder.verify(eventRepository).updateEvent(any(Event.class));
    inOrder.verify(eventDetailView).showProgress(true);
    inOrder.verify(eventDetailView).showResult(any(Event.class));
    inOrder.verify(eventDetailView).showProgress(false);
}
Also used : InOrder(org.mockito.InOrder) Event(org.fossasia.openevent.app.data.models.Event) Test(org.junit.Test)

Example 5 with Event

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

the class DateServiceTest method testClashPast.

@Test
public void testClashPast() {
    Event pastLatest = new Event();
    String min = DateUtils.formatDateToIso(LocalDateTime.MIN);
    String minPlus5 = DateUtils.formatDateToIso(LocalDateTime.MIN.plusDays(5));
    pastLatest.setStartsAt(new ObservableString(min));
    pastLatest.setEndsAt(new ObservableString(minPlus5));
    assertEquals(1, DateService.compareEventDates(PAST, pastLatest));
}
Also used : ObservableString(org.fossasia.openevent.app.data.models.dto.ObservableString) Event(org.fossasia.openevent.app.data.models.Event) ObservableString(org.fossasia.openevent.app.data.models.dto.ObservableString) 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