### Question:
OneWayTrack extends Track { @Override public void accept(Direction direction, Marble marble) { if (!accepts(direction, marble)) { throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } informAcceptation(direction, marble); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble);  }### Answer:
@Test public void acceptLeft() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.LEFT; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public void acceptRight() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.RIGHT; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public void acceptTopException() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.TOP; track.addListener(listener); assertThatThrownBy(() -> track.accept(direction, marble)) .isInstanceOf(IllegalArgumentException.class); verify(listener, never()).ballAccepted(track, direction, marble); }
@Test public void acceptBottomException() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.BOTTOM; track.addListener(listener); assertThatThrownBy(() -> track.accept(direction, marble)) .isInstanceOf(IllegalArgumentException.class); verify(listener, never()).ballAccepted(track, direction, marble); }