UserReportingServiceImpl implements UserReportingService { @Override public ListBean<TripProblemReportSummaryBean> getTripProblemReportSummaries( TripProblemReportQueryBean query, ETripProblemGroupBy groupBy) { List<T2<Object, Integer>> records = _userReportingDao.getTripProblemReportSummaries( query, groupBy); List<TripProblemReportSummaryBean> beans = new ArrayList<TripProblemReportSummaryBean>( records.size()); for (T2<Object, Integer> record : records) { TripProblemReportSummaryBean bean = new TripProblemReportSummaryBean(); bean.setCount(record.getSecond()); switch (groupBy) { case TRIP: { AgencyAndId tripId = (AgencyAndId) record.getFirst(); bean.setTrip(_tripBeanService.getTripForId(tripId)); break; } case STATUS: { EProblemReportStatus status = (EProblemReportStatus) record.getFirst(); bean.setStatus(status); break; } case LABEL: { String label = (String) record.getFirst(); bean.setLabel(label); break; } } beans.add(bean); } return new ListBean<TripProblemReportSummaryBean>(beans, false); }  @Autowired void setUserReportingDao(UserReportingDao userReportingDao); @Autowired void setGrah(TransitGraphDao graph); @Autowired void setBlockStatusService(BlockStatusService blockStatusService); @Autowired void setArrivalAndDepartureService(
      ArrivalAndDepartureService arrivalAndDepartureService); @Autowired void setTripBeanService(TripBeanService tripBeanService); @Autowired void setStopBeanService(StopBeanService stopBeanService); @Autowired void setStopTimeBeanService(StopTimeBeanService stopTimeBeanService); @Override void reportProblemWithStop(StopProblemReportBean problem); @Override void reportProblemWithTrip(TripProblemReportBean problem); @Override ListBean<StopProblemReportSummaryBean> getStopProblemReportSummaries(
      StopProblemReportQueryBean query); @Override ListBean<TripProblemReportSummaryBean> getTripProblemReportSummaries(
      TripProblemReportQueryBean query, ETripProblemGroupBy groupBy); ListBean<StopProblemReportBean> getStopProblemReports(
      StopProblemReportQueryBean query); ListBean<TripProblemReportBean> getTripProblemReports(
      TripProblemReportQueryBean query); @Override List<StopProblemReportBean> getAllStopProblemReportsForStopId(
      AgencyAndId stopId); @Override List<TripProblemReportBean> getAllTripProblemReportsForTripId(
      AgencyAndId tripId); @Override StopProblemReportBean getStopProblemReportForId(long id); @Override TripProblemReportBean getTripProblemReportForId(long id); @Override void deleteStopProblemReportForId(long id); @Override void updateTripProblemReport(TripProblemReportBean bean); @Override void deleteTripProblemReportForId(long id); @Override List<String> getAllTripProblemReportLabels();  }
@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()); }