Search in sources :

Example 1 with NetexImportDataIndex

use of org.opentripplanner.netex.loader.NetexImportDataIndex in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method mapRouteWithAgencySpecified.

@Test
public void mapRouteWithAgencySpecified() {
    NetexImportDataIndex netexIndex = new NetexImportDataIndex();
    OtpTransitServiceBuilder transitBuilder = new OtpTransitServiceBuilder();
    Network network = new Network().withId(NETWORK_ID).withTransportOrganisationRef(createJaxbElement(new OrganisationRefStructure().withRef(AUTHORITY_ID)));
    netexIndex.networkById.add(network);
    netexIndex.authoritiesById.add(new Authority().withId(AUTHORITY_ID));
    transitBuilder.getAgenciesById().add(createAgency());
    Line line = createExampleLine();
    RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, transitBuilder.getAgenciesById(), transitBuilder.getOperatorsById(), netexIndex.readOnlyView(), TIME_ZONE);
    Route route = routeMapper.mapRoute(line);
    assertEquals(AUTHORITY_ID, route.getAgency().getId().getId());
}
Also used : OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) Line(org.rutebanken.netex.model.Line) OrganisationRefStructure(org.rutebanken.netex.model.OrganisationRefStructure) NetexImportDataIndex(org.opentripplanner.netex.loader.NetexImportDataIndex) Authority(org.rutebanken.netex.model.Authority) Network(org.rutebanken.netex.model.Network) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Example 2 with NetexImportDataIndex

use of org.opentripplanner.netex.loader.NetexImportDataIndex in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method mapRouteWithDefaultAgency.

@Test
public void mapRouteWithDefaultAgency() {
    NetexImportDataIndex netexImportDataIndex = new NetexImportDataIndex();
    Line line = createExampleLine();
    RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, new EntityById<>(), new EntityById<>(), netexImportDataIndex.readOnlyView(), TimeZone.getDefault().toString());
    Route route = routeMapper.mapRoute(line);
    assertEquals(MappingSupport.ID_FACTORY.createId("RUT:Line:1"), route.getId());
    assertEquals("Line 1", route.getLongName());
    assertEquals("L1", route.getShortName());
}
Also used : Line(org.rutebanken.netex.model.Line) NetexImportDataIndex(org.opentripplanner.netex.loader.NetexImportDataIndex) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Example 3 with NetexImportDataIndex

use of org.opentripplanner.netex.loader.NetexImportDataIndex in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method mapRouteWithColor.

@Test
public void mapRouteWithColor() {
    NetexImportDataIndex netexImportDataIndex = new NetexImportDataIndex();
    Line line = createExampleLine();
    byte[] color = new byte[] { 127, 0, 0 };
    byte[] textColor = new byte[] { 0, 127, 0 };
    line.setPresentation(new PresentationStructure().withColour(color).withTextColour(textColor));
    RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, new EntityById<>(), new EntityById<>(), netexImportDataIndex.readOnlyView(), TimeZone.getDefault().toString());
    Route route = routeMapper.mapRoute(line);
    assertEquals(route.getColor(), "7F0000");
    assertEquals(route.getTextColor(), "007F00");
}
Also used : Line(org.rutebanken.netex.model.Line) PresentationStructure(org.rutebanken.netex.model.PresentationStructure) NetexImportDataIndex(org.opentripplanner.netex.loader.NetexImportDataIndex) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Route (org.opentripplanner.model.Route)3 NetexImportDataIndex (org.opentripplanner.netex.loader.NetexImportDataIndex)3 Line (org.rutebanken.netex.model.Line)3 OtpTransitServiceBuilder (org.opentripplanner.model.impl.OtpTransitServiceBuilder)1 Authority (org.rutebanken.netex.model.Authority)1 Network (org.rutebanken.netex.model.Network)1 OrganisationRefStructure (org.rutebanken.netex.model.OrganisationRefStructure)1 PresentationStructure (org.rutebanken.netex.model.PresentationStructure)1