Search in sources :

Example 1 with Attendee

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

the class AttendeeCheckInPresenterTest method getCheckedInAttendee.

private Attendee getCheckedInAttendee() {
    Attendee attendee = Attendee.builder().id(ID).build();
    attendee.setCheckedIn(true);
    return attendee;
}
Also used : Attendee(org.fossasia.openevent.app.data.models.Attendee)

Example 2 with Attendee

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

the class AttendeeCheckInPresenterTest method shouldHandleAttendeeChange.

@Test
public void shouldHandleAttendeeChange() {
    attendeeCheckInPresenter.setAttendee(ATTENDEE);
    Attendee toggled = getCheckedInAttendee();
    when(databaseChangeListener.getNotifier()).thenReturn(notifier);
    when(attendeeRepository.getAttendee(ID, false)).thenReturn(Observable.empty()).thenReturn(Observable.just(toggled));
    attendeeCheckInPresenter.start();
    notifier.onNext(new DatabaseChangeListener.ModelChange<>(ATTENDEE, BaseModel.Action.UPDATE));
    verify(attendeeCheckInView).showResult(toggled);
}
Also used : DatabaseChangeListener(org.fossasia.openevent.app.data.db.DatabaseChangeListener) IDatabaseChangeListener(org.fossasia.openevent.app.data.db.IDatabaseChangeListener) Attendee(org.fossasia.openevent.app.data.models.Attendee) Test(org.junit.Test)

Example 3 with Attendee

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

the class AttendeePresenterTest method shouldNotShowScanButtonOnNoItemAfterSwipeRefresh.

@Test
public void shouldNotShowScanButtonOnNoItemAfterSwipeRefresh() {
    ArrayList<Attendee> attendees = new ArrayList<>();
    when(attendeeRepository.getAttendees(ID, true)).thenReturn(Observable.fromIterable(attendees));
    InOrder inOrder = Mockito.inOrder(attendeesView);
    attendeesPresenter.loadAttendees(true);
    inOrder.verify(attendeesView).showScanButton(false);
    inOrder.verify(attendeesView).onRefreshComplete(true);
    inOrder.verify(attendeesView).showScanButton(false);
}
Also used : InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) Attendee(org.fossasia.openevent.app.data.models.Attendee) Test(org.junit.Test)

Example 4 with Attendee

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

the class TicketTest method setUp.

@Override
public void setUp() {
    RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
    Event event = new Event();
    event.setId(Long.valueOf(12));
    Ticket ticket1 = Ticket.builder().id(1L).quantity(120L).type(FREE).event(event).build();
    Ticket ticket2 = Ticket.builder().id(2L).quantity(20L).type(PAID).price(25.99f).event(event).build();
    Ticket ticket3 = Ticket.builder().id(3L).quantity(30L).type(DONATION).event(event).build();
    Ticket ticket4 = Ticket.builder().id(4L).quantity(10L).type(DONATION).event(event).build();
    Ticket ticket5 = Ticket.builder().id(5L).quantity(50L).type(PAID).price(99.99f).event(event).build();
    Attendee attendee = Attendee.builder().id(1L).ticket(ticket1).event(event).build();
    Attendee attendee2 = Attendee.builder().id(2L).ticket(ticket1).event(event).build();
    Attendee attendee3 = Attendee.builder().id(3L).ticket(ticket1).event(event).build();
    Attendee attendee4 = Attendee.builder().id(4L).ticket(ticket2).event(event).build();
    Attendee attendee5 = Attendee.builder().id(5L).ticket(ticket2).event(event).build();
    Attendee attendee6 = Attendee.builder().id(6L).ticket(ticket4).event(event).build();
    Attendee attendee7 = Attendee.builder().id(7L).ticket(ticket5).event(event).build();
    event.setTickets(Arrays.asList(ticket1, ticket2, ticket3, ticket4, ticket5));
    DatabaseRepository databaseRepository = new DatabaseRepository();
    databaseRepository.save(Event.class, event).subscribe();
    databaseRepository.saveList(Attendee.class, Arrays.asList(attendee, attendee2, attendee3, attendee4, attendee5, attendee6, attendee7)).subscribe();
    ticketRepository = new TicketRepository(null, databaseRepository, null);
}
Also used : Ticket(org.fossasia.openevent.app.data.models.Ticket) TicketRepository(org.fossasia.openevent.app.data.repository.TicketRepository) DatabaseRepository(org.fossasia.openevent.app.data.db.DatabaseRepository) Event(org.fossasia.openevent.app.data.models.Event) Attendee(org.fossasia.openevent.app.data.models.Attendee)

Example 5 with Attendee

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

the class AttendeeRepositoryTest method shouldSaveToggledAttendeeCheck.

@Test
public void shouldSaveToggledAttendeeCheck() {
    Attendee attendee = Attendee.builder().id(89).build();
    attendee.setCheckedIn(true);
    TestObserver testObserver = TestObserver.create();
    Completable completable = Completable.complete().doOnSubscribe(testObserver::onSubscribe);
    when(utilModel.isConnected()).thenReturn(true);
    when(databaseRepository.getItems(eq(Attendee.class), any())).thenReturn(Observable.just(attendee));
    when(databaseRepository.update(Attendee.class, attendee)).thenReturn(completable);
    when(eventService.patchAttendee(89, attendee)).thenReturn(Observable.just(attendee));
    Observable<Attendee> attendeeObservable = attendeeRepository.toggleAttendeeCheckStatus(attendee);
    attendeeObservable.test();
    testObserver.assertSubscribed();
}
Also used : Completable(io.reactivex.Completable) Attendee(org.fossasia.openevent.app.data.models.Attendee) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test)

Aggregations

Attendee (org.fossasia.openevent.app.data.models.Attendee)9 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 InOrder (org.mockito.InOrder)2 NonNull (android.support.annotation.NonNull)1 Completable (io.reactivex.Completable)1 TestObserver (io.reactivex.observers.TestObserver)1 Arrays (java.util.Arrays)1 List (java.util.List)1 DatabaseChangeListener (org.fossasia.openevent.app.data.db.DatabaseChangeListener)1 DatabaseRepository (org.fossasia.openevent.app.data.db.DatabaseRepository)1 IDatabaseChangeListener (org.fossasia.openevent.app.data.db.IDatabaseChangeListener)1 Event (org.fossasia.openevent.app.data.models.Event)1 Ticket (org.fossasia.openevent.app.data.models.Ticket)1 TicketRepository (org.fossasia.openevent.app.data.repository.TicketRepository)1 Utils (org.fossasia.openevent.app.utils.Utils)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1