Skip to content

Commit

Permalink
Add test and example
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 29, 2024
1 parent 0124153 commit 30e12f9
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.opentripplanner.updater.siri.updater.light;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.time.Duration;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.updater.spi.HttpHeaders;
import uk.org.siri.siri20.NaturalLanguageStringStructure;

class SiriLightHttpLoaderTest {

private static final Duration ONE_MIN = Duration.ofMinutes(1);

@Test
void test() {
var uri = ResourceLoader.of(this).uri("siri-sx.xml");
var loader = new SiriLightHttpLoader(uri, ONE_MIN, HttpHeaders.empty());
var siri = loader.fetchETFeed("OTP");
var delivery = siri.get().getServiceDelivery().getSituationExchangeDeliveries().getFirst();
var element = delivery.getSituations().getPtSituationElements().getFirst();
assertEquals(
List.of(
"Hindernis auf Strecke",
"Obstacle on the route",
"Ostacolo sul percorso",
"Ostacul su la via"
),
element.getReasonNames().stream().map(NaturalLanguageStringStructure::getValue).toList()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
<?xml version="1.0" encoding="utf-8"?>
<Siri version="2.0" xmlns="http://www.siri.org.uk/siri">
<ServiceDelivery>
<ResponseTimestamp>2024-11-27T11:48:04.308988Z</ResponseTimestamp>
<ProducerRef>DDIP-M</ProducerRef>
<SituationExchangeDelivery xmlns="http://www.siri.org.uk/siri">
<ResponseTimestamp>2024-11-27T11:48:04.308988Z</ResponseTimestamp>
<Situations>
<PtSituationElement>
<CreationTime>2024-10-04T13:11:34.547+02:00</CreationTime>
<ParticipantRef>STA</ParticipantRef>
<SituationNumber>2024-3443167</SituationNumber>
<Version>6</Version>
<Source>
<SourceType>directReport</SourceType>
</Source>
<Progress>published</Progress>
<ValidityPeriod>
<StartTime>2024-10-04T13:08:00+02:00</StartTime>
<EndTime>2024-11-30T13:08:00+01:00</EndTime>
</ValidityPeriod>
<PublicationWindow>
<StartTime>2024-10-04T00:00:00+02:00</StartTime>
<EndTime>2024-11-30T23:59:00+01:00</EndTime>
</PublicationWindow>
<AlertCause>routeBlockage</AlertCause>
<ReasonName xml:lang="de">Hindernis auf Strecke</ReasonName>
<ReasonName xml:lang="en">Obstacle on the route</ReasonName>
<ReasonName xml:lang="it">Ostacolo sul percorso</ReasonName>
<ReasonName xml:lang="lad">Ostacul su la via</ReasonName>
<Priority>3</Priority>
<ScopeType>line</ScopeType>
<Language>de</Language>
<Summary xml:lang="de">Straßen-/Streckenhindernis</Summary>
<Summary xml:lang="en">The busroute: 120 obstacle on the track</Summary>
<Summary xml:lang="it">120 Linea 120 . Ostacolo su strada/pista</Summary>
<Affects>
<Networks>
<AffectedNetwork>
<AffectedLine>
<LineRef>it:apb:Line:80120_.24a</LineRef>
<PublishedLineName>120</PublishedLineName>
<Direction>
<DirectionRef>28554</DirectionRef>
<DirectionName>Salorno, Autostazione</DirectionName>
</Direction>
</AffectedLine>
</AffectedNetwork>
</Networks>
</Affects>
<Consequences>
<Consequence>
<Period>
<StartTime>2024-10-04T13:08:00+02:00</StartTime>
<EndTime>2024-11-30T13:08:00+01:00</EndTime>
</Period>
<Condition>tripCancellation</Condition>
<Severity>normal</Severity>
<Affects>
<Networks>
<AffectedNetwork>
<AffectedLine>
<LineRef>it:apb:Line:80120_.24a</LineRef>
<PublishedLineName>120</PublishedLineName>
<Direction>
<DirectionRef>28554</DirectionRef>
<DirectionName>Salorno, Autostazione</DirectionName>
</Direction>
</AffectedLine>
</AffectedNetwork>
</Networks>
</Affects>
<Blocking/>
</Consequence>
</Consequences>
<PublishingActions>
<PublishingAction>
<PublishAtScope>
<ScopeType>line</ScopeType>
<Affects>
<Networks>
<AffectedNetwork>
<AffectedLine>
<LineRef>it:apb:Line:80120_.24a</LineRef>
<PublishedLineName>120</PublishedLineName>
<Direction>
<DirectionRef>28554</DirectionRef>
<DirectionName>Salorno, Autostazione
</DirectionName>
</Direction>
</AffectedLine>
</AffectedNetwork>
</Networks>
</Affects>
</PublishAtScope>
<PassengerInformationAction>
<ActionStatus>published</ActionStatus>
<ActionRef>2024-3443167</ActionRef>
<RecordedAtTime>2024-10-04T13:11:34.547+02:00</RecordedAtTime>
<Version>6</Version>
<SourceRef>ControlCenter</SourceRef>
<OwnerRef>STA</OwnerRef>
<Perspective>general</Perspective>
<ActionPriority>3</ActionPriority>
<TextualContent>
<TextualContentSize>L</TextualContentSize>
<SummaryContent>
<SummaryText xml:lang="de">Straßen-/Streckenhindernis
</SummaryText>
<SummaryText xml:lang="en">The busroute: 120 obstacle on the
track
</SummaryText>
<SummaryText xml:lang="it">120 Linea 120 . Ostacolo su
strada/pista
</SummaryText>
</SummaryContent>
<ReasonContent>
<ReasonText xml:lang="de">Hindernis auf Strecke</ReasonText>
<ReasonText xml:lang="en">Obstacle on the route</ReasonText>
<ReasonText xml:lang="it">Ostacolo sul percorso</ReasonText>
<ReasonText xml:lang="lad">Ostacul su la via</ReasonText>
</ReasonContent>
<ConsequenceContent>
<ConsequenceText xml:lang="de">Freitext</ConsequenceText>
<ConsequenceText xml:lang="en">Free text</ConsequenceText>
<ConsequenceText xml:lang="it">Testo libero
</ConsequenceText>
</ConsequenceContent>
<RecommendationContent>
<RecommendationText xml:lang="de">Umsteigen auf andere
Linie
</RecommendationText>
<RecommendationText xml:lang="en">Change to another line
</RecommendationText>
<RecommendationText xml:lang="it">Cambiare linea
</RecommendationText>
</RecommendationContent>
<DurationContent>
<DurationText xml:lang="de">Dauer der Beeinträchtigung bis
vsl. 2024-11-30 13:08:00
</DurationText>
</DurationContent>
<RemarkContent/>
</TextualContent>
<TextualContent>
<TextualContentSize>M</TextualContentSize>
<SummaryContent>
<SummaryText xml:lang="de">Straßen-/Streckenhindernis
</SummaryText>
<SummaryText xml:lang="en">The busroute: 120 obstacle on the
track
</SummaryText>
<SummaryText xml:lang="it">120 Linea 120 . Ostacolo su
strada/pista
</SummaryText>
</SummaryContent>
<ReasonContent>
<ReasonText xml:lang="de">Hindernis auf Strecke</ReasonText>
<ReasonText xml:lang="en">Obstacle on the route</ReasonText>
<ReasonText xml:lang="it">Ostacolo sul percorso</ReasonText>
<ReasonText xml:lang="lad">Ostacul su la via</ReasonText>
</ReasonContent>
<ConsequenceContent>
<ConsequenceText xml:lang="de">Freitext</ConsequenceText>
<ConsequenceText xml:lang="en">Free text</ConsequenceText>
<ConsequenceText xml:lang="it">Testo libero
</ConsequenceText>
</ConsequenceContent>
<RecommendationContent>
<RecommendationText xml:lang="de">Umsteigen auf andere
Linie
</RecommendationText>
<RecommendationText xml:lang="en">Change to another line
</RecommendationText>
<RecommendationText xml:lang="it">Cambiare linea
</RecommendationText>
</RecommendationContent>
<DurationContent>
<DurationText xml:lang="de">Dauer der Beeinträchtigung bis
vsl. 2024-11-30 13:08:00
</DurationText>
</DurationContent>
<RemarkContent/>
</TextualContent>
<TextualContent>
<TextualContentSize>S</TextualContentSize>
<SummaryContent>
<SummaryText xml:lang="de">Straßen-/Streckenhindernis
</SummaryText>
<SummaryText xml:lang="en">The busroute: 120 obstacle on the
track
</SummaryText>
<SummaryText xml:lang="it">120 Linea 120 . Ostacolo su
strada/pista
</SummaryText>
</SummaryContent>
<ReasonContent>
<ReasonText xml:lang="de">Hindernis auf Strecke</ReasonText>
<ReasonText xml:lang="en">Obstacle on the route</ReasonText>
<ReasonText xml:lang="it">Ostacolo sul percorso</ReasonText>
<ReasonText xml:lang="lad">Ostacul su la via</ReasonText>
</ReasonContent>
<DescriptionContent>
<DescriptionText xml:lang="de">Aufgrund Stand: 04.10.2024 -
30.11.2024 ; 13:08
</DescriptionText>
<DescriptionText xml:lang="en">Due to Update: 04.10.2024 ;
13:08
</DescriptionText>
<DescriptionText xml:lang="it">A causa di Aggiornamento:
04.10.2024 ; 13:08
</DescriptionText>
</DescriptionContent>
<ConsequenceContent>
<ConsequenceText xml:lang="de">Freitext</ConsequenceText>
<ConsequenceText xml:lang="en">Free text</ConsequenceText>
<ConsequenceText xml:lang="it">Testo libero
</ConsequenceText>
</ConsequenceContent>
<RecommendationContent>
<RecommendationText xml:lang="de">Umsteigen auf andere
Linie
</RecommendationText>
<RecommendationText xml:lang="en">Change to another line
</RecommendationText>
<RecommendationText xml:lang="it">Cambiare linea
</RecommendationText>
</RecommendationContent>
<DurationContent>
<DurationText xml:lang="de">Dauer der Beeinträchtigung bis
vsl. 2024-11-30 13:08:00
</DurationText>
</DurationContent>
<RemarkContent/>
</TextualContent>
</PassengerInformationAction>
</PublishingAction>
</PublishingActions>
</PtSituationElement>
</Situations>
</SituationExchangeDelivery>
</ServiceDelivery>
</Siri>
3 changes: 2 additions & 1 deletion doc/templates/sandbox/siri/SiriUpdater.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ for GTFS-RT TripUpdates.

### SIRI-SX Light

This updater follows the same definition of SIRI light
This updater follows the same definition of SIRI Light as the SIRI-ET one: it downloads the entire
feed in a single HTTP GET request.

<!-- INSERT: siri-sx-light -->

Expand Down
5 changes: 5 additions & 0 deletions doc/user/RouterConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,11 @@ Used to group requests when monitoring OTP.
"feedId" : "sta",
"url" : "https://example.com/siri-lite/estimated-timetable/xml",
"fuzzyTripMatching" : true
},
{
"type" : "siri-sx-light",
"feedId" : "sta",
"url" : "https://example.com/siri-lite/situation-exchange/xml"
}
],
"rideHailingServices" : [
Expand Down
2 changes: 1 addition & 1 deletion doc/user/sandbox/siri/SiriAzureUpdater.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,5 @@ Has to be present for authenticationMethod SharedAccessKey. This should be Prima
- Initial version (April 2022)
- Minor changes in logging (November 2022)
- Retry fetch from history endpoint if it failed (February 2023)
- Solve a bug in SIRIAzureETUpdater and improve error logging (March 2023)
- Solve a bug in SiriAzureETUpdater and improve error logging (March 2023)
- Add support with federated identity authentication (February 2024)
Loading

0 comments on commit 30e12f9

Please sign in to comment.