### Question:
VerticalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case TOP: case BOTTOM: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } }  boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble);  }### Answer:
@Test public void acceptTop() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.TOP; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public void acceptBottom() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.BOTTOM; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public void acceptLeftException() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.LEFT; track.addListener(listener); assertThatThrownBy(() -> track.accept(direction, marble)) .isInstanceOf(IllegalArgumentException.class); verify(listener, never()).ballAccepted(track, direction, marble); }
@Test public void acceptRightException() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.RIGHT; track.addListener(listener); assertThatThrownBy(() -> track.accept(direction, marble)) .isInstanceOf(IllegalArgumentException.class); verify(listener, never()).ballAccepted(track, direction, marble); }