@Override public MoveProgress followPath(MovingRoadUser object, Queue<Point> path, TimeLapse time) { return delegate().followPath(object, path, time); }
/** * {@inheritDoc} * @throws UnsupportedOperationException when diversion is not allowed. */ @Override public final MoveProgress followPath(MovingRoadUser object, Queue<Point> path, TimeLapse time) { if (allowDiversion) { return delegate().followPath(object, path, time); } else { return unsupported(); } }
/** * {@inheritDoc} * @throws UnsupportedOperationException when diversion is not allowed. */ @Override public final MoveProgress followPath(MovingRoadUser object, Queue<Point> path, TimeLapse time) { if (allowDiversion) { return delegate().followPath(object, path, time); } else { return unsupported(); } }
@Test(expected = IllegalArgumentException.class) public void followPathFailTime() { final TestRoadUser testRoadUser = new TestRoadUser(); model.addObjectAt(testRoadUser, SW); model.followPath(testRoadUser, new LinkedList<Point>(Arrays.asList(SW)), emptyTimeLapse); }
@Test(expected = IllegalArgumentException.class) public void followPathFailPath2() { final TestRoadUser testRoadUser = new TestRoadUser(); model.addObjectAt(testRoadUser, SW); model.followPath(testRoadUser, new LinkedList<Point>(), emptyTimeLapse); }
@Test public void followPathRoundingTimeCheck() { // FIXME fix this rounding time bug! final MovingRoadUser ru = new SpeedyRoadUser(1d); model.addObjectAt(ru, SW); model.followPath(ru, newLinkedList(asList(SE)), TimeLapseFactory.create(0, 36000000 - 1)); }
@Test(expected = NullPointerException.class) public void followPathFailPath1() { final TestRoadUser testRoadUser = new TestRoadUser(); model.addObjectAt(testRoadUser, SW); model.followPath(testRoadUser, null, emptyTimeLapse); }
@Test public void followPathEventIssuerType() { final MovingRoadUser user = new TestRoadUser(); model.addObjectAt(user, SW); final ListenerEventHistory list = new ListenerEventHistory(); model.getEventAPI().addListener(list, RoadEventType.MOVE); assertTrue(list.getHistory().isEmpty()); model.followPath(user, newLinkedList(asList(SW, SE, NE, NW)), TimeLapseFactory.create(0, 10)); assertEquals(1, list.getHistory().size()); assertEquals(RoadEventType.MOVE, list.getHistory().get(0).getEventType()); assertEquals(model, list.getHistory().get(0).getIssuer()); }
@Test public void getDestination() { final TestRoadUser testRoadUser = new TestRoadUser(); model.addObjectAt(testRoadUser, SW); assertNull(model.getDestination(testRoadUser)); assertNull(model.getDestination(new TestRoadUser())); final List<Point> path = model.getShortestPathTo(SW, NW); model.followPath(testRoadUser, newLinkedList(path), TimeLapseFactory.create(0, 1)); assertEquals(NW, model.getDestination(testRoadUser)); model.moveTo(testRoadUser, NE, TimeLapseFactory.create(0, 1)); assertEquals(NE, model.getDestination(testRoadUser)); }
@Test public void containsObjectAt() { assertFalse(model.containsObjectAt(new TestRoadUser(), new Point(2, 3))); final TestRoadUser ru = new TestRoadUser(); model.addObjectAt(ru, SW); assertFalse(model.containsObjectAt(ru, new Point(2, 3))); assertTrue(model.containsObjectAt(ru, SW)); model.followPath(ru, asPath(SE), hour(1)); final Point p = model.getPosition(ru); assertTrue(model.containsObjectAt(ru, PointTestUtil.duplicate(p))); }