Search in sources :

Example 1 with TripProblemReportQueryBean

use of org.onebusaway.transit_data.model.problems.TripProblemReportQueryBean in project onebusaway-application-modules by camsys.

the class UserReportingDaoImplTest method query.

private TripProblemReportQueryBean query(String agencyId, String tripId, long timeFrom, long timeTo, EProblemReportStatus status, String label) {
    TripProblemReportQueryBean query = new TripProblemReportQueryBean();
    query.setAgencyId(agencyId);
    query.setTripId(tripId);
    query.setTimeFrom(timeFrom);
    query.setTimeTo(timeTo);
    query.setStatus(status);
    query.setLabel(label);
    return query;
}
Also used : TripProblemReportQueryBean(org.onebusaway.transit_data.model.problems.TripProblemReportQueryBean)

Example 2 with TripProblemReportQueryBean

use of org.onebusaway.transit_data.model.problems.TripProblemReportQueryBean in project onebusaway-application-modules by camsys.

the class UserReportingServiceImplTest method test.

@SuppressWarnings("unchecked")
@Test
public void test() {
    TripProblemReportQueryBean query = new TripProblemReportQueryBean();
    AgencyAndId tripIdA = new AgencyAndId("1", "t-a");
    AgencyAndId tripIdB = new AgencyAndId("1", "t-b");
    TripBean tripA = new TripBean();
    TripBean tripB = new TripBean();
    Mockito.when(_dao.getTripProblemReportSummaries(query, ETripProblemGroupBy.TRIP)).thenReturn(Arrays.asList(Tuples.tuple((Object) tripIdA, 7), Tuples.tuple((Object) tripIdB, 3)));
    Mockito.when(_tripBeanService.getTripForId(tripIdA)).thenReturn(tripA);
    Mockito.when(_tripBeanService.getTripForId(tripIdB)).thenReturn(tripB);
    ListBean<TripProblemReportSummaryBean> summaries = _service.getTripProblemReportSummaries(query, ETripProblemGroupBy.TRIP);
    List<TripProblemReportSummaryBean> list = summaries.getList();
    assertEquals(2, list.size());
    TripProblemReportSummaryBean summary = list.get(0);
    assertSame(tripA, summary.getTrip());
    assertEquals(7, summary.getCount());
    summary = list.get(1);
    assertSame(tripB, summary.getTrip());
    assertEquals(3, summary.getCount());
    Mockito.when(_dao.getTripProblemReportSummaries(query, ETripProblemGroupBy.STATUS)).thenReturn(Arrays.asList(Tuples.tuple((Object) EProblemReportStatus.NEW, 6), Tuples.tuple((Object) EProblemReportStatus.DUPLICATE, 4)));
    summaries = _service.getTripProblemReportSummaries(query, ETripProblemGroupBy.STATUS);
    list = summaries.getList();
    assertEquals(2, list.size());
    summary = list.get(0);
    assertEquals(EProblemReportStatus.NEW, summary.getStatus());
    assertEquals(6, summary.getCount());
    summary = list.get(1);
    assertEquals(EProblemReportStatus.DUPLICATE, summary.getStatus());
    assertEquals(4, summary.getCount());
    Mockito.when(_dao.getTripProblemReportSummaries(query, ETripProblemGroupBy.LABEL)).thenReturn(Arrays.asList(Tuples.tuple((Object) "label-a", 9), Tuples.tuple((Object) "label-b", 2)));
    summaries = _service.getTripProblemReportSummaries(query, ETripProblemGroupBy.LABEL);
    list = summaries.getList();
    assertEquals(2, list.size());
    summary = list.get(0);
    assertEquals("label-a", summary.getLabel());
    assertEquals(9, summary.getCount());
    summary = list.get(1);
    assertEquals("label-b", summary.getLabel());
    assertEquals(2, summary.getCount());
}
Also used : TripProblemReportQueryBean(org.onebusaway.transit_data.model.problems.TripProblemReportQueryBean) TripProblemReportSummaryBean(org.onebusaway.transit_data.model.problems.TripProblemReportSummaryBean) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TripBean(org.onebusaway.transit_data.model.trips.TripBean) Test(org.junit.Test)

Aggregations

TripProblemReportQueryBean (org.onebusaway.transit_data.model.problems.TripProblemReportQueryBean)2 Test (org.junit.Test)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 TripProblemReportSummaryBean (org.onebusaway.transit_data.model.problems.TripProblemReportSummaryBean)1 TripBean (org.onebusaway.transit_data.model.trips.TripBean)1