target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void disallowsNull() { assertThatThrownBy(() -> track.allowsConnection(null)) .isInstanceOf(NullPointerException.class); } | @Override public boolean allowsConnection(Direction direction) { switch (direction) { case LEFT: case RIGHT: return true; default: return false; } } | HorizontalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case LEFT: case RIGHT: return true; default: return false; } } } | HorizontalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case LEFT: case RIGHT: return true; default: return false; } } } | HorizontalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case LEFT: case RIGHT: return true; default: return false; } } 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); } | HorizontalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case LEFT: case RIGHT: return true; default: return false; } } 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); } |
@Test public void acceptsLeft() { assertThat(track.accepts(Direction.LEFT, marble)).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void acceptsRight() { assertThat(track.accepts(Direction.RIGHT, marble)).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void notAcceptsTop() { assertThat(track.accepts(Direction.TOP, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void notAcceptsBottom() { assertThat(track.accepts(Direction.BOTTOM, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void passesMidpointLeft() { assertThat(track.passesMidpoint(Direction.LEFT, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void passesMidpointRight() { assertThat(track.passesMidpoint(Direction.RIGHT, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void passesMidpointTop() { assertThat(track.passesMidpoint(Direction.TOP, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void passesMidpointBottom() { assertThat(track.passesMidpoint(Direction.BOTTOM, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void getDoubleProperty() throws Exception { when(api.getRealValueOf("a")).thenReturn(1.0); assertThat(config.get(new DoubleProperty("a"))).isEqualTo(1.0); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@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); } | @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } |
@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); } | @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } |
@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); } | @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } |
@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); } | @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } | HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: 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); } |
@Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); } | 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; } | 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; } } | 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; } } | 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); } | 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); } |
@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(); } | 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; } | 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; } } | 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; } } | 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); } | 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); } |
@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(); } | 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; } | 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; } } | 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; } } | 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); } | 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); } |
@Test public void unplacedNotConnected() { assertThatThrownBy(() -> track.isConnected()).isInstanceOf(IllegalStateException.class); } | 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; } | 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; } } | 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; } } | 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); } | 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); } |
@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(); } | 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; } | 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; } } | 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; } } | 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); } | 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); } |
@Test public void allowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } |
@Test public void getDefaultDoubleProperty() throws Exception { when(api.getRealValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new DoubleProperty("a", 1.0))).isEqualTo(1.0); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void allowsBottom() { assertThat(track.allowsConnection(Direction.BOTTOM)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } |
@Test public void disallowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isFalse(); } | @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } |
@Test public void disallowsBottom() { assertThat(track.allowsConnection(Direction.RIGHT)).isFalse(); } | @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } |
@Test public void disallowsNull() { assertThatThrownBy(() -> track.allowsConnection(null)) .isInstanceOf(NullPointerException.class); } | @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } | VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } 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); } |
@Test public void acceptsTop() { assertThat(track.accepts(Direction.TOP, marble)).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void acceptsBottom() { assertThat(track.accepts(Direction.BOTTOM, marble)).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void notAcceptsLeft() { assertThat(track.accepts(Direction.LEFT, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void notAcceptsRight() { assertThat(track.accepts(Direction.RIGHT, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } | VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(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); } |
@Test public void passesMidpointLeft() { assertThat(track.passesMidpoint(Direction.LEFT, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void passesMidpointRight() { assertThat(track.passesMidpoint(Direction.RIGHT, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void getIntegerProperty() throws Exception { when(api.getIntegerValueOf("a")).thenReturn(1); assertThat(config.get(new IntegerProperty("a"))).isEqualTo(1); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void passesMidpointTop() { assertThat(track.passesMidpoint(Direction.TOP, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@Test public void passesMidpointBottom() { assertThat(track.passesMidpoint(Direction.BOTTOM, marble)).isTrue(); } | @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } | VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } 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); } |
@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); } | @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"); } } | 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"); } } } | 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"); } } } | 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); } | 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); } |
@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); } | @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"); } } | 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"); } } } | 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"); } } } | 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); } | 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); } |
@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); } | @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"); } } | 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"); } } } | 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"); } } } | 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); } | 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); } |
@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); } | @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"); } } | 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"); } } } | 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"); } } } | 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); } | 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); } |
@Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); } | @Override public boolean isConnected() { return track.isConnected(); } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void isConnected() { Grid grid = new Grid(null, 3, 1); grid.place(1, 0, track); assertThat(track.isConnected()).isTrue(); } | @Override public boolean isConnected() { return track.isConnected(); } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void allowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void allowsRight() { assertThat(track.allowsConnection(Direction.RIGHT)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void getDefaultIntegerProperty() throws Exception { when(api.getIntegerValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new IntegerProperty("a", 1))).isEqualTo(1); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void disallowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isFalse(); } | @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void disallowsBottom() { assertThat(track.allowsConnection(Direction.BOTTOM)).isFalse(); } | @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void acceptsRight() { assertThat(track.accepts(Direction.RIGHT, new Marble(MarbleType.GREEN))).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void notAcceptsTop() { assertThat(track.accepts(Direction.TOP, new Marble(MarbleType.GREEN))).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void notAcceptsBottom() { assertThat(track.accepts(Direction.BOTTOM, new Marble(MarbleType.GREEN))).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void getTrack() { assertThat(track.getTrack()).isEqualTo(inner); } | public Track getTrack() { return track; } | FilterTrack extends Track implements TileableListener { public Track getTrack() { return track; } } | FilterTrack extends Track implements TileableListener { public Track getTrack() { return track; } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { public Track getTrack() { return track; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { public Track getTrack() { return track; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void getMarbleType() { assertThat(track.getMarbleType()).isEqualTo(type); } | public MarbleType getMarbleType() { return marbleType; } | FilterTrack extends Track implements TileableListener { public MarbleType getMarbleType() { return marbleType; } } | FilterTrack extends Track implements TileableListener { public MarbleType getMarbleType() { return marbleType; } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { public MarbleType getMarbleType() { return marbleType; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { public MarbleType getMarbleType() { return marbleType; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void informDispose() { Tileable tileable = new HorizontalTrack(); Direction direction = Direction.RIGHT; Marble marble = new Marble(MarbleType.BLUE); track.ballDisposed(tileable, direction, marble); } | @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } | FilterTrack extends Track implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } } | FilterTrack extends Track implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } FilterTrack(Track track, MarbleType marbleType); } | FilterTrack extends Track implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } | FilterTrack extends Track implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); @Override void setTile(Tile tile); @Override void ballAccepted(Tileable tileable, Direction direction, Marble marble); @Override void ballDisposed(Tileable tileable, Direction direction, Marble marble); @Override void ballReleased(Tileable tileable, Direction direction, Marble marble); } |
@Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); } | @Override public boolean isConnected() { return track.isConnected(); } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } 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); } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } 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); } |
@Test public void isConnected() { Grid grid = new Grid(null, 3, 1); grid.place(1, 0, track); assertThat(track.isConnected()).isTrue(); } | @Override public boolean isConnected() { return track.isConnected(); } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } 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); } | OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } 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); } |
@Test public void getStringProperty() throws Exception { when(api.getStringValueOf("a")).thenReturn("b"); assertThat(config.get(new StringProperty("a", "c"))).isEqualTo("b"); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void allowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } |
@Test public void allowsRight() { assertThat(track.allowsConnection(Direction.RIGHT)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } |
@Test public void disallowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isFalse(); } | @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } |
@Test public void disallowsBottom() { assertThat(track.allowsConnection(Direction.BOTTOM)).isFalse(); } | @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } | OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } 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); } |
@Test public void acceptsLeft() { assertThat(track.accepts(Direction.LEFT, new Marble(MarbleType.GREEN))).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(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); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(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); } |
@Test public void notAcceptsTop() { assertThat(track.accepts(Direction.TOP, new Marble(MarbleType.GREEN))).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(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); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(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); } |
@Test public void notAcceptsBottom() { assertThat(track.accepts(Direction.BOTTOM, new Marble(MarbleType.GREEN))).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(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); } | OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(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); } |
@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); } | @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 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 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); } | 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); } | 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); } |
@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); } | @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 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 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); } | 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); } | 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); } |
@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); } | @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 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 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); } | 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); } | 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); } |
@Test public void getDefaultStringProperty() throws Exception { when(api.getStringValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new StringProperty("a", "c"))).isEqualTo("c"); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@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); } | @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 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 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); } | 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); } | 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); } |
@Test public void getTrack() { assertThat(track.getTrack()).isEqualTo(inner); } | public Track getTrack() { return this.track; } | OneWayTrack extends Track { public Track getTrack() { return this.track; } } | OneWayTrack extends Track { public Track getTrack() { return this.track; } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { public Track getTrack() { return this.track; } 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); } | OneWayTrack extends Track { public Track getTrack() { return this.track; } 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); } |
@Test public void getDirection() { assertThat(track.getDirection()).isEqualTo(direction); } | public Direction getDirection() { return direction; } | OneWayTrack extends Track { public Direction getDirection() { return direction; } } | OneWayTrack extends Track { public Direction getDirection() { return direction; } OneWayTrack(Track track, Direction direction); } | OneWayTrack extends Track { public Direction getDirection() { return direction; } 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); } | OneWayTrack extends Track { public Direction getDirection() { return direction; } 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); } |
@Test public void createPinkBall() { Marble marble = new Marble(MarbleType.PINK); assertThat(marble.getType()).isEqualTo(MarbleType.PINK); } | public MarbleType getType() { return type; } | Marble implements Entity { public MarbleType getType() { return type; } } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void createBlueBall() { Marble marble = new Marble(MarbleType.BLUE); assertThat(marble.getType()).isEqualTo(MarbleType.BLUE); } | public MarbleType getType() { return type; } | Marble implements Entity { public MarbleType getType() { return type; } } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void createGreenBall() { Marble marble = new Marble(MarbleType.GREEN); assertThat(marble.getType()).isEqualTo(MarbleType.GREEN); } | public MarbleType getType() { return type; } | Marble implements Entity { public MarbleType getType() { return type; } } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void createYellowBall() { Marble marble = new Marble(MarbleType.YELLOW); assertThat(marble.getType()).isEqualTo(MarbleType.YELLOW); } | public MarbleType getType() { return type; } | Marble implements Entity { public MarbleType getType() { return type; } } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void createJoker() { Marble marble = new Marble(MarbleType.JOKER); assertThat(marble.getType()).isEqualTo(MarbleType.JOKER); } | public MarbleType getType() { return type; } | Marble implements Entity { public MarbleType getType() { return type; } } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void createBallNull() { Marble marble = new Marble((MarbleType) null); assertThat(marble.getType()).isEqualTo(null); } | public MarbleType getType() { return type; } | Marble implements Entity { public MarbleType getType() { return type; } } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void isCompatibleSameColour() { Marble greenMarble1 = new Marble(MarbleType.GREEN); Marble greenMarble2 = new Marble(MarbleType.GREEN); assertThat(greenMarble1.isCompatible(greenMarble2)).isTrue(); } | public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void getUnsupportedListProperty() throws Exception { List<Object> list = Lists.newArrayList(new Object()); assertThat(config.get(new ListProperty<>(Object.class, "a", list))).isEqualTo(list); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void isIncompatibleDifferentColour() { Marble green = new Marble(MarbleType.GREEN); Marble blue = new Marble(MarbleType.BLUE); assertThat(green.isCompatible(blue)).isFalse(); } | public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void isCompatibleJokerFirst() { Marble joker = new Marble(MarbleType.JOKER); Marble greenMarble = new Marble(MarbleType.GREEN); assertThat(joker.isCompatible(greenMarble)).isTrue(); } | public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void isCompatibleJokerSecond() { Marble joker = new Marble(MarbleType.JOKER); Marble greenMarble = new Marble(MarbleType.GREEN); assertThat(greenMarble.isCompatible(joker)).isTrue(); } | public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void isCompatibleBothJokers() { Marble joker1 = new Marble(MarbleType.JOKER); Marble joker2 = new Marble(MarbleType.JOKER); assertThat(joker1.isCompatible(joker2)).isTrue(); } | public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void isCompatibleNull() { Marble joker = new Marble(MarbleType.JOKER); assertThat(joker.isCompatible(null)).isFalse(); } | public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } |
@Test public void acceptsLeftFalse() { assertThat(empty.accepts(Direction.LEFT, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return false; } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } |
@Test public void acceptsRightFalse() { assertThat(empty.accepts(Direction.RIGHT, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return false; } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } |
@Test public void acceptsTopFalse() { assertThat(empty.accepts(Direction.TOP, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return false; } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } |
@Test public void acceptsBottomFalse() { assertThat(empty.accepts(Direction.BOTTOM, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return false; } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } | Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } |
@Test public void acceptLeftIllegalArgumentException() { assertThatThrownBy(() -> empty.accept(Direction.LEFT, null)).isInstanceOf(Exception.class); } | @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } | Empty extends Tileable { @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } } | Empty extends Tileable { @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } } | Empty extends Tileable { @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } | Empty extends Tileable { @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } |
@Test public void getBooleanListProperty() throws Exception { List<Boolean> list = Lists.newArrayList(false, true); when(api.getListBoolValueOf("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(Boolean.class, "a", Lists.emptyList()))) .isEqualTo(list); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void spawnFailsOnOccupation() { context.setOccupied(true); assertThatThrownBy(() -> nexus.spawn()).isInstanceOf(IllegalStateException.class); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void spawnInitialSequence() { assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.BLUE); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void peekInitialSequence() { assertThat(context.peek()).isEqualTo(MarbleType.BLUE); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.BLUE); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void spawnJoker() { when(random.nextDouble()).thenReturn(0.4); context.poll(); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.JOKER); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void spawnPink() { when(random.nextInt(anyInt())).thenReturn(0); when(random.nextDouble()).thenReturn(0.6); context.poll(); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.PINK); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void spawnGreen() { when(random.nextDouble()).thenReturn(0.6); when(random.nextInt(anyInt())).thenReturn(1); context.poll(); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.GREEN); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void spawnBlue() { when(random.nextDouble()).thenReturn(0.6); when(random.nextInt(anyInt())).thenReturn(2); context.poll(); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.BLUE); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void spawnYellow() { when(random.nextDouble()).thenReturn(0.6); when(random.nextInt(anyInt())).thenReturn(3); context.poll(); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.YELLOW); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void add() { when(random.nextDouble()).thenReturn(0.0); context.add(MarbleType.JOKER); context.poll(); assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.JOKER); } | public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void getDirection() { assertThat(nexus.getDirection()).isEqualTo(direction); } | public Direction getDirection() { return direction; } | SpawningNexus extends Nexus { public Direction getDirection() { return direction; } } | SpawningNexus extends Nexus { public Direction getDirection() { return direction; } SpawningNexus(NexusContext context, Direction direction); } | SpawningNexus extends Nexus { public Direction getDirection() { return direction; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); } | SpawningNexus extends Nexus { public Direction getDirection() { return direction; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } |
@Test public void getDefaultBooleanListProperty() throws Exception { when(api.getListRealValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new ListProperty<>(Boolean.class,"a", Lists.emptyList()))) .isEqualTo(Lists.emptyList()); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; value = getList(listProperty); } else { value = getValue(key, type); } if (value == null) { return defaultValue; } return property.map((T) value); } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void invalidFile() throws Exception { File file = mock(File.class); when(file.exists()).thenReturn(true); assertThatThrownBy(() -> loader.load(file)).isInstanceOf(FileNotFoundException.class); } | @Override @SuppressWarnings("IllegalCatch") public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } try { return new DefProConfiguration(APIProvider.getAPI(file.getAbsolutePath())); } catch (Exception e) { throw new FileNotFoundException(e.getMessage()); } } | DefProConfigurationLoader implements ConfigurationLoader { @Override @SuppressWarnings("IllegalCatch") public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } try { return new DefProConfiguration(APIProvider.getAPI(file.getAbsolutePath())); } catch (Exception e) { throw new FileNotFoundException(e.getMessage()); } } } | DefProConfigurationLoader implements ConfigurationLoader { @Override @SuppressWarnings("IllegalCatch") public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } try { return new DefProConfiguration(APIProvider.getAPI(file.getAbsolutePath())); } catch (Exception e) { throw new FileNotFoundException(e.getMessage()); } } } | DefProConfigurationLoader implements ConfigurationLoader { @Override @SuppressWarnings("IllegalCatch") public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } try { return new DefProConfiguration(APIProvider.getAPI(file.getAbsolutePath())); } catch (Exception e) { throw new FileNotFoundException(e.getMessage()); } } @Override @SuppressWarnings("IllegalCatch") Configuration load(File file); @Override Configuration load(InputStream input); } | DefProConfigurationLoader implements ConfigurationLoader { @Override @SuppressWarnings("IllegalCatch") public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } try { return new DefProConfiguration(APIProvider.getAPI(file.getAbsolutePath())); } catch (Exception e) { throw new FileNotFoundException(e.getMessage()); } } @Override @SuppressWarnings("IllegalCatch") Configuration load(File file); @Override Configuration load(InputStream input); } |
@Test public void allowsConnectionLeft() { assertThat(nexus.allowsConnection(Direction.LEFT)).isTrue(); } | @Override public boolean allowsConnection(Direction direction) { return !Direction.TOP.equals(direction); } | Nexus extends HorizontalTrack { @Override public boolean allowsConnection(Direction direction) { return !Direction.TOP.equals(direction); } } | Nexus extends HorizontalTrack { @Override public boolean allowsConnection(Direction direction) { return !Direction.TOP.equals(direction); } Nexus(NexusContext context); } | Nexus extends HorizontalTrack { @Override public boolean allowsConnection(Direction direction) { return !Direction.TOP.equals(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } | Nexus extends HorizontalTrack { @Override public boolean allowsConnection(Direction direction) { return !Direction.TOP.equals(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.