### Question:
Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); }  abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid();  }### Answer:
@Test public void isConnected() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isConnected(Direction.RIGHT)).isTrue(); }
@Test public void isConnectedInverse() { Tileable tileable = grid.get(1, 0).getTileable(); assertThat(tileable.isConnected(Direction.LEFT)).isTrue(); }
@Test public void isNotConnected() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isConnected(Direction.LEFT)).isFalse(); }
@Test public void doesNotAllowConnections() { Tileable tileable = grid.get(1, 1).getTileable(); assertThat(tileable.isConnected(Direction.TOP)).isFalse(); }
@Test public void neighbourDoesNotAllowConnections() { Tileable tileable = grid.get(0, 1).getTileable(); assertThat(tileable.isConnected(Direction.RIGHT)).isFalse(); }
@Test public void unplacedNotConnected() { Track track = new HorizontalTrack(); assertThatThrownBy(() -> track.isConnected(Direction.RIGHT)) .isInstanceOf(IllegalStateException.class); }