use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class FragmentInstanceTest method setUpMockEvent.
private void setUpMockEvent() {
Event event = new Event();
event.timezone = "UTC";
event.endsAt = "2018-12-14T23:59:59.123456+00:00";
ContextManager.setSelectedEvent(event);
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class AuthHolderTest method shouldClearSelectedEventOnLogout.
@Test
public void shouldClearSelectedEventOnLogout() {
ContextManager.setSelectedEvent(new Event());
authHolder.logout();
verify(preferenceModel).setLong(MainActivity.EVENT_KEY, -1);
assertNull(ContextManager.getSelectedEvent());
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventRepositoryTest method shouldSaveEventsInCache.
@Test
public void shouldSaveEventsInCache() {
TestObserver testObserver = TestObserver.create();
Completable completable = Completable.complete().doOnSubscribe(testObserver::onSubscribe);
when(repository.isConnected()).thenReturn(true);
when(authHolder.getIdentity()).thenReturn(344);
when(repository.getAllItems(eq(Event.class))).thenReturn(Observable.empty()).thenReturn(Observable.fromIterable(EVENTS));
when(repository.syncSave(eq(Event.class), eq(EVENTS), any(), any())).thenReturn(completable);
when(eventApi.getEvents(344L)).thenReturn(Observable.just(EVENTS));
// No force reload ensures use of cache
Observable<Event> eventObservable = eventRepository.getEvents(false);
eventObservable.toList().test().assertValue(EVENTS);
// Verify loads from network
verify(eventApi).getEvents(344L);
verify(repository).syncSave(eq(Event.class), eq(EVENTS), any(), any());
testObserver.assertSubscribed();
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventRepositoryTest method shouldLoadEventFromCache.
@Test
public void shouldLoadEventFromCache() {
long id = 45L;
Event event = new Event();
when(repository.getItems(eq(Event.class), refEq(Event_Table.id.eq(id)))).thenReturn(Observable.just(event));
// No force reload ensures use of cache
Observable<Event> eventObservable = eventRepository.getEvent(id, false);
eventObservable.test();
verify(repository).getItems(eq(Event.class), refEq(Event_Table.id.eq(id)));
verifyZeroInteractions(eventApi);
}
use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.
the class EventRepositoryTest method shouldSaveEventInCache.
@Test
public void shouldSaveEventInCache() {
long id = 23L;
Event event = new Event();
TestObserver testObserver = TestObserver.create();
Completable completable = Completable.complete().doOnSubscribe(testObserver::onSubscribe);
when(repository.isConnected()).thenReturn(true);
when(repository.getItems(eq(Event.class), refEq(Event_Table.id.eq(id)))).thenReturn(Observable.empty()).thenReturn(Observable.just(event));
when(repository.save(Event.class, event)).thenReturn(completable);
when(eventApi.getEvent(id)).thenReturn(Observable.just(event));
// No force reload ensures use of cache
Observable<Event> userObservable = eventRepository.getEvent(23, false);
userObservable.test().assertSubscribed().assertValue(event);
testObserver.assertSubscribed();
// Verify loads from network
verify(eventApi).getEvent(id);
verify(repository).save(Event.class, event);
}
Aggregations