From 6ca6f83f0572c6b0af0b5ca3145eec23dcff0223 Mon Sep 17 00:00:00 2001 From: Angelo Cassano Date: Tue, 20 Aug 2024 16:00:49 +0200 Subject: [PATCH 1/3] Issue #366: Add an endpoint to retrieve the stops of a particular agency --- .../api/where/StopsForAgencyAction.java | 63 +++++++++++++++++++ .../StopsForAgencyIdController.java | 38 +++++++++++ .../WEB-INF/jsp/stops-for-agency-id.jsp | 30 +++++++++ .../impl/beans/StopsBeanServiceImpl.java | 14 +++++ .../federated/TransitDataServiceImpl.java | 6 ++ .../TransitDataServiceTemplateImpl.java | 6 ++ .../services/beans/StopsBeanService.java | 9 ++- .../services/TransitDataService.java | 8 ++- src/site/markdown/api/where/index.md | 3 +- .../api/where/methods/stop-ids-for-agency.md | 2 +- .../api/where/methods/stops-for-agency.md | 35 +++++++++++ 11 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/where/StopsForAgencyAction.java create mode 100644 onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java create mode 100644 onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp create mode 100644 src/site/markdown/api/where/methods/stops-for-agency.md diff --git a/onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/where/StopsForAgencyAction.java b/onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/where/StopsForAgencyAction.java new file mode 100644 index 0000000000..67e4f74f57 --- /dev/null +++ b/onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/where/StopsForAgencyAction.java @@ -0,0 +1,63 @@ +/** + * Copyright (C) 2011 Brian Ferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onebusaway.api.actions.api.where; + +import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator; +import org.apache.struts2.rest.DefaultHttpHeaders; +import org.onebusaway.api.actions.api.ApiActionSupport; +import org.onebusaway.api.model.transit.BeanFactoryV2; +import org.onebusaway.transit_data.model.ListBean; +import org.onebusaway.transit_data.model.StopsBean; +import org.onebusaway.transit_data.services.TransitDataService; +import org.springframework.beans.factory.annotation.Autowired; + +public class StopsForAgencyAction extends ApiActionSupport { + + private static final long serialVersionUID = 1L; + + private static final int V2 = 2; + + @Autowired + private TransitDataService _service; + + private String _id; + + public StopsForAgencyAction() { + super(V2); + } + + @RequiredFieldValidator + public void setId(String id) { + _id = id; + } + + public String getId() { + return _id; + } + + public DefaultHttpHeaders show() { + + if (hasErrors()) + return setValidationErrorsResponse(); + + if( ! isVersion(V2)) + return setUnknownVersionResponse(); + + StopsBean stops = _service.getStopsForAgencyId(_id); + BeanFactoryV2 factory = getBeanFactoryV2(); + return setOkResponse(factory.getResponse(stops)); + } +} diff --git a/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java b/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java new file mode 100644 index 0000000000..befac3105f --- /dev/null +++ b/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2011 Brian Ferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onebusaway.transit_data_federation_webapp.controllers; + +import org.onebusaway.transit_data.model.StopsBean; +import org.onebusaway.transit_data_federation.services.beans.StopsBeanService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +@Controller +@RequestMapping("/stops-for-agency-id.action") +public class StopsForAgencyIdController { + + @Autowired + private StopsBeanService _service; + + @RequestMapping() + public ModelAndView index(@RequestParam String agencyId) { + StopsBean stops = _service.getStopsForAgencyId(agencyId); + return new ModelAndView("stops-for-agency-id.jspx", "stops", stops); + } +} diff --git a/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp b/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp new file mode 100644 index 0000000000..6bc9351143 --- /dev/null +++ b/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp @@ -0,0 +1,30 @@ + + + + + + Stops For Agency + + + + ${stop.name} + + + \ No newline at end of file diff --git a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java index 133d484709..e1c9a56cf9 100644 --- a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java +++ b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java @@ -231,6 +231,20 @@ private void sortByDistance(List stopBeans, Map distan Collections.sort(stopBeans, new DistanceAwayComparator()); } + @Override + public StopsBean getStopsForAgencyId(String agencyId) { + AgencyEntry agency = _transitGraphDao.getAgencyForId(agencyId); + if (agency == null) + throw new NoSuchAgencyServiceException(agencyId); + List stopBeans = new ArrayList(); + for (StopEntry stop : agency.getStops()) { + AgencyAndId id = stop.getId(); + StopBean stopBean = _stopBeanService.getStopForId(id, null); + stopBeans.add(stopBean); + } + return constructResult(stopBeans, false); + } + @Override public ListBean getStopsIdsForAgencyId(String agencyId) { AgencyEntry agency = _transitGraphDao.getAgencyForId(agencyId); diff --git a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceImpl.java b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceImpl.java index 58afe4e9c7..2538130898 100644 --- a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceImpl.java +++ b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceImpl.java @@ -180,6 +180,12 @@ public ListBean getStopIdsForAgencyId(String agencyId) { return _transitDataService.getStopIdsForAgencyId(agencyId); } + @Override + public StopsBean getStopsForAgencyId(String agencyId) { + blockUntilBundleIsReady(); + return _transitDataService.getStopsForAgencyId(agencyId); + } + @Override public StopWithArrivalsAndDeparturesBean getStopWithArrivalsAndDepartures( String stopId, ArrivalsAndDeparturesQueryBean query, AgencyServiceInterval serviceInterval) diff --git a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceTemplateImpl.java b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceTemplateImpl.java index bbf4857b24..1ea1edfdac 100644 --- a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceTemplateImpl.java +++ b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/federated/TransitDataServiceTemplateImpl.java @@ -266,6 +266,12 @@ public ListBean getStopIdsForAgencyId(String agencyId) { return _stopsBeanService.getStopsIdsForAgencyId(agencyId); } + //@Override + public StopsBean getStopsForAgencyId(String agencyId) { + + return _stopsBeanService.getStopsForAgencyId(agencyId); + } + //@Override public StopWithArrivalsAndDeparturesBean getStopWithArrivalsAndDepartures( String stopId, ArrivalsAndDeparturesQueryBean query, AgencyServiceInterval serviceInterval) diff --git a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/services/beans/StopsBeanService.java b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/services/beans/StopsBeanService.java index 81ee4322c4..dacf9f55fe 100644 --- a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/services/beans/StopsBeanService.java +++ b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/services/beans/StopsBeanService.java @@ -46,10 +46,17 @@ public interface StopsBeanService { public StopsBean getStops(SearchQueryBean query) throws ServiceException; /** - * + * * @param agencyId see {@link Agency#getId()} * @return the list of all stops for the specified agency */ + public StopsBean getStopsForAgencyId(String agencyId); + + /** + * + * @param agencyId see {@link Agency#getId()} + * @return the list of all stop ids for the specified agency + */ public ListBean getStopsIdsForAgencyId(String agencyId); /** diff --git a/onebusaway-transit-data/src/main/java/org/onebusaway/transit_data/services/TransitDataService.java b/onebusaway-transit-data/src/main/java/org/onebusaway/transit_data/services/TransitDataService.java index 2c22307751..9ad836a064 100644 --- a/onebusaway-transit-data/src/main/java/org/onebusaway/transit_data/services/TransitDataService.java +++ b/onebusaway-transit-data/src/main/java/org/onebusaway/transit_data/services/TransitDataService.java @@ -377,11 +377,17 @@ public StopScheduleBean getScheduleForStop(String stopId, Date date) /** * @param agencyId - * @return the list of all stops operated by the specified agency + * @return the list of all stop ids operated by the specified agency */ @FederatedByAgencyIdMethod public ListBean getStopIdsForAgencyId(String agencyId); + /** + * @param agencyId + * @return the list of all stops operated by the specified agency + */ + public StopsBean getStopsForAgencyId(String agencyId); + /** * * @param shapeId diff --git a/src/site/markdown/api/where/index.md b/src/site/markdown/api/where/index.md index bc0d82e6ad..6b20ded81f 100644 --- a/src/site/markdown/api/where/index.md +++ b/src/site/markdown/api/where/index.md @@ -126,7 +126,8 @@ The current list of supported API methods. * [schedule-for-route](methods/schedule-for-route.html) - get the full schedule for a route on a particular day * [schedule-for-stop](methods/schedule-for-stop.html) - get the full schedule for a stop on a particular day * [shape](methods/shape.html) - get details for a specific shape (polyline drawn on a map) -* [stop-ids-for-agency](methods/stop-ids-for-agency.html) - get a list of all stops for an agency +* [stops-for-agency](methods/stops-for-agency.html) - get a list of all stops for an agency +* [stop-ids-for-agency](methods/stop-ids-for-agency.html) - get a list of all stop ids for an agency * [stop](methods/stop.html) - get details for a specific stop * [stops-for-location](methods/stops-for-location.html) - search for stops near a location, optionally by stop code * [stops-for-route](methods/stops-for-route.html) - get the set of stops and paths of travel for a particular route diff --git a/src/site/markdown/api/where/methods/stop-ids-for-agency.md b/src/site/markdown/api/where/methods/stop-ids-for-agency.md index 3540f5bc4d..7c96f10313 100644 --- a/src/site/markdown/api/where/methods/stop-ids-for-agency.md +++ b/src/site/markdown/api/where/methods/stop-ids-for-agency.md @@ -2,7 +2,7 @@ # Method: stops-ids-for-agency -Retrieve the list of all stops for a particular agency by id +Retrieve the list of all stop ids for a particular agency by id ## Sample Request diff --git a/src/site/markdown/api/where/methods/stops-for-agency.md b/src/site/markdown/api/where/methods/stops-for-agency.md new file mode 100644 index 0000000000..1bbcd14e0a --- /dev/null +++ b/src/site/markdown/api/where/methods/stops-for-agency.md @@ -0,0 +1,35 @@ +[Back to API parent page](../index.html) + +# Method: stops-for-agency + +Retrieve the list of all stops for a particular agency by id + +## Sample Request + +http://api.pugetsound.onebusaway.org/api/where/stops-for-agency/40.xml?key=TEST + +## Sample Response + + + 2 + 200 + OK + 1270614730908 + + + + ... + + + false + + + +## Request Parameters + +* id - the id of the agency, encoded directly in the URL: + * `http://api.pugetsound.onebusaway.org/api/where/stops-for-agency/[ID GOES HERE].xml` + +## Response + +Returns a list of all stops served by the specified agency. \ No newline at end of file From f56ac1a085f9a5b61fd959c9d963eee63fa1de27 Mon Sep 17 00:00:00 2001 From: Angelo Cassano Date: Tue, 27 Aug 2024 16:37:37 +0200 Subject: [PATCH 2/3] Issue #366: Added unit tests for StopsBeanServiceImpl --- .../impl/beans/StopBeanServiceImpl.java | 2 +- .../impl/beans/StopsBeanServiceImpl.java | 10 ++ .../impl/beans/StopBeanServiceImplTest.java | 2 +- .../impl/beans/StopsBeanServiceImplTest.java | 152 ++++++++++++++++++ 4 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java diff --git a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImpl.java b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImpl.java index 32dd24a8a3..803c4ed84e 100644 --- a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImpl.java +++ b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImpl.java @@ -58,7 +58,7 @@ class StopBeanServiceImpl implements StopBeanService { private ConsolidatedStopsService _consolidatedStopsService; @Autowired - public void setTranstiGraphDao(TransitGraphDao transitGraphDao) { + public void setTransitGraphDao(TransitGraphDao transitGraphDao) { _transitGraphDao = transitGraphDao; } diff --git a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java index e1c9a56cf9..43cc44d4ee 100644 --- a/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java +++ b/onebusaway-transit-data-federation/src/main/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImpl.java @@ -70,6 +70,16 @@ class StopsBeanServiceImpl implements StopsBeanService { @Autowired private TransitGraphDao _transitGraphDao; + @Autowired + public void setTransitGraphDao(TransitGraphDao transitGraphDao) { + _transitGraphDao = transitGraphDao; + } + + @Autowired + public void setStopBeanService(StopBeanService stopBeanService) { + _stopBeanService = stopBeanService; + } + @Override public StopsBean getStops(SearchQueryBean queryBean) throws ServiceException { String query = queryBean.getQuery(); diff --git a/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImplTest.java b/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImplTest.java index 1c03038d0d..288d247470 100644 --- a/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImplTest.java +++ b/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopBeanServiceImplTest.java @@ -55,7 +55,7 @@ public void setup() { _service = new StopBeanServiceImpl(); _transitGraphDao = Mockito.mock(TransitGraphDao.class); - _service.setTranstiGraphDao(_transitGraphDao); + _service.setTransitGraphDao(_transitGraphDao); _narrativeService = Mockito.mock(NarrativeService.class); _service.setNarrativeService(_narrativeService); diff --git a/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java b/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java new file mode 100644 index 0000000000..2d5f0d9e55 --- /dev/null +++ b/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java @@ -0,0 +1,152 @@ +/** + * Copyright (C) 2024 Angelo Cassano + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onebusaway.transit_data_federation.impl.beans; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onebusaway.exceptions.NoSuchAgencyServiceException; +import org.onebusaway.gtfs.model.AgencyAndId; +import org.onebusaway.transit_data.model.ListBean; +import org.onebusaway.transit_data.model.StopBean; +import org.onebusaway.transit_data.model.StopsBean; +import org.onebusaway.transit_data_federation.impl.transit_graph.AgencyEntryImpl; +import org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl; +import org.onebusaway.transit_data_federation.services.beans.StopBeanService; +import org.onebusaway.transit_data_federation.services.transit_graph.StopEntry; +import org.onebusaway.transit_data_federation.services.transit_graph.TransitGraphDao; +import org.onebusaway.util.AgencyAndIdLibrary; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +public class StopsBeanServiceImplTest { + private StopsBeanServiceImpl _service; + private StopBeanService _stopBeanService; + private TransitGraphDao _transitGraphDao; + + @Before + public void setup() { + _service = new StopsBeanServiceImpl(); + + _stopBeanService = Mockito.mock(StopBeanService.class); + _service.setStopBeanService(_stopBeanService); + + _transitGraphDao = Mockito.mock(TransitGraphDao.class); + _service.setTransitGraphDao(_transitGraphDao); + } + + @Test + public void testGetStopsIdsForAgencyId() { + List stopEntries = new ArrayList(); + List stopIds = new ArrayList(); + + String agencyId = "1"; + AgencyEntryImpl agency = new AgencyEntryImpl(); + agency.setStops(stopEntries); + + Mockito.when(_transitGraphDao.getAgencyForId(agencyId)).thenReturn(agency); + for (int i = 0; i < 10; i++) { + AgencyAndId id = new AgencyAndId(agencyId, Integer.toString(i)); + StopEntryImpl stopEntry = new StopEntryImpl(id, 10 * (i + 1), -20 * (i + 1)); + stopEntries.add(stopEntry); + stopIds.add(AgencyAndIdLibrary.convertToString(id)); + } + + ListBean stopIdsFromService = _service.getStopsIdsForAgencyId(agencyId); + + assertNotNull(stopIdsFromService); + assertNotNull(stopIdsFromService.getList()); + assertEquals(10, stopIdsFromService.getList().size()); + + for (int i = 0; i < 10; i++) { + assertEquals(stopIds.get(i), stopIdsFromService.getList().get(i)); + } + } + + @Test + public void testGetStopsIdsForAgencyIdThrowsNoSuchAgencyServiceException() { + String agencyId = "1"; + Mockito.when(_transitGraphDao.getAgencyForId(agencyId)).thenReturn(null); + + try { + _service.getStopsIdsForAgencyId(agencyId); + fail("Should throw NoSuchAgencyServiceException"); + } catch (Throwable e) { + assertTrue(e instanceof NoSuchAgencyServiceException); + } + } + + @Test + public void testGetStopsForAgencyId() { + List stopEntries = new ArrayList(); + List stopBeans = new ArrayList(); + + String agencyId = "1"; + AgencyEntryImpl agency = new AgencyEntryImpl(); + agency.setStops(stopEntries); + + Mockito.when(_transitGraphDao.getAgencyForId(agencyId)).thenReturn(agency); + for (int i = 0; i < 10; i++) { + AgencyAndId id = new AgencyAndId(agencyId, Integer.toString(i)); + StopEntryImpl stopEntry = new StopEntryImpl(id, 10 * (i + 1), -20 * (i + 1)); + StopBean stopBean = new StopBean(); + + stopBean.setId(id.getId()); + stopBean.setLat(stopEntry.getStopLat()); + stopBean.setLon(stopEntry.getStopLon()); + + stopEntries.add(stopEntry); + stopBeans.add(stopBean); + + Mockito.when(_transitGraphDao.getStopEntryForId(id)).thenReturn(stopEntry); + Mockito.when(_stopBeanService.getStopForId(id, null)).thenReturn(stopBean); + } + + StopsBean stopsBean = _service.getStopsForAgencyId(agencyId); + + assertNotNull(stopsBean); + assertNotNull(stopsBean.getStops()); + assertEquals(10, stopsBean.getStops().size()); + + for (int i = 0; i < 10; i++) { + StopBean stopBean = stopBeans.get(i); + StopBean stopBeanFromService = stopsBean.getStops().get(i); + + assertNotNull(stopBeanFromService); + assertEquals(stopBean.getId(), stopBeanFromService.getId()); + assertEquals(stopBean.getLat(), stopBeanFromService.getLat(), 0.0); + assertEquals(stopBean.getLon(), stopBeanFromService.getLon(), 0.0); + } + } + + @Test + public void testGetStopsForAgencyIdThrowsNoSuchAgencyServiceException() { + String agencyId = "1"; + Mockito.when(_transitGraphDao.getAgencyForId(agencyId)).thenReturn(null); + + try { + _service.getStopsForAgencyId(agencyId); + fail("Should throw NoSuchAgencyServiceException"); + } catch (Throwable e) { + assertTrue(e instanceof NoSuchAgencyServiceException); + } + } +} + From 32c98781f2f6929a0d5340399870078ec5bb5e88 Mon Sep 17 00:00:00 2001 From: Angelo Cassano Date: Sun, 1 Sep 2024 22:11:50 +0200 Subject: [PATCH 3/3] Issue #366: Fixed licences --- .../StopsForAgencyIdController.java | 2 +- .../WEB-INF/jsp/stops-for-agency-id.jsp | 28 +++++++++---------- .../impl/beans/StopsBeanServiceImplTest.java | 8 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java b/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java index befac3105f..677e6f8913 100644 --- a/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java +++ b/onebusaway-transit-data-federation-webapp/src/main/java/org/onebusaway/transit_data_federation_webapp/controllers/StopsForAgencyIdController.java @@ -33,6 +33,6 @@ public class StopsForAgencyIdController { @RequestMapping() public ModelAndView index(@RequestParam String agencyId) { StopsBean stops = _service.getStopsForAgencyId(agencyId); - return new ModelAndView("stops-for-agency-id.jspx", "stops", stops); + return new ModelAndView("stops-for-agency-id.jsp", "stops", stops); } } diff --git a/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp b/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp index 6bc9351143..2822d8ce8c 100644 --- a/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp +++ b/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/jsp/stops-for-agency-id.jsp @@ -1,21 +1,21 @@ - - +--%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> @@ -27,4 +27,4 @@ limitations under the License. ${stop.name} - \ No newline at end of file + diff --git a/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java b/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java index 2d5f0d9e55..aa908386ad 100644 --- a/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java +++ b/onebusaway-transit-data-federation/src/test/java/org/onebusaway/transit_data_federation/impl/beans/StopsBeanServiceImplTest.java @@ -1,12 +1,12 @@ /** * Copyright (C) 2024 Angelo Cassano - *

+ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.