### Question:
VerticalTrack extends Track { public boolean isConnected() { Tile tile = getTile(); if (tile == null) { throw new IllegalStateException("The track is not placed on a grid"); } Tile left = tile.get(Direction.TOP); Tile right = tile.get(Direction.BOTTOM); return left != null && right != null; }  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 isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); }
@Test public void isNotConnectedBottom() { Grid grid = new Grid(null, 1, 2); grid.place(0, 0, new VerticalTrack()); grid.place(0, 1, track); assertThat(track.isConnected()).isFalse(); }
@Test public void isNotConnectedTop() { Grid grid = new Grid(null, 1, 2); grid.place(0, 0, track); grid.place(0, 1, new HorizontalTrack()); assertThat(track.isConnected()).isFalse(); }
@Test public void unplacedNotConnected() { assertThatThrownBy(() -> track.isConnected()).isInstanceOf(IllegalStateException.class); }
@Test public void isConnected() { Grid grid = new Grid(null, 1, 3); grid.place(0, 0, new VerticalTrack()); grid.place(0, 1, track); grid.place(0, 2, new VerticalTrack()); assertThat(track.isConnected()).isTrue(); }