WhereGeospatialServiceImpl service = new WhereGeospatialServiceImpl();
TransitGraphDao dao = Mockito.mock(TransitGraphDao.class);
service.setTransitGraphDao(dao);
StopEntry stopA = stop("a", -0.5, -0.5);
StopEntry stopB = stop("b", -0.5, 0.5);
StopEntry stopC = stop("c", 0.5, -0.5);
StopEntry stopD = stop("d", 0.5, 0.5);
List<StopEntry> allStops = Arrays.asList(stopA, stopB, stopC, stopD);
Mockito.when(dao.getAllStops()).thenReturn(allStops);
service.initialize();
List<AgencyAndId> stops = service.getStopsByBounds(new CoordinateBounds(-1,
-1, 0, 0));
assertEquals(1, stops.size());
assertTrue(stops.contains(stopA.getId()));
stops = service.getStopsByBounds(new CoordinateBounds(0, -1, 1, 0));
assertEquals(1, stops.size());
assertTrue(stops.contains(stopC.getId()));
stops = service.getStopsByBounds(new CoordinateBounds(-1, -1, 1, 0));
assertEquals(2, stops.size());
assertTrue(stops.contains(stopA.getId()));
assertTrue(stops.contains(stopC.getId()));
stops = service.getStopsByBounds(new CoordinateBounds(-1, -1, 1, 1));
assertEquals(4, stops.size());
assertTrue(stops.contains(stopA.getId()));
assertTrue(stops.contains(stopB.getId()));
assertTrue(stops.contains(stopC.getId()));
assertTrue(stops.contains(stopD.getId()));
stops = service.getStopsByBounds(new CoordinateBounds(0.8, 0.8, 1, 1));
assertEquals(0, stops.size());
}