@Override public ImmutableSet<ModelBuilder<?, ?>> getModelBuilders() { return ImmutableSet.<ModelBuilder<?, ?>>builder() .add( TimeModel.builder() .withTickLength(1L) .withTimeUnit(NonSI.MINUTE)) .add( RoadModelBuilders.plane() .withMinPoint(getMin()) .withMaxPoint(getMax()) .withDistanceUnit(SI.KILOMETER) .withMaxSpeed(MAX_SPEED) .withSpeedUnit( SI.KILOMETRE.divide(NonSI.MINUTE).asType(Velocity.class))) .add( DefaultPDPModel.builder() .withTimeWindowPolicy(TimeWindowPolicies.TARDY_ALLOWED)) .add( StatsTracker.builder()) .build(); }
.withMinPoint(MIN) .withMaxPoint(MAX) .withDistanceUnit(SI.KILOMETER) .withSpeedUnit(MAX_SPEED.getUnit()) .withMaxSpeed(MAX_SPEED.getValue()))
/** * Tests that units are correctly set. */ @Test public void testAbstractRMBUnits() { final PlaneRoadModel prm = RoadModelBuilders.plane() .withDistanceUnit(NonSI.LIGHT_YEAR) .withSpeedUnit(NonSI.C) .build(mock(DependencyProvider.class)); assertThat(prm.getDistanceUnit()).isEqualTo(NonSI.LIGHT_YEAR); assertThat(prm.getSpeedUnit()).isEqualTo(NonSI.C); }
.withMinPoint(new Point(0, 0)) .withMaxPoint(new Point(10, 10)) .withDistanceUnit(SI.KILOMETER) .withMaxSpeed(0.1) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR))
.addEvent(TimeOutEvent.create(200000)) .addModel(RoadModelBuilders.plane() .withDistanceUnit(SI.CENTIMETER) .withMaxPoint(new Point(7d, 8.4)) .withMinPoint(new Point(-1, 3))
assertThat(plane).isEqualTo(RoadModelBuilders.plane()); assertThat(plane).isNotEqualTo( RoadModelBuilders.plane().withDistanceUnit(SI.CENTIMETER));
.withMinPoint(MIN_POINT) .withMaxPoint(max) .withDistanceUnit(SI.METER) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR) .withMaxSpeed(MAX_SPEED))
.withMinPoint(MIN_POINT) .withMaxPoint(max) .withDistanceUnit(SI.METER) .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR) .withMaxSpeed(MAX_SPEED))
.withMinPoint(new Point(6, 6)) .withMaxPoint(new Point(1034, 32)) .withDistanceUnit(SI.METER) .withSpeedUnit(SI.METERS_PER_SECOND) .withMaxSpeed(1d))
.withDistanceUnit(SI.METER) .withMaxSpeed(Double.POSITIVE_INFINITY) .withSpeedUnit(SI.METERS_PER_SECOND)
@Test public void createPlaneScenarioGeneratorTest() { final ModelBuilder<? extends RoadModel, ? extends RoadUser> roadModelBuilder = RoadModelBuilders .plane() .withSpeedUnit(NonSI.KILOMETERS_PER_HOUR) .withDistanceUnit(SI.METER); final ScenarioGenerator sg = ScenarioGenerator.builder().addModel( roadModelBuilder) .build(); assertEquals(SI.METER, sg.getDistanceUnit()); assertEquals(NonSI.KILOMETERS_PER_HOUR, sg.getSpeedUnit()); } }
/** * Creates a snapshot of a {@link PlaneRoadModel}. * @param minimum The minimum bound of the plane. * @param maximum The maximum bound of the plane. * @param planeDistanceUnit The distance unit of the model. * @return A snapshot with the desired properties. */ public static RoadModelSnapshot createPlaneRoadModelSnapshot( Point minimum, Point maximum, Unit<Length> planeDistanceUnit) { return new AutoValue_PlaneRoadModelSnapshot( new PlaneRoadModel(RoadModelBuilders.plane().withMinPoint(minimum) .withMaxPoint(maximum).withDistanceUnit(planeDistanceUnit))); }
@Override public GenericRoadModel create(ForwardingRoadModelTest testClass) { return new ForwardingRoadModel( RoadModelBuilders.plane() .withMinPoint(new Point(0, 0)) .withMaxPoint(new Point(10, 10)) .withDistanceUnit(SI.METER) .withSpeedUnit(SI.METERS_PER_SECOND) .withMaxSpeed(10d) .build(mock(DependencyProvider.class))); } }}, {new Creator() {