use of com.eventyay.organizer.data.event.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(TestUtil.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);
}
use of com.eventyay.organizer.data.event.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);
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventsViewModelTest method shouldRefreshEventsSuccessfully.
@Test
public void shouldRefreshEventsSuccessfully() {
when(eventRepository.getEvents(true)).thenReturn(Observable.fromIterable(EVENT_LIST));
InOrder inOrder = Mockito.inOrder(events, eventRepository, progress, success, progress);
eventsViewModel.getProgress().observeForever(progress);
eventsViewModel.getSuccess().observeForever(success);
eventsViewModel.getError().observeForever(error);
events.onChanged(new ArrayList<Event>());
eventsViewModel.loadUserEvents(true);
inOrder.verify(eventRepository).getEvents(true);
inOrder.verify(progress).onChanged(true);
inOrder.verify(success).onChanged(true);
inOrder.verify(progress).onChanged(false);
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventsViewModelTest method shouldShowEventError.
@Test
public void shouldShowEventError() {
String errorString = "Test Error";
when(eventRepository.getEvents(false)).thenReturn(TestUtil.ERROR_OBSERVABLE);
InOrder inOrder = Mockito.inOrder(eventRepository, progress, error);
eventsViewModel.getProgress().observeForever(progress);
eventsViewModel.getError().observeForever(error);
events.onChanged(new ArrayList<Event>());
eventsViewModel.loadUserEvents(false);
inOrder.verify(eventRepository).getEvents(false);
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged(errorString);
inOrder.verify(progress).onChanged(false);
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventsViewModelTest method shouldLoadEventsSuccessfully.
@Test
public void shouldLoadEventsSuccessfully() {
when(eventRepository.getEvents(false)).thenReturn(Observable.fromIterable(EVENT_LIST));
InOrder inOrder = Mockito.inOrder(events, eventRepository, progress, success);
eventsViewModel.getProgress().observeForever(progress);
eventsViewModel.getSuccess().observeForever(success);
eventsViewModel.getError().observeForever(error);
events.onChanged(new ArrayList<Event>());
eventsViewModel.loadUserEvents(false);
inOrder.verify(events).onChanged(new ArrayList<>());
inOrder.verify(eventRepository).getEvents(false);
inOrder.verify(progress).onChanged(true);
inOrder.verify(success).onChanged(true);
inOrder.verify(progress).onChanged(false);
}
Aggregations