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 allowsConnectionRight() { assertThat(nexus.allowsConnection(Direction.RIGHT)).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(); } |
@Test public void allowsConnectionBottom() { assertThat(nexus.allowsConnection(Direction.BOTTOM)).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(); } |
@Test public void disallowsConnectionTop() { assertThat(nexus.allowsConnection(Direction.TOP)).isFalse(); } | @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(); } |
@Test public void acceptsLeft() { assertThat(nexus.accepts(Direction.LEFT, marble)).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } |
@Test public void acceptsRight() { assertThat(nexus.accepts(Direction.RIGHT, marble)).isTrue(); } | @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } |
@Test public void notAcceptsTop() { assertThat(nexus.accepts(Direction.TOP, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } |
@Test public void notAcceptsBottom() { assertThat(nexus.accepts(Direction.BOTTOM, marble)).isFalse(); } | @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } | Nexus extends HorizontalTrack { @Override public boolean accepts(Direction direction, Marble marble) { return super.allowsConnection(direction); } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } |
@Test public void getContext() { assertThat(nexus.getContext()).isEqualTo(context); } | public NexusContext getContext() { return context; } | Nexus extends HorizontalTrack { public NexusContext getContext() { return context; } } | Nexus extends HorizontalTrack { public NexusContext getContext() { return context; } Nexus(NexusContext context); } | Nexus extends HorizontalTrack { public NexusContext getContext() { return context; } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } | Nexus extends HorizontalTrack { public NexusContext getContext() { return context; } Nexus(NexusContext context); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); NexusContext getContext(); } |
@Test public void testWonFalse() { assertThat(progress.isWon()).isFalse(); } | public boolean isWon() { return unmarked.isEmpty(); } | Progress implements ReceptorListener { public boolean isWon() { return unmarked.isEmpty(); } } | Progress implements ReceptorListener { public boolean isWon() { return unmarked.isEmpty(); } } | Progress implements ReceptorListener { public boolean isWon() { return unmarked.isEmpty(); } boolean isWon(); int getScore(); void setScore(int score); void score(int points); void track(Grid grid); @Override void receptorMarked(Receptor receptor); } | Progress implements ReceptorListener { public boolean isWon() { return unmarked.isEmpty(); } boolean isWon(); int getScore(); void setScore(int score); void score(int points); void track(Grid grid); @Override void receptorMarked(Receptor receptor); } |
@Test public void getDoubleListProperty() throws Exception { List<Double> list = Lists.newArrayList(1.0, 2.0); when(api.getListRealValueOf("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(Double.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 getIndex() { assertThat(level.getIndex()).isEqualTo(2); } | @Override public int getIndex() { return 2; } | HardLevelTwo extends AbstractHardLevel { @Override public int getIndex() { return 2; } } | HardLevelTwo extends AbstractHardLevel { @Override public int getIndex() { return 2; } } | HardLevelTwo extends AbstractHardLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } | HardLevelTwo extends AbstractHardLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); } | @Override public int getIndex() { return 1; } | HardLevelOne extends AbstractHardLevel { @Override public int getIndex() { return 1; } } | HardLevelOne extends AbstractHardLevel { @Override public int getIndex() { return 1; } } | HardLevelOne extends AbstractHardLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } | HardLevelOne extends AbstractHardLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void createLevelOne() { assertThat(factory.create(1)).isInstanceOf(HardLevelOne.class); } | public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } AbstractHardLevel create(int level); } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } AbstractHardLevel create(int level); } |
@Test public void createLevelTwo() { assertThat(factory.create(2)).isInstanceOf(HardLevelTwo.class); } | public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } AbstractHardLevel create(int level); } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } AbstractHardLevel create(int level); } |
@Test public void createLevelThree() { assertThat(factory.create(3)).isInstanceOf(HardLevelThree.class); } | public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } AbstractHardLevel create(int level); } | HardLevelFactory extends LevelFactory { public AbstractHardLevel create(int level) { switch (level) { case 1: return new HardLevelOne(); case 2: return new HardLevelTwo(); case 3: return new HardLevelThree(); default: return null; } } AbstractHardLevel create(int level); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); } | @Override public int getIndex() { return 3; } | HardLevelThree extends AbstractHardLevel { @Override public int getIndex() { return 3; } } | HardLevelThree extends AbstractHardLevel { @Override public int getIndex() { return 3; } } | HardLevelThree extends AbstractHardLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } | HardLevelThree extends AbstractHardLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(2); } | @Override public int getIndex() { return 2; } | EasyLevelTwo extends AbstractEasyLevel { @Override public int getIndex() { return 2; } } | EasyLevelTwo extends AbstractEasyLevel { @Override public int getIndex() { return 2; } } | EasyLevelTwo extends AbstractEasyLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } | EasyLevelTwo extends AbstractEasyLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); } | @Override public int getIndex() { return 1; } | EasyLevelOne extends AbstractEasyLevel { @Override public int getIndex() { return 1; } } | EasyLevelOne extends AbstractEasyLevel { @Override public int getIndex() { return 1; } } | EasyLevelOne extends AbstractEasyLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } | EasyLevelOne extends AbstractEasyLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void createLevelOne() { assertThat(factory.create(1)).isInstanceOf(EasyLevelOne.class); } | public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } AbstractEasyLevel create(int level); } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } AbstractEasyLevel create(int level); } |
@Test public void createLevelTwo() { assertThat(factory.create(2)).isInstanceOf(EasyLevelTwo.class); } | public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } AbstractEasyLevel create(int level); } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } AbstractEasyLevel create(int level); } |
@Test public void getDefaultDoubleListProperty() throws Exception { when(api.getListRealValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new ListProperty<>(Double.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 createLevelThree() { assertThat(factory.create(3)).isInstanceOf(EasyLevelThree.class); } | public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } AbstractEasyLevel create(int level); } | EasyLevelFactory extends LevelFactory { public AbstractEasyLevel create(int level) { switch (level) { case 1: return new EasyLevelOne(); case 2: return new EasyLevelTwo(); case 3: return new EasyLevelThree(); default: return null; } } AbstractEasyLevel create(int level); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); } | @Override public int getIndex() { return 3; } | EasyLevelThree extends AbstractEasyLevel { @Override public int getIndex() { return 3; } } | EasyLevelThree extends AbstractEasyLevel { @Override public int getIndex() { return 3; } } | EasyLevelThree extends AbstractEasyLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } | EasyLevelThree extends AbstractEasyLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void getFirst() { assertThat(factory.create(1)).isNotNull(); } | public abstract Level create(int level); | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } |
@Test public void getSecond() { assertThat(factory.create(2)).isNotNull(); } | public abstract Level create(int level); | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } |
@Test public void getThird() { assertThat(factory.create(3)).isNotNull(); } | public abstract Level create(int level); | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } |
@Test public void getFourth() { assertThat(factory.create(4)).isNull(); } | public abstract Level create(int level); | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } | LevelFactory { public abstract Level create(int level); abstract Level create(int level); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); } | @Override public int getIndex() { return 3; } | MediumLevelThree extends AbstractMediumLevel { @Override public int getIndex() { return 3; } } | MediumLevelThree extends AbstractMediumLevel { @Override public int getIndex() { return 3; } } | MediumLevelThree extends AbstractMediumLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } | MediumLevelThree extends AbstractMediumLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); } | @Override public int getIndex() { return 1; } | MediumLevelOne extends AbstractMediumLevel { @Override public int getIndex() { return 1; } } | MediumLevelOne extends AbstractMediumLevel { @Override public int getIndex() { return 1; } } | MediumLevelOne extends AbstractMediumLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } | MediumLevelOne extends AbstractMediumLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void createLevelOne() { assertThat(factory.create(1)).isInstanceOf(MediumLevelOne.class); } | public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } AbstractMediumLevel create(int level); } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } AbstractMediumLevel create(int level); } |
@Test public void createLevelTwo() { assertThat(factory.create(2)).isInstanceOf(MediumLevelTwo.class); } | public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } AbstractMediumLevel create(int level); } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } AbstractMediumLevel create(int level); } |
@Test public void getIntegerListProperty() throws Exception { List<Integer> list = Lists.newArrayList(1, 2); when(api.getListIntValueOf("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(Integer.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 createLevelThree() { assertThat(factory.create(3)).isInstanceOf(MediumLevelThree.class); } | public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } AbstractMediumLevel create(int level); } | MediumLevelFactory extends LevelFactory { public AbstractMediumLevel create(int level) { switch (level) { case 1: return new MediumLevelOne(); case 2: return new MediumLevelTwo(); case 3: return new MediumLevelThree(); default: return null; } } AbstractMediumLevel create(int level); } |
@Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(2); } | @Override public int getIndex() { return 2; } | MediumLevelTwo extends AbstractMediumLevel { @Override public int getIndex() { return 2; } } | MediumLevelTwo extends AbstractMediumLevel { @Override public int getIndex() { return 2; } } | MediumLevelTwo extends AbstractMediumLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } | MediumLevelTwo extends AbstractMediumLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } |
@Test public void isOccupied() { assertThat(grid.get(0,0).isOccupied()).isTrue(); } | public boolean isOccupied() { return !(tileable instanceof Empty); } | Tile implements Entity { public boolean isOccupied() { return !(tileable instanceof Empty); } } | Tile implements Entity { public boolean isOccupied() { return !(tileable instanceof Empty); } Tile(); } | Tile implements Entity { public boolean isOccupied() { return !(tileable instanceof Empty); } Tile(); Tileable getTileable(); boolean isOccupied(); Tile get(Direction direction); abstract int getX(); abstract int getY(); abstract Grid getGrid(); } | Tile implements Entity { public boolean isOccupied() { return !(tileable instanceof Empty); } Tile(); Tileable getTileable(); boolean isOccupied(); Tile get(Direction direction); abstract int getX(); abstract int getY(); abstract Grid getGrid(); } |
@Test public void getDirectionNull() { assertThatThrownBy(() -> grid.get(1,0).get(null)) .isInstanceOf(IllegalArgumentException.class); } | public Tile get(Direction direction) { Grid grid = getGrid(); int x = getX(); int y = getY(); if (direction == null) { throw new IllegalArgumentException(); } Tile result = null; switch (direction) { case TOP: result = grid.get(x, y + 1); break; case RIGHT: result = grid.get(x + 1, y); break; case BOTTOM: result = grid.get(x, y - 1); break; case LEFT: result = grid.get(x - 1, y); break; default: } return result; } | Tile implements Entity { public Tile get(Direction direction) { Grid grid = getGrid(); int x = getX(); int y = getY(); if (direction == null) { throw new IllegalArgumentException(); } Tile result = null; switch (direction) { case TOP: result = grid.get(x, y + 1); break; case RIGHT: result = grid.get(x + 1, y); break; case BOTTOM: result = grid.get(x, y - 1); break; case LEFT: result = grid.get(x - 1, y); break; default: } return result; } } | Tile implements Entity { public Tile get(Direction direction) { Grid grid = getGrid(); int x = getX(); int y = getY(); if (direction == null) { throw new IllegalArgumentException(); } Tile result = null; switch (direction) { case TOP: result = grid.get(x, y + 1); break; case RIGHT: result = grid.get(x + 1, y); break; case BOTTOM: result = grid.get(x, y - 1); break; case LEFT: result = grid.get(x - 1, y); break; default: } return result; } Tile(); } | Tile implements Entity { public Tile get(Direction direction) { Grid grid = getGrid(); int x = getX(); int y = getY(); if (direction == null) { throw new IllegalArgumentException(); } Tile result = null; switch (direction) { case TOP: result = grid.get(x, y + 1); break; case RIGHT: result = grid.get(x + 1, y); break; case BOTTOM: result = grid.get(x, y - 1); break; case LEFT: result = grid.get(x - 1, y); break; default: } return result; } Tile(); Tileable getTileable(); boolean isOccupied(); Tile get(Direction direction); abstract int getX(); abstract int getY(); abstract Grid getGrid(); } | Tile implements Entity { public Tile get(Direction direction) { Grid grid = getGrid(); int x = getX(); int y = getY(); if (direction == null) { throw new IllegalArgumentException(); } Tile result = null; switch (direction) { case TOP: result = grid.get(x, y + 1); break; case RIGHT: result = grid.get(x + 1, y); break; case BOTTOM: result = grid.get(x, y - 1); break; case LEFT: result = grid.get(x - 1, y); break; default: } return result; } Tile(); Tileable getTileable(); boolean isOccupied(); Tile get(Direction direction); abstract int getX(); abstract int getY(); abstract Grid getGrid(); } |
@Test public void getGridTest() { assertThat(grid.get(0,0).getGrid()).isEqualTo(grid); } | public abstract Grid getGrid(); | Tile implements Entity { public abstract Grid getGrid(); } | Tile implements Entity { public abstract Grid getGrid(); Tile(); } | Tile implements Entity { public abstract Grid getGrid(); Tile(); Tileable getTileable(); boolean isOccupied(); Tile get(Direction direction); abstract int getX(); abstract int getY(); abstract Grid getGrid(); } | Tile implements Entity { public abstract Grid getGrid(); Tile(); Tileable getTileable(); boolean isOccupied(); Tile get(Direction direction); abstract int getX(); abstract int getY(); abstract Grid getGrid(); } |
@Test public void onGridInPointsTest() { Grid grid = new Grid(session, 3, 2); for (int x = 0; x < 3; x++) { for (int y = 0; y < 2; y++) { assertThat(grid.onGrid(x,y)).isTrue(); } } } | public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } Grid(GameSession session, int width, int height); } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } |
@Test public void onGridOutPointsTest() { Grid grid = new Grid(session, 3, 2); int x = -1; int y = -1; while (y < 2) { while (x < 4) { assertThat(grid.onGrid(x, y)).isFalse(); x++; } x = -1; y += 3; } x = -1; y = -1; while (x < 4) { while (y < 3) { assertThat(grid.onGrid(x, y)).isFalse(); y++; } y = -1; x += 4; } } | public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } Grid(GameSession session, int width, int height); } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } | Grid implements Entity { public boolean onGrid(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } |
@Test public void placeInvalid() { Grid grid = new Grid(session, 3, 1); assertThatThrownBy(() -> grid.place(-1, -1, null)) .isInstanceOf(IllegalArgumentException.class); } | public void place(int x, int y, Tileable tileable) { if (!onGrid(x, y)) { throw new IllegalArgumentException("The given coordinates do not exist on this grid"); } Tile tile = tiles[y][x]; tile.tileable = tileable; tileable.setTile(tile); } | Grid implements Entity { public void place(int x, int y, Tileable tileable) { if (!onGrid(x, y)) { throw new IllegalArgumentException("The given coordinates do not exist on this grid"); } Tile tile = tiles[y][x]; tile.tileable = tileable; tileable.setTile(tile); } } | Grid implements Entity { public void place(int x, int y, Tileable tileable) { if (!onGrid(x, y)) { throw new IllegalArgumentException("The given coordinates do not exist on this grid"); } Tile tile = tiles[y][x]; tile.tileable = tileable; tileable.setTile(tile); } Grid(GameSession session, int width, int height); } | Grid implements Entity { public void place(int x, int y, Tileable tileable) { if (!onGrid(x, y)) { throw new IllegalArgumentException("The given coordinates do not exist on this grid"); } Tile tile = tiles[y][x]; tile.tileable = tileable; tileable.setTile(tile); } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } | Grid implements Entity { public void place(int x, int y, Tileable tileable) { if (!onGrid(x, y)) { throw new IllegalArgumentException("The given coordinates do not exist on this grid"); } Tile tile = tiles[y][x]; tile.tileable = tileable; tileable.setTile(tile); } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } |
@Test public void getSession() { Grid grid = new Grid(session, 1, 1); assertThat(grid.getSession()).isEqualTo(session); } | public GameSession getSession() { return session; } | Grid implements Entity { public GameSession getSession() { return session; } } | Grid implements Entity { public GameSession getSession() { return session; } Grid(GameSession session, int width, int height); } | Grid implements Entity { public GameSession getSession() { return session; } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } | Grid implements Entity { public GameSession getSession() { return session; } Grid(GameSession session, int width, int height); int getWidth(); int getHeight(); GameSession getSession(); void place(int x, int y, Tileable tileable); Tile get(int x, int y); boolean onGrid(int x, int y); } |
@Test public void isConnected() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isConnected(Direction.RIGHT)).isTrue(); } | public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void getDefaultIntegerListProperty() throws Exception { when(api.getListIntValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new ListProperty<>(Integer.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 isConnectedInverse() { Tileable tileable = grid.get(1, 0).getTileable(); assertThat(tileable.isConnected(Direction.LEFT)).isTrue(); } | public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void isNotConnected() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isConnected(Direction.LEFT)).isFalse(); } | public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void doesNotAllowConnections() { Tileable tileable = grid.get(1, 1).getTileable(); assertThat(tileable.isConnected(Direction.TOP)).isFalse(); } | public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void neighbourDoesNotAllowConnections() { Tileable tileable = grid.get(0, 1).getTileable(); assertThat(tileable.isConnected(Direction.RIGHT)).isFalse(); } | public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void unplacedNotConnected() { Track track = new HorizontalTrack(); assertThatThrownBy(() -> track.isConnected(Direction.RIGHT)) .isInstanceOf(IllegalStateException.class); } | public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allowsConnection(direction.inverse()); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void isReleasable() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isReleasable(Direction.RIGHT, marble)).isTrue(); } | public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void isNotReleasable() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isReleasable(Direction.LEFT, marble)).isFalse(); } | public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void neighbourDoesNotAllowReleasing() { Tileable tileable = grid.get(0, 1).getTileable(); assertThat(tileable.isReleasable(Direction.RIGHT, marble)).isFalse(); } | public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void unplacedNotReleasable() { Track track = new HorizontalTrack(); assertThatThrownBy(() -> track.isReleasable(Direction.RIGHT, marble)) .isInstanceOf(IllegalStateException.class); } | public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void unplacedRelease() { Track track = new HorizontalTrack(); assertThatThrownBy(() -> track.release(Direction.RIGHT, new Marble(MarbleType.BLUE))) .isInstanceOf(IllegalStateException.class); } | public void release(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); if (neighbour != null) { informRelease(direction, marble); neighbour.getTileable().accept(direction.inverse(), marble); } } | Tileable implements Entity { public void release(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); if (neighbour != null) { informRelease(direction, marble); neighbour.getTileable().accept(direction.inverse(), marble); } } } | Tileable implements Entity { public void release(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); if (neighbour != null) { informRelease(direction, marble); neighbour.getTileable().accept(direction.inverse(), marble); } } } | Tileable implements Entity { public void release(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); if (neighbour != null) { informRelease(direction, marble); neighbour.getTileable().accept(direction.inverse(), marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public void release(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); if (neighbour != null) { informRelease(direction, marble); neighbour.getTileable().accept(direction.inverse(), marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void getStringListProperty() throws Exception { List<String> list = Lists.newArrayList("a", "b"); when(api.getListStringValueOf("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(String.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 onGrid() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.onGrid()).isTrue(); } | public boolean onGrid() { return tile != null; } | Tileable implements Entity { public boolean onGrid() { return tile != null; } } | Tileable implements Entity { public boolean onGrid() { return tile != null; } } | Tileable implements Entity { public boolean onGrid() { return tile != null; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean onGrid() { return tile != null; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void notOnGrid() { Tileable tileable = new HorizontalTrack(); assertThat(tileable.onGrid()).isFalse(); } | public boolean onGrid() { return tile != null; } | Tileable implements Entity { public boolean onGrid() { return tile != null; } } | Tileable implements Entity { public boolean onGrid() { return tile != null; } } | Tileable implements Entity { public boolean onGrid() { return tile != null; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean onGrid() { return tile != null; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void getTile() { Tile tile = grid.get(0, 0); Tileable tileable = tile.getTileable(); assertThat(tileable.getTile()).isEqualTo(tile); } | public Tile getTile() { return tile; } | Tileable implements Entity { public Tile getTile() { return tile; } } | Tileable implements Entity { public Tile getTile() { return tile; } } | Tileable implements Entity { public Tile getTile() { return tile; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public Tile getTile() { return tile; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void getListeners() { Tileable tileable = new HorizontalTrack(); assertThat(tileable.getListeners()).isEmpty(); } | public Set<TileableListener> getListeners() { return listeners; } | Tileable implements Entity { public Set<TileableListener> getListeners() { return listeners; } } | Tileable implements Entity { public Set<TileableListener> getListeners() { return listeners; } } | Tileable implements Entity { public Set<TileableListener> getListeners() { return listeners; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public Set<TileableListener> getListeners() { return listeners; } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void addListener() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); tileable.addListener(listener); assertThat(tileable.getListeners()).containsExactly(listener); } | public boolean addListener(TileableListener listener) { return listeners.add(listener); } | Tileable implements Entity { public boolean addListener(TileableListener listener) { return listeners.add(listener); } } | Tileable implements Entity { public boolean addListener(TileableListener listener) { return listeners.add(listener); } } | Tileable implements Entity { public boolean addListener(TileableListener listener) { return listeners.add(listener); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean addListener(TileableListener listener) { return listeners.add(listener); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void removeListener() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); tileable.addListener(listener); tileable.removeListener(listener); assertThat(tileable.getListeners()).isEmpty(); } | public boolean removeListener(TileableListener listener) { return listeners.remove(listener); } | Tileable implements Entity { public boolean removeListener(TileableListener listener) { return listeners.remove(listener); } } | Tileable implements Entity { public boolean removeListener(TileableListener listener) { return listeners.remove(listener); } } | Tileable implements Entity { public boolean removeListener(TileableListener listener) { return listeners.remove(listener); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { public boolean removeListener(TileableListener listener) { return listeners.remove(listener); } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void informAcceptation() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); Direction direction = Direction.RIGHT; Marble marble = new Marble(MarbleType.BLUE); tileable.addListener(listener); tileable.informAcceptation(direction, marble); verify(listener, times(1)).ballAccepted(tileable, direction, marble); } | protected void informAcceptation(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballAccepted(this, direction, marble); } } | Tileable implements Entity { protected void informAcceptation(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballAccepted(this, direction, marble); } } } | Tileable implements Entity { protected void informAcceptation(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballAccepted(this, direction, marble); } } } | Tileable implements Entity { protected void informAcceptation(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballAccepted(this, direction, marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { protected void informAcceptation(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballAccepted(this, direction, marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void informRelease() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); Direction direction = Direction.RIGHT; Marble marble = new Marble(MarbleType.BLUE); tileable.addListener(listener); tileable.informRelease(direction, marble); verify(listener, times(1)).ballReleased(tileable, direction, marble); } | protected void informRelease(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballReleased(this, direction, marble); } } | Tileable implements Entity { protected void informRelease(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballReleased(this, direction, marble); } } } | Tileable implements Entity { protected void informRelease(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballReleased(this, direction, marble); } } } | Tileable implements Entity { protected void informRelease(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballReleased(this, direction, marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { protected void informRelease(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballReleased(this, direction, marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void informDispose() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); Direction direction = Direction.RIGHT; Marble marble = new Marble(MarbleType.BLUE); tileable.addListener(listener); tileable.informDispose(direction, marble); verify(listener, times(1)).ballDisposed(tileable, direction, marble); } | protected void informDispose(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballDisposed(this, direction, marble); } } | Tileable implements Entity { protected void informDispose(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballDisposed(this, direction, marble); } } } | Tileable implements Entity { protected void informDispose(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballDisposed(this, direction, marble); } } } | Tileable implements Entity { protected void informDispose(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballDisposed(this, direction, marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } | Tileable implements Entity { protected void informDispose(Direction direction, Marble marble) { for (TileableListener listener : listeners) { listener.ballDisposed(this, direction, marble); } } abstract boolean allowsConnection(Direction direction); abstract boolean accepts(Direction direction, Marble marble); abstract void accept(Direction direction, Marble marble); boolean isConnected(Direction direction); boolean isReleasable(Direction direction, Marble marble); void release(Direction direction, Marble marble); Tile getTile(); void setTile(Tile tile); Set<TileableListener> getListeners(); boolean addListener(TileableListener listener); boolean removeListener(TileableListener listener); boolean onGrid(); } |
@Test public void getDefaultStringListProperty() throws Exception { when(api.getListStringValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new ListProperty<>(String.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 getBoundedIntegerPropertyDefault() throws Exception { when(api.getIntegerValueOf("a")).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a", -1), 0, 100))) .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 getBoundedIntegerPropertyInner() throws Exception { when(api.getIntegerValueOf("a")).thenReturn(50); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a"), 0, 100))) .isEqualTo(50); } | @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 getBoundedIntegerPropertyLower() throws Exception { when(api.getIntegerValueOf("a")).thenReturn(-1); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a"), 0, 100))) .isEqualTo(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 getBoundedIntegerPropertyUpper() throws Exception { when(api.getIntegerValueOf("a")).thenReturn(200); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a"), 0, 100))) .isEqualTo(100); } | @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 existentFile() throws Exception { File file = File.createTempFile("defpro", "test"); String content = "int a = 1"; Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE); assertThat(loader.load(file).get(new IntegerProperty("a"))).isEqualTo(1); file.deleteOnExit(); } | @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 getUnsupportedProperty() { Object object = new Object(); assertThat(config.get(new Property<Object>(Object.class, "", object) {})) .isEqualTo(object); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void propertyExists() throws Exception { when(api.hasPath("test")).thenReturn(true); assertThat(config.exists(new StringProperty("test", ""))).isTrue(); } | @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } LightbendConfiguration(Config api); } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void propertyNotExists() throws Exception { when(api.getString(anyString())).thenThrow(new ConfigException.BadPath("", "")); assertThat(config.exists(new StringProperty("test", ""))).isFalse(); } | @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } LightbendConfiguration(Config api); } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { return api.hasPath(property.getKey()); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getBooleanProperty() throws Exception { when(api.getBoolean("a")).thenReturn(true); assertThat(config.get(new BooleanProperty("a", false))).isTrue(); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultBooleanProperty() throws Exception { when(api.getBoolean(anyString())).thenThrow(new ConfigException.BadPath("", "")); assertThat(config.get(new BooleanProperty("a", false))).isFalse(); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDoubleProperty() throws Exception { when(api.getDouble("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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultDoubleProperty() throws Exception { when(api.getDouble(anyString())).thenThrow(new ConfigException.BadPath("", "")); 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getIntegerProperty() throws Exception { when(api.getInt("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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultIntegerProperty() throws Exception { when(api.getInt(anyString())).thenThrow(new ConfigException.BadPath("", "")); 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getStringProperty() throws Exception { when(api.getString("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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void validStream() throws Exception { String content = "int a = 1"; InputStream input = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); assertThat(loader.load(input).get(new IntegerProperty("a"))).isEqualTo(1); } | @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 getDefaultStringProperty() throws Exception { when(api.getString(anyString())).thenThrow(new ConfigException.BadPath("", "")); 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getBooleanListProperty() throws Exception { List<Boolean> list = Lists.newArrayList(false, true); when(api.getBooleanList("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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultBooleanListProperty() throws Exception { when(api.getDoubleList(anyString())).thenThrow(new ConfigException.BadPath("", "")); 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDoubleListProperty() throws Exception { List<Double> list = Lists.newArrayList(1.0, 2.0); when(api.getDoubleList("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(Double.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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultDoubleListProperty() throws Exception { when(api.getDoubleList(anyString())).thenThrow(new ConfigException.BadPath("", "")); assertThat(config.get(new ListProperty<>(Double.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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getIntegerListProperty() throws Exception { List<Integer> list = Lists.newArrayList(1, 2); when(api.getIntList("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(Integer.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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultIntegerListProperty() throws Exception { when(api.getIntList(anyString())).thenThrow(new ConfigException.BadPath("", "")); assertThat(config.get(new ListProperty<>(Integer.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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getStringListProperty() throws Exception { List<String> list = Lists.newArrayList("a", "b"); when(api.getStringList("a")).thenReturn(list); assertThat(config.get(new ListProperty<>(String.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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getDefaultStringListProperty() throws Exception { when(api.getStringList(anyString())).thenThrow(new ConfigException.BadPath("", "")); assertThat(config.get(new ListProperty<>(String.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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void invalidStream() throws Exception { InputStream input = mock(InputStream.class); when(input.read(any())).thenThrow(new IOException()); assertThatThrownBy(() -> loader.load(input)).isInstanceOf(IOException.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 getBoundedIntegerPropertyDefault() throws Exception { when(api.getInt("a")).thenThrow(new ConfigException.BadPath("", "")); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a", -1), 0, 100))) .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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getBoundedIntegerPropertyInner() throws Exception { when(api.getInt("a")).thenReturn(50); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a"), 0, 100))) .isEqualTo(50); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getBoundedIntegerPropertyLower() throws Exception { when(api.getInt("a")).thenReturn(-1); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a"), 0, 100))) .isEqualTo(0); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void getBoundedIntegerPropertyUpper() throws Exception { when(api.getInt("a")).thenReturn(200); assertThat(config.get(new BoundedProperty<>(new IntegerProperty("a"), 0, 100))) .isEqualTo(100); } | @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } | LightbendConfiguration 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 = property instanceof ListProperty ? getList((ListProperty) property) : getValue(key, type); if (value == null) { return defaultValue; } return property.map((T) value); } LightbendConfiguration(Config api); @Override @SuppressWarnings("unchecked") T get(Property<T> property, T defaultValue); @Override boolean exists(Property<?> property); } |
@Test public void nonExistentFile() throws Exception { File file = mock(File.class); when(file.exists()).thenReturn(false); assertThatThrownBy(() -> loader.load(file)).isInstanceOf(FileNotFoundException.class); } | @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } |
@Test public void existentFile() throws Exception { File file = File.createTempFile("lightbend", "test"); String content = "a = 1"; Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE); assertThat(loader.load(file).get(new IntegerProperty("a"))).isEqualTo(1); file.deleteOnExit(); } | @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } |
@Test public void validStream() throws Exception { String content = "a = 1"; InputStream input = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); assertThat(loader.load(input).get(new IntegerProperty("a"))).isEqualTo(1); } | @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } |
@Test public void invalidStream() throws Exception { InputStream input = mock(InputStream.class); when(input.read(any())).thenThrow(new IOException()); assertThatThrownBy(() -> loader.load(input)).isInstanceOf(IOException.class); } | @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } | LightbendConfigurationLoader implements ConfigurationLoader { @Override public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } return new LightbendConfiguration(ConfigFactory.parseFile(file)); } @Override Configuration load(File file); @Override Configuration load(InputStream input); } |
@Test public void smokeTest() { assertThatCode(() -> { DesktopLauncher.main(new String[] {}); Thread.sleep(2000); ((LwjglApplication) Gdx.app).stop(); }).doesNotThrowAnyException(); } | public static void main(String[] args) { getInstance().run(); } | DesktopLauncher implements Runnable { public static void main(String[] args) { getInstance().run(); } } | DesktopLauncher implements Runnable { public static void main(String[] args) { getInstance().run(); } private DesktopLauncher(); } | DesktopLauncher implements Runnable { public static void main(String[] args) { getInstance().run(); } private DesktopLauncher(); static DesktopLauncher getInstance(); static void main(String[] args); @Override void run(); } | DesktopLauncher implements Runnable { public static void main(String[] args) { getInstance().run(); } private DesktopLauncher(); static DesktopLauncher getInstance(); static void main(String[] args); @Override void run(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.