Search in sources :

Example 6 with Attendee

use of com.eventyay.organizer.data.attendee.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 : Attendee(com.eventyay.organizer.data.attendee.Attendee) Arrays(java.util.Arrays) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Assert.assertEquals(org.junit.Assert.assertEquals) Attendee(com.eventyay.organizer.data.attendee.Attendee) Test(org.junit.Test)

Aggregations

Attendee (com.eventyay.organizer.data.attendee.Attendee)6 Test (org.junit.Test)3 SuppressLint (android.annotation.SuppressLint)1 Repository (com.eventyay.organizer.data.Repository)1 DbFlowDatabaseRepository (com.eventyay.organizer.data.db.DbFlowDatabaseRepository)1 Event (com.eventyay.organizer.data.event.Event)1 Ticket (com.eventyay.organizer.data.ticket.Ticket)1 TicketRepositoryImpl (com.eventyay.organizer.data.ticket.TicketRepositoryImpl)1 Completable (io.reactivex.Completable)1 TestObserver (io.reactivex.observers.TestObserver)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 InOrder (org.mockito.InOrder)1