Search in sources :

Example 6 with Attendee

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

the class AttendeeCheckInJob method onRunJob.

@NonNull
@Override
// No information on possible exceptions available
@SuppressWarnings("PMD.AvoidCatchingGenericException")
protected Result onRunJob(Params params) {
    DaggerAppComponent.create().inject(this);
    Timber.d("Running batch job : %s", TAG);
    Iterable<Attendee> attendees = attendeeRepository.getPendingCheckIns().blockingIterable();
    for (Attendee attendee : attendees) {
        Timber.d("Trying to toggle attendee status -> %s", attendee);
        try {
            Attendee toggled = attendeeRepository.toggleAttendeeCheckStatus(attendee).blockingFirst();
            Timber.d("Attendee check in job succeeded for attendee: %s", toggled);
        } catch (Exception exception) {
            Timber.e("Attendee Check In Job Failed for attendee status -> %ss\n" + "With error: %s\n" + "The job is rescheduled", attendee, exception.getMessage());
            return Result.RESCHEDULE;
        }
    }
    return Result.SUCCESS;
}
Also used : Attendee(org.fossasia.openevent.app.data.models.Attendee) NonNull(android.support.annotation.NonNull)

Example 7 with Attendee

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

the class StickyHeaderAdapter method onBindHeaderViewHolder.

@Override
public void onBindHeaderViewHolder(HeaderViewHolder viewHolder, int position) {
    if (sortByName) {
        Attendee attendee = (Attendee) getFastAdapter().getItem(position);
        viewHolder.bindHeader(attendee.getTicket().getType());
    } else
        viewHolder.bindHeader(getFastAdapter().getItem(position).getHeader());
}
Also used : Attendee(org.fossasia.openevent.app.data.models.Attendee)

Example 8 with Attendee

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

the class AttendeePresenterTest method shouldShowEmptyViewOnNoItemAfterSwipeRefresh.

@Test
public void shouldShowEmptyViewOnNoItemAfterSwipeRefresh() {
    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).showEmptyView(false);
    inOrder.verify(attendeesView).showResults(attendees);
    inOrder.verify(attendeesView).showEmptyView(true);
}
Also used : InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) Attendee(org.fossasia.openevent.app.data.models.Attendee) Test(org.junit.Test)

Example 9 with Attendee

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

the class UtilsTest method shouldFindIndex.

@Test
public void shouldFindIndex() {
    List<Attendee> attendees = Arrays.asList(Attendee.builder().id(12).build(), Attendee.builder().id(34).build(), Attendee.builder().id(10).build(), Attendee.builder().id(90).build(), Attendee.builder().id(3).build());
    Attendee newAttendee = Attendee.builder().id(10).build();
    Utils.PropertyMatcher<Attendee> idEqual = (first, second) -> first.getId() == second.getId();
    Utils.indexOf(attendees, newAttendee, idEqual).test().assertNoErrors().assertValue(2);
    newAttendee.setId(12);
    Utils.indexOf(attendees, newAttendee, idEqual).test().assertNoErrors().assertValue(0);
    newAttendee.setId(3);
    Utils.indexOf(attendees, newAttendee, idEqual).test().assertNoErrors().assertValue(4);
    newAttendee.setId(2);
    Utils.indexOf(attendees, newAttendee, idEqual).test().assertNoErrors().assertValue(-1);
}
Also used : Utils(org.fossasia.openevent.app.utils.Utils) Arrays(java.util.Arrays) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Attendee(org.fossasia.openevent.app.data.models.Attendee) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Assert.assertEquals(org.junit.Assert.assertEquals) Utils(org.fossasia.openevent.app.utils.Utils) Attendee(org.fossasia.openevent.app.data.models.Attendee) 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