VehicleAssignmentResource extends AuthenticatedResource { public List<ActiveBlock> getActiveBlocks(ServiceDate serviceDate, List<AgencyAndId> filterRoutes) throws ExecutionException { return _service.getActiveBlocks(serviceDate, filterRoutes); }  void setVehicleAssignmentService(VehicleAssignmentServiceImpl vehicleAssignmentService); void setActiveVehiclesService(ActiveVehiclesServiceImpl activeVehiclesService); boolean assign(String blockId, String vehicleId); @Path("/assign/block/{block}/vehicle/{vehicle}") @GET Response assignVehicleToBlock(@PathParam("block") String block, @PathParam("vehicle") String vehicle); String getAssignmentByBlockId(String blockId); List<ActiveBlock> getActiveBlocks(ServiceDate serviceDate, List<AgencyAndId> filterRoutes); @Path("/active-blocks/{serviceDate}/{routeList}") @GET Response getActiveBlocksAsCSV(@PathParam("serviceDate") String serviceDate, @PathParam("routeList") String routes); @Path("/get/csv") @GET Response getAssignmentsAsCSV(); @Path("/list") @GET @Produces("application/json") Response getAssignmentsAsJson(); @Path("/active-vehicles/list") @GET @Produces("application/json") Response getActiveVehiclesAsJson(@QueryParam("q") String query); @Path("/trips/block/{blockId}") @GET @Produces("application/json") Response getTripsForBlockAsJson(@PathParam("blockId") String blockId);  }
@Test public void testGetActiveBlocks() throws ExecutionException { VehicleAssignmentResource var = new VehicleAssignmentResource(); VehicleAssignmentServiceImpl vas = new VehicleAssignmentServiceImpl(); TransitDataService tds = new TransitDataServiceImpl() { public ListBean<RouteBean> getRoutesForAgencyId(String agencyId) { ListBean<RouteBean> lb = new ListBean<>(); lb.setList(new ArrayList<RouteBean>()); RouteBean.Builder builder = RouteBean.builder(); builder.setId("1_route1"); AgencyBean agency = new AgencyBean(); agency.setTimezone("America/New_York"); builder.setAgency(agency); RouteBean rb = builder.create(); lb.getList().add(rb); return lb; } public ListBean<TripDetailsBean> getTripsForRoute(TripsForRouteQueryBean query) { ListBean<TripDetailsBean> lb = new ListBean<>(); lb.setList(new ArrayList<TripDetailsBean>()); TripDetailsBean tdb = new TripDetailsBean(); tdb.setTrip(new TripBean()); tdb.getTrip().setBlockId("1"); tdb.getTrip().setServiceId("1_service1"); lb.getList().add(tdb); return lb; } public BlockBean getBlockForId(String blockId) { BlockBean bb = new BlockBean(); bb.setId(blockId); return bb; } public BlockInstanceBean getBlockInstance(String blockId, long serviceDate) { BlockInstanceBean bib = new BlockInstanceBean(); bib.setBlockId(blockId); return bib; } @Override public RouteBean getRouteForId(String routeId) throws ServiceException { RouteBean.Builder builder = RouteBean.builder(); builder.setId("1_route1"); AgencyBean agency = new AgencyBean(); agency.setTimezone("America/New_York"); builder.setAgency(agency); return builder.create(); } @Override public List<BlockInstanceBean> getActiveBlocksForRoute(AgencyAndId route, long timeFrom, long timeTo) { return Collections.EMPTY_LIST; } }; vas.setTransitDataService(tds); var.setVehicleAssignmentService(vas); ServiceDate today = new ServiceDate(); AgencyAndId filterRoute = new AgencyAndId("1", "route1"); ArrayList<AgencyAndId> filterRoutes = new ArrayList<>(); filterRoutes.add(filterRoute); List<ActiveBlock> beans = var.getActiveBlocks(today, filterRoutes); assertNotNull(beans); }