@Override public ImmutableList<ImmutableList<Parcel>> solve(GlobalStateObject state) throws InterruptedException { return validateOutputs(delegateSolver.solve(validateInputs(state)), state); } }
@Test public void validateInvalidNumberOfRoutes() { final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), POINT, absent, ImmutableSet.<Parcel>of(), 0, null, null); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList.of(); final GlobalStateObject state = GlobalStateObject.create( ImmutableSet.<Parcel>of(), ImmutableList.of(vs1), 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage()).contains("found 0 routes with 1 vehicles"); fail = true; } assertThat(fail).isTrue(); }
SolverValidator.validateOutputs(schedule, state);
@Test public void validateParcelTooManyTimes1() { final ImmutableSet<Parcel> empty = ImmutableSet.of(); final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, empty, 0, null, null); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList .of(ImmutableList.of(p1, p1, p1)); final ImmutableSet<Parcel> availableParcels = ImmutableSet.of(p1); final ImmutableList<VehicleStateObject> vehicles = ImmutableList.of(vs1); final GlobalStateObject state = GlobalStateObject.create(availableParcels, vehicles, 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage()).contains("found 3 occurence(s) of parcel p1"); fail = true; } assertThat(fail).isTrue(); }
@Test public void validateOutputDestinationNotFirstInRoute() { final ImmutableSet<Parcel> empty = ImmutableSet.of(); final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, empty, 0, p1, null); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList .of(ImmutableList.of(p2, p1, p1, p2)); final ImmutableSet<Parcel> availableParcels = ImmutableSet.of(p1, p2); final ImmutableList<VehicleStateObject> vehicles = ImmutableList.of(vs1); final GlobalStateObject state = GlobalStateObject.create(availableParcels, vehicles, 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage()) .contains("should start with its current destination"); fail = true; } assertThat(fail).isTrue(); }
@Test public void validateParcelTooManyTimes2() { final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, ImmutableSet.of(p1), 0, null, null); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList .of(ImmutableList.of(p1, p1)); final ImmutableSet<Parcel> availableParcels = ImmutableSet.of(); final ImmutableList<VehicleStateObject> vehicles = ImmutableList.of(vs1); final GlobalStateObject state = GlobalStateObject.create(availableParcels, vehicles, 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage()).contains("found 2 occurences of parcel p1"); fail = true; } assertThat(fail).isTrue(); }
@Test public void validateIncompleteRouteForVehicle() { final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, ImmutableSet.of(p1), 0, null, null); final ImmutableList<Parcel> empty = ImmutableList.of(); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList .of(empty); final ImmutableSet<Parcel> availableParcels = ImmutableSet.of(); final ImmutableList<VehicleStateObject> vehicles = ImmutableList.of(vs1); final GlobalStateObject state = GlobalStateObject.create(availableParcels, vehicles, 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage()) .contains("doesn't visit all parcels in its cargo"); fail = true; } assertThat(fail).isTrue(); }
@Test public void validateParcelNotInCargo() { final ImmutableSet<Parcel> empty = ImmutableSet.of(); final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, empty, 0, null, null); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList .of(ImmutableList.of(p1)); final ImmutableSet<Parcel> availableParcels = ImmutableSet.of(); final ImmutableList<VehicleStateObject> vehicles = ImmutableList.of(vs1); final GlobalStateObject state = GlobalStateObject.create(availableParcels, vehicles, 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { fail = true; assertThat(e.getMessage()) .contains("The parcel in this route is not available"); } assertThat(fail).isTrue(); }
@SuppressWarnings("null") @Test public void validateCorrectOutput() { final ImmutableSet<Parcel> empty = ImmutableSet.of(); final VehicleStateObject vs1 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, empty, 0, null, null); final VehicleStateObject vs2 = VehicleStateObject.create(vdto(), new Point(0, 0), absent, ImmutableSet.of(p3), 0, null, null); final ImmutableList<ImmutableList<Parcel>> routes = ImmutableList.of( ImmutableList.of(p1, p1), ImmutableList.of(p2, p3, p2)); final ImmutableSet<Parcel> availableParcels = ImmutableSet.of(p1, p2); final ImmutableList<VehicleStateObject> vehicles = ImmutableList.of(vs1, vs2); final GlobalStateObject state = GlobalStateObject.create(availableParcels, vehicles, 0, SI.SECOND, SI.METERS_PER_SECOND, SI.CENTIMETER, mock(RoadModelSnapshot.class)); SolverValidator.validateOutputs(routes, state); }
boolean fail = false; try { SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage())
SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage())
SolverValidator.validateOutputs(routes, state); } catch (final IllegalArgumentException e) { assertThat(e.getMessage()).contains(