src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
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 allowsConnectionLeft() { assertThat(nexus.allowsConnection(Direction.LEFT)).isTrue(); }
@Test public void allowsConnectionRight() { assertThat(nexus.allowsConnection(Direction.RIGHT)).isTrue(); }
@Test public void allowsConnectionBottom() { assertThat(nexus.allowsConnection(Direction.BOTTOM)).isTrue()... |
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 acceptsLeft() { assertThat(nexus.accepts(Direction.LEFT, marble)).isTrue(); }
@Test public void acceptsRight() { assertThat(nexus.accepts(Direction.RIGHT, marble)).isTrue(); }
@Test public void notAcceptsTop() { assertThat(nexus.accepts(Direction.TOP, marble)).isFalse(); }
@Test public void notAccepts... |
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 getContext() { assertThat(nexus.getContext()).isEqualTo(context); } |
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 testWonFalse() { assertThat(progress.isWon()).isFalse(); } |
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(2); } |
HardLevelOne extends AbstractHardLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } | @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); } |
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 createLevelOne() { assertThat(factory.create(1)).isInstanceOf(HardLevelOne.class); }
@Test public void createLevelTwo() { assertThat(factory.create(2)).isInstanceOf(HardLevelTwo.class); }
@Test public void createLevelThree() { assertThat(factory.create(3)).isInstanceOf(HardLevelThree.class); } |
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(3); } |
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(2); } |
EasyLevelOne extends AbstractEasyLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } | @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); } |
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 createLevelOne() { assertThat(factory.create(1)).isInstanceOf(EasyLevelOne.class); }
@Test public void createLevelTwo() { assertThat(factory.create(2)).isInstanceOf(EasyLevelTwo.class); }
@Test public void createLevelThree() { assertThat(factory.create(3)).isInstanceOf(EasyLevelThree.class); } |
EasyLevelThree extends AbstractEasyLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); } | @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); } |
LevelFactory { public abstract Level create(int level); abstract Level create(int level); } | @Test public void getFirst() { assertThat(factory.create(1)).isNotNull(); }
@Test public void getSecond() { assertThat(factory.create(2)).isNotNull(); }
@Test public void getThird() { assertThat(factory.create(3)).isNotNull(); }
@Test public void getFourth() { assertThat(factory.create(4)).isNull(); } |
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(3); } |
MediumLevelOne extends AbstractMediumLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); } | @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); } |
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 createLevelOne() { assertThat(factory.create(1)).isInstanceOf(MediumLevelOne.class); }
@Test public void createLevelTwo() { assertThat(factory.create(2)).isInstanceOf(MediumLevelTwo.class); }
@Test public void createLevelThree() { assertThat(factory.create(3)).isInstanceOf(MediumLevelThree.class); } |
MediumLevelTwo extends AbstractMediumLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); } | @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(2); } |
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 isOccupied() { assertThat(grid.get(0,0).isOccupied()).isTrue(); } |
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; c... | @Test public void getDirectionNull() { assertThatThrownBy(() -> grid.get(1,0).get(null)) .isInstanceOf(IllegalArgumentException.class); } |
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 getGridTest() { assertThat(grid.get(0,0).getGrid()).isEqualTo(grid); } |
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... | @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(); } } }
@Test public void onGridOutPointsTest() { Grid grid = new Grid(session, 3, 2); int x = -1; int y = -1; while (y < 2) { while (x < 4) { as... |
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 g... | @Test public void placeInvalid() { Grid grid = new Grid(session, 3, 1); assertThatThrownBy(() -> grid.place(-1, -1, null)) .isInstanceOf(IllegalArgumentException.class); } |
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 getSession() { Grid grid = new Grid(session, 1, 1); assertThat(grid.getSession()).isEqualTo(session); } |
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(dir... | @Test public void isConnected() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isConnected(Direction.RIGHT)).isTrue(); }
@Test public void isConnectedInverse() { Tileable tileable = grid.get(1, 0).getTileable(); assertThat(tileable.isConnected(Direction.LEFT)).isTrue(); }
@Test public void isNo... |
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 all... | @Test public void isReleasable() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isReleasable(Direction.RIGHT, marble)).isTrue(); }
@Test public void isNotReleasable() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.isReleasable(Direction.LEFT, marble)).isFalse(); }
@Test... |
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); }... | @Test public void unplacedRelease() { Track track = new HorizontalTrack(); assertThatThrownBy(() -> track.release(Direction.RIGHT, new Marble(MarbleType.BLUE))) .isInstanceOf(IllegalStateException.class); } |
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(Di... | @Test public void onGrid() { Tileable tileable = grid.get(0, 0).getTileable(); assertThat(tileable.onGrid()).isTrue(); }
@Test public void notOnGrid() { Tileable tileable = new HorizontalTrack(); assertThat(tileable.onGrid()).isFalse(); } |
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 di... | @Test public void getTile() { Tile tile = grid.get(0, 0); Tileable tileable = tile.getTileable(); assertThat(tileable.getTile()).isEqualTo(tile); } |
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); boolea... | @Test public void getListeners() { Tileable tileable = new HorizontalTrack(); assertThat(tileable.getListeners()).isEmpty(); } |
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(Dire... | @Test public void addListener() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); tileable.addListener(listener); assertThat(tileable.getListeners()).containsExactly(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 isConnecte... | @Test public void removeListener() { TileableListener listener = mock(TileableListener.class); Tileable tileable = new HorizontalTrack(); tileable.addListener(listener); tileable.removeListener(listener); assertThat(tileable.getListeners()).isEmpty(); } |
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); abs... | @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,... |
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); abstrac... | @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... |
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); abstrac... | @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... |
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)... | @Test public void getUnsupportedProperty() { Object object = new Object(); assertThat(config.get(new Property<Object>(Object.class, "", object) {})) .isEqualTo(object); }
@Test public void getBooleanProperty() throws Exception { when(api.getBoolean("a")).thenReturn(true); assertThat(config.get(new BooleanProperty("a", ... |
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 propertyExists() throws Exception { when(api.hasPath("test")).thenReturn(true); assertThat(config.exists(new StringProperty("test", ""))).isTrue(); }
@Test public void propertyNotExists() throws Exception { when(api.getString(anyString())).thenThrow(new ConfigException.BadPath("", "")); assertThat(con... |
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 Configurati... | @Test public void nonExistentFile() throws Exception { File file = mock(File.class); when(file.exists()).thenReturn(false); assertThatThrownBy(() -> loader.load(file)).isInstanceOf(FileNotFoundException.class); }
@Test public void existentFile() throws Exception { File file = File.createTempFile("lightbend", "test"); S... |
DesktopLauncher implements Runnable { public static void main(String[] args) { getInstance().run(); } private DesktopLauncher(); static DesktopLauncher getInstance(); static void main(String[] args); @Override void run(); } | @Test public void smokeTest() { assertThatCode(() -> { DesktopLauncher.main(new String[] {}); Thread.sleep(2000); ((LwjglApplication) Gdx.app).stop(); }).doesNotThrowAnyException(); } |
MusicActor extends Actor implements Disposable { public void play(Music theme) { if (this.theme != null) { this.theme.stop(); } this.theme = theme; this.theme.setLooping(true); this.theme.play(); } void play(Music theme); @Override void dispose(); } | @Test public void testPlay() { Music theme = mock(Music.class); actor.play(theme); verify(theme, times(1)).play(); verify(theme, times(1)).setLooping(true); }
@Test public void testPlaySecond() { Music first = mock(Music.class); Music second = mock(Music.class); actor.play(first); reset(first); actor.play(second); veri... |
ReceptorActor extends TileableActor<Receptor> implements ReceptorListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { Actor actor = getContext().actor(marble); if (actor != null) { actor.remove(); } } ReceptorActor(Receptor receptor, ActorContext context); @Override Tex... | @Test public void disposeUnknown() throws Exception { assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); assertThatCode(() -> actor.ballDisposed(receptor, Direction.LEFT, new Marble(MarbleType.BLUE)) ).doesNotThrowAnyException(); } |
NexusActor extends TransportingActor<Nexus> implements TileableListener { @Override public void ballAccepted(Tileable tileable, Direction direction, Marble marble) { MarbleActor actor = MarbleActor.get(marble, getContext()); addActor(actor); Nexus nexus = getTileable(); Vector2 origin = getOrigin(direction); Vector2 ce... | @Test public void testSpawn() throws Exception { assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); latch = new CountDownLatch(2); TileableListener listener = spy(new TileableListener() { @Override public void ballAccepted(Tileable tileable, Direction direction, Marble marble) { latch.countDown(); } }); nexus.addLi... |
TrackActor extends TransportingActor<Track> implements TileableListener { @Override public void ballAccepted(Tileable tileable, Direction direction, Marble marble) { MarbleActor actor = (MarbleActor) getContext().actor(marble); Vector2 origin = stageToLocalCoordinates(actor.localToStageCoordinates( new Vector2(actor.ge... | @Test public void testFilterJoker() throws Exception { assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); latch = new CountDownLatch(2); Marble marble = new Marble(MarbleType.JOKER); JokerMarbleActor jokerActor = new JokerMarbleActor(marble, context); jokerActor.addActor(new Actor()); context.register(marble, joker... |
ScreenStack extends Stack { public void push(Actor screen) { Action runnable = Actions.run(() -> { add(screen); getStage().setKeyboardFocus(screen); }); addAction(runnable); } void replace(Actor screen); void push(Actor screen); void pop(int n); @Override void act(float deltaTime); } | @Test public void testPush() throws Exception { Actor screen = spy(new Actor()); latch = new CountDownLatch(1); app.postRunnable(() -> { actor.push(screen); latch.countDown(); }); assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); Thread.sleep(500); verify(screen, atLeastOnce()).draw(any(), anyFloat()); verify(scre... |
ScreenStack extends Stack { public void replace(Actor screen) { Action runnable = Actions.run(() -> { if (hasChildren()) { getChildren().pop(); } add(screen); getStage().setKeyboardFocus(screen); }); addAction(runnable); } void replace(Actor screen); void push(Actor screen); void pop(int n); @Override void act(float d... | @Test public void testReplace() throws Exception { Actor screenA = spy(new Actor()); Actor screenB = spy(new Actor()); latch = new CountDownLatch(1); app.postRunnable(() -> { actor.push(screenA); actor.replace(screenB); latch.countDown(); }); assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); reset(screenA); Thread... |
ScreenStack extends Stack { public void pop(int n) { addAction(Actions.run(() -> { if (!hasChildren() || n == 0) { return; } SnapshotArray<Actor> children = getChildren(); int size = children.size; children.removeRange(Math.max(0, size - n), size - 1); if (size - n > 0) { getStage().setKeyboardFocus(children.peek()); }... | @Test public void testPopNoChildren() throws Exception { latch = new CountDownLatch(1); app.postRunnable(() -> { actor.pop(1); latch.countDown(); }); assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); Thread.sleep(500); assertThat(actor.hasChildren()).isFalse(); } |
ScreenStack extends Stack { @Override public void act(float deltaTime) { Array<Action> actions = this.getActions(); Stage stage = getStage(); if (actions.size > 0) { if (stage != null) { if (stage.getActionsRequestRendering()) { Gdx.graphics.requestRendering(); } } for (int i = 0; i < actions.size; i++) { Action action... | @Test @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") public void testActionsNoStage() throws Exception { Graphics real = Gdx.graphics; Gdx.graphics = spy(real); latch = new CountDownLatch(1); app.postRunnable(() -> { actor.remove(); actor.addAction(Actions.delay(1)); actor.act(1); latch.countDown(); });... |
StackableStage extends Stage { public void push(Actor screen) { stack.push(screen); } StackableStage(Viewport viewport, ScreenStack stack); StackableStage(Viewport viewport); ScreenStack getScreenStack(); void replace(Actor screen); void push(Actor screen); void pop(int n); } | @Test public void push() { Actor screen = mock(Actor.class); stage.push(screen); verify(stack).push(eq(screen)); } |
DefProConfiguration implements Configuration { @Override public boolean exists(Property<?> property) { try { return api.getStringValueOf(property.getKey()) != null; } catch (NotExistingVariableException ignored) { return false; } } DefProConfiguration(IDefProAPI api); @Override @SuppressWarnings("unchecked") T get(Prop... | @Test public void propertyExists() throws Exception { when(api.getStringValueOf("test")).thenReturn(""); assertThat(config.exists(new StringProperty("test", ""))).isTrue(); }
@Test public void propertyNotExists() throws Exception { when(api.getStringValueOf(anyString())).thenThrow(new NotExistingVariableException(""));... |
StackableStage extends Stage { public void replace(Actor screen) { stack.replace(screen); } StackableStage(Viewport viewport, ScreenStack stack); StackableStage(Viewport viewport); ScreenStack getScreenStack(); void replace(Actor screen); void push(Actor screen); void pop(int n); } | @Test public void replace() { Actor screen = mock(Actor.class); stage.replace(screen); verify(stack).replace(eq(screen)); } |
StackableStage extends Stage { public void pop(int n) { stack.pop(n); } StackableStage(Viewport viewport, ScreenStack stack); StackableStage(Viewport viewport); ScreenStack getScreenStack(); void replace(Actor screen); void push(Actor screen); void pop(int n); } | @Test public void pop() { stage.pop(2); verify(stack).pop(eq(2)); } |
Receptor extends Tileable { public boolean isMarked() { return marked; } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp(); void setPowerUp(PowerUp powerUp); @Override boolean isReleasable(Direction dir... | @Test public void notMarkedOnStart() { Receptor receptor = new Receptor(); assertThat(receptor.isMarked()).isFalse(); } |
Receptor extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return !locked && !getSlot(direction).isOccupied(); } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp()... | @Test public void acceptsWhenSlotEmpty() { Receptor receptor = new Receptor(); assertThat(receptor.accepts(Direction.LEFT, marble)).isTrue(); } |
Receptor extends Tileable { @Override public boolean allowsConnection(Direction direction) { return true; } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp(); void setPowerUp(PowerUp powerUp); @Override... | @Test public void allowsConnectionLeft() { assertThat(receptor.allowsConnection(Direction.LEFT)).isTrue(); }
@Test public void allowsConnectionRight() { assertThat(receptor.allowsConnection(Direction.RIGHT)).isTrue(); }
@Test public void allowsConnectionTop() { assertThat(receptor.allowsConnection(Direction.TOP)).isTru... |
Receptor extends Tileable { public void lock() { this.locked = true; } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp(); void setPowerUp(PowerUp powerUp); @Override boolean isReleasable(Direction direc... | @Test public void lock() { receptor.lock(); assertThat(receptor.isLocked()).isTrue(); } |
Receptor extends Tileable { public void unlock() { this.locked = false; } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp(); void setPowerUp(PowerUp powerUp); @Override boolean isReleasable(Direction di... | @Test public void unlock() { receptor.unlock(); assertThat(receptor.isLocked()).isFalse(); } |
Receptor extends Tileable { @Override public boolean isReleasable(Direction direction, Marble marble) { return !isLocked() && super.isReleasable(direction, marble); } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerU... | @Test public void unlockedReceptorIsNotReleasable() { Grid grid = new Grid(null,1, 1); grid.place(0, 0, receptor); assertThat(receptor.isReleasable(Direction.LEFT, marble)).isFalse(); }
@Test public void isReleasable() { Grid grid = new Grid(null,2, 1); grid.place(0, 0, new HorizontalTrack()); grid.place(1, 0, receptor... |
Receptor extends Tileable { public Slot getSlot(Direction direction) { return slots[Math.floorMod(direction.ordinal() - rotation, directions.length)]; } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp()... | @Test public void isNotCompatibleB() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, receptor); assertThat(receptor.getSlot(Direction.LEFT) .isCompatible(receptor.getSlot(Direction.RIGHT))).isFalse(); }
@Test public void getReceptor() { assertThat(receptor.getSlot(Direction.LEFT).getReceptor()).isEqualTo(receptor)... |
Receptor extends Tileable { @Override public void accept(Direction direction, Marble marble) { getSlot(direction).accept(marble); } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp(); void setPowerUp(Pow... | @Test public void acceptWhenSlotOccupied() { receptor.accept(Direction.TOP, new Marble(MarbleType.BLUE)); assertThatThrownBy(() -> receptor.accept(Direction.TOP, new Marble(MarbleType.BLUE))) .isInstanceOf(IllegalStateException.class) .hasMessage("The slot is already occupied"); }
@Test public void notMark() { Receptor... |
Receptor extends Tileable { private void mark() { marked = true; getTile().getGrid().getSession().getProgress().score(multiplier); for (Slot slot : slots) { slot.dispose(); } informMarked(); if (powerUp != null) { powerUp.activate(this); setPowerUp(null); } } void rotate(int turns); int getRotation(); Slot getSlot(Dir... | @Test public void mark() { ReceptorListener listener = mock(ReceptorListener.class); ReceptorListener stub = new ReceptorListener() {}; TileableListener tileableListener = mock(TileableListener.class); receptor.addListener(listener); receptor.addListener(stub); receptor.addListener(tileableListener); Progress progress ... |
Receptor extends Tileable { public void setPowerUp(PowerUp powerUp) { this.powerUp = powerUp; informAssigned(); } void rotate(int turns); int getRotation(); Slot getSlot(Direction direction); boolean isMarked(); boolean isLocked(); void lock(); void unlock(); PowerUp getPowerUp(); void setPowerUp(PowerUp powerUp); @Ov... | @Test public void assigned() { ReceptorListener listener = mock(ReceptorListener.class); ReceptorListener stub = new ReceptorListener() {}; TileableListener tileableListener = mock(TileableListener.class); receptor.addListener(listener); receptor.addListener(stub); receptor.addListener(tileableListener); receptor.setPo... |
RandomPowerUpFactory extends PowerUpFactory { @Override public PowerUp create() { return cdf.floorEntry(random.nextDouble()).getValue().create(); } RandomPowerUpFactory(Random random, NavigableMap<Double, PowerUpFactory> cdf); @Override PowerUp create(); } | @Test public void createA() { NavigableMap<Double, PowerUpFactory> cdf = new TreeMap<>(); cdf.put(0.0, new BonusPowerUpFactory()); cdf.put(0.6, new JokerPowerUpFactory()); PowerUpFactory factory = new RandomPowerUpFactory(random, cdf); when(random.nextDouble()).thenReturn(0.4); assertThat(factory.create()).isInstanceOf... |
BonusPowerUp implements PowerUp { @Override public void activate(Receptor receptor) { receptor.getTile().getGrid().getSession().getProgress().score(100); } @Override void activate(Receptor receptor); } | @Test public void activate() { receptor.setPowerUp(powerUp); for (Direction direction : Direction.values()) { receptor.accept(direction, new Marble(MarbleType.BLUE)); } assertThat(session.getProgress().getScore()).isEqualTo(200); } |
JokerPowerUp implements PowerUp { @Override public void activate(Receptor receptor) { NexusContext context = receptor.getTile().getGrid().getSession().getNexusContext(); context.add(MarbleType.JOKER, MarbleType.JOKER); } @Override void activate(Receptor receptor); } | @Test public void activate() { receptor.setPowerUp(powerUp); for (Direction direction : Direction.values()) { receptor.accept(direction, new Marble(MarbleType.BLUE)); } verify(context).add(MarbleType.JOKER, MarbleType.JOKER); } |
Teleporter extends Tileable implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } Teleporter(Track track); void setDestination(Teleporter destination); Track getTrack(); Teleporter getDestination(); @Override boolean allowsConnection(D... | @Test public void allowsLeft() { assertThat(teleporter1.allowsConnection(Direction.LEFT)).isTrue(); }
@Test public void allowsRight() { assertThat(teleporter1.allowsConnection(Direction.RIGHT)).isTrue(); }
@Test public void disallowsTop() { assertThat(teleporter1.allowsConnection(Direction.TOP)).isFalse(); }
@Test publ... |
Teleporter extends Tileable implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } Teleporter(Track track); void setDestination(Teleporter destination); Track getTrack(); Teleporter getDestination(); @Override boolean allowsConnect... | @Test public void acceptsLeft() { assertThat(teleporter1.accepts(Direction.LEFT, new Marble( MarbleType.GREEN))).isTrue(); } |
Teleporter extends Tileable implements TileableListener { public Track getTrack() { return track; } Teleporter(Track track); void setDestination(Teleporter destination); Track getTrack(); Teleporter getDestination(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction,... | @Test public void getTrack() { assertThat(teleporter1.getTrack()).isEqualTo(inner); } |
Teleporter extends Tileable implements TileableListener { public Teleporter getDestination() { return destination; } Teleporter(Track track); void setDestination(Teleporter destination); Track getTrack(); Teleporter getDestination(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Dir... | @Test public void getDestination() { assertThat(teleporter1.getDestination()).isEqualTo(teleporter2); assertThat(teleporter2.getDestination()).isEqualTo(teleporter1); } |
UriUtils { public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches()... | @Test public void checkUriIsValidTest() { String url = "http: UriUtils.checkUrlIsValid(url); url = "https: UriUtils.checkUrlIsValid(url); url = "http: UriUtils.checkUrlIsValid(url); url = "https: UriUtils.checkUrlIsValid(url); url = "http: UriUtils.checkUrlIsValid(url); url = "http: UriUtils.checkUrlIsValid(url); url =... |
G2Client { public void loginToGallery(String galleryUrl, String user, String password) throws ImpossibleToLoginException { sessionCookies.clear(); sessionCookies.add(new BasicClientCookie("", "")); List<NameValuePair> sb = new ArrayList<NameValuePair>(); sb.add(LOGIN_CMD_NAME_VALUE_PAIR); sb.add(new BasicNameValuePair(... | @Test(expected = ImpossibleToLoginException.class) public void loginToGalleryTestFailBecauseUrlIsWrong() throws GalleryConnectionException { g2ConnectionUtils.loginToGallery("http: "hackerPassword"); }
@Test public void loginToGalleryTest() throws GalleryConnectionException { g2ConnectionUtils .loginToGallery(galleryUr... |
G2Client { public int sendImageToGallery(String galleryUrl, int albumName, File imageFile, String imageName, String summary, String description) throws GalleryConnectionException { int imageCreatedName = 0; MultipartEntity multiPartEntity = createMultiPartEntityForSendImageToGallery( albumName, imageFile, imageName, su... | @Test @Ignore public void sendImageToGalleryTest() throws GalleryConnectionException { g2ConnectionUtils.loginToGallery(galleryUrl, user, password); File imageFile = new File("image.png"); int newItemId = g2ConnectionUtils.sendImageToGallery(galleryUrl, 174, imageFile, "plouf", "Summary from test", "Description from te... |
G2Client { public int createNewAlbum(String galleryUrl, int parentAlbumName, String albumName, String albumTitle, String albumDescription) throws GalleryConnectionException { int newAlbumName = 0; List<NameValuePair> nameValuePairsFetchImages = new ArrayList<NameValuePair>(); nameValuePairsFetchImages.add(CREATE_ALBUM_... | @Test public void createNewAlbumTest() throws GalleryConnectionException { g2ConnectionUtils.loginToGallery(galleryUrl, user, password); Random random = new Random(); int randomInt = random.nextInt(); String albumName = "UnitTestAlbumNumber" + randomInt; String albumTitle = "Unit Test Album"; String albumDescription = ... |
G2Client { public Collection<G2Picture> extractG2PicturesFromProperties( HashMap<String, String> fetchImages) throws GalleryConnectionException { Map<Integer, G2Picture> picturesMap = new HashMap<Integer, G2Picture>(); List<Integer> tmpImageNumbers = new ArrayList<Integer>(); int imageNumber = 0; for (Entry<String, Str... | @Test public void extractG2PictureFromPropertiesTest() throws GalleryConnectionException { HashMap<String, String> fetchImages = new HashMap<String, String>(); fetchImages.put("image.thumb_height.393", "150"); fetchImages.put("image.title.393", "picture.jpg"); fetchImages.put("image.resizedName.393", "12600"); fetchIma... |
G2Client { public Map<Integer, G2Album> extractAlbumFromProperties( HashMap<String, String> albumsProperties) throws GalleryConnectionException { int albumNumber = 0; Map<Integer, G2Album> albumsMap = new HashMap<Integer, G2Album>(); List<Integer> tmpAlbumNumbers = new ArrayList<Integer>(); for (Entry<String, String> e... | @Test public void extractAlbumFromPropertiesTest() throws GalleryConnectionException { HashMap<String, String> albumsProperties = new HashMap<String, String>(); albumsProperties.put("album.name.1", "10726"); albumsProperties.put("album.title.1", "Brunch"); albumsProperties.put("album.summary.1", "Le Dimanche de 11h à 1... |
G2Client { public Album organizeAlbumsHierarchy(Map<Integer, G2Album> albums) { Album rootAlbum = null; Map<Integer, Album> albumss = new HashMap<Integer, Album>(); for (Integer key : albums.keySet()) { albumss.put(key, G2ConvertUtils.g2AlbumToAlbum(albums.get(key))); } for (Album album : albumss.values()) { if (album.... | @Test public void organizeAlbumsHierarchy() throws Exception { Map<Integer, G2Album> albums = new HashMap<Integer, G2Album>(); G2Album album = new G2Album(); album.setName(6); album.setId(600); album.setParentName(20); albums.put(album.getId(), album); album = new G2Album(); album.setName(3); album.setId(300); album.se... |
G2ConvertUtils { public static Album g2AlbumToAlbum(G2Album g2Album) { if(g2Album==null){ return null; } Album album = new Album(); album.setId(g2Album.getId()); album.setName(g2Album.getName()); album.setTitle(g2Album.getTitle()); album.setSummary(g2Album.getSummary()); album.setParentName(g2Album.getParentName()); re... | @Test public void g2AlbumToAlbum() throws IOException, JSONException { G2Album g2Album = new G2Album(); g2Album.setId(1024); g2Album.setTitle("Title"); g2Album.setName(12); g2Album.setSummary("Summary"); g2Album.setParentName(1); g2Album.setExtrafields("extrafields"); Album album = G2ConvertUtils.g2AlbumToAlbum(g2Album... |
G2ConvertUtils { public static Picture g2PictureToPicture(G2Picture g2Picture, String galleryUrl) { if(g2Picture==null ){ return null; } String baseUrl = getBaseUrl(galleryUrl); Picture picture = new Picture(); picture.setId(g2Picture.getId()); picture.setTitle(g2Picture.getCaption()); picture.setFileName(g2Picture.get... | @Test public void g2PictureToPicture() throws IOException, JSONException { G2Picture g2Picture = new G2Picture(); g2Picture.setTitle("Title.jpg"); g2Picture.setId(10214); g2Picture.setName("1"); g2Picture.setThumbName("2"); g2Picture.setThumbWidth(320); g2Picture.setThumbHeight(480); g2Picture.setResizedName("3"); g2Pi... |
JiwigoConvertUtils { public static Album jiwigoCategoryToAlbum(Category jiwigoCategory) { if(jiwigoCategory==null){ return null; } Album album = new Album(); album.setId(jiwigoCategory.getIdentifier()); album.setName(jiwigoCategory.getIdentifier()); album.setTitle(jiwigoCategory.getName()); album.setParentName(jiwigoCa... | @Test public void jiwigoCategoryToAlbum() { Category jiwigoCategory = new Category(); jiwigoCategory.setIdentifier(43); jiwigoCategory.setName("MyAlbum"); jiwigoCategory.setDirectParent(1); Album album = JiwigoConvertUtils.jiwigoCategoryToAlbum(jiwigoCategory); Album expectedAlbum = new Album(); expectedAlbum.setId(43)... |
JiwigoConvertUtils { public static Picture jiwigoImageToPicture(Image jiwigoImage) { if(jiwigoImage==null ){ return null; } Picture picture = new Picture(); picture.setId(jiwigoImage.getIdentifier()); picture.setTitle(jiwigoImage.getName()); picture.setFileName(jiwigoImage.getFile()); picture.setThumbUrl(jiwigoImage.ge... | @Test public void jiwigoImageToPicture() { Image jiwigoImage = new Image(); jiwigoImage.setName("Title"); jiwigoImage.setFile("Title.jpg"); jiwigoImage.setIdentifier(10214); jiwigoImage .setThumbnailUrl("http: jiwigoImage.setWidth(768); jiwigoImage.setHeight(1024); jiwigoImage .setUrl("http: Picture picture = JiwigoCon... |
JiwigoConvertUtils { public static Album categoriesToAlbum(List<Category> categories){ Album resultAlbum = new Album(); resultAlbum.setName(0); resultAlbum.setId(0); Album album; for (Category category : categories) { album = jiwigoCategoryToAlbum(category); if(category.getParentCategories().size()==0){ resultAlbum.get... | @Test public void categoriesToAlbum() { List<Category> categories = new ArrayList<Category>(); Category coaticook = new Category(); coaticook.setName("coaticook"); coaticook.setIdentifier(1); Category barrage = new Category(); barrage.setName("barrage"); barrage.setIdentifier(2); Category barrage2 = new Category(); bar... |
G3Client implements IG3Client { public Item getItem(int itemId) throws G3GalleryException { Item item = null; String stringResult = sendHttpRequest(INDEX_PHP_REST_ITEM + itemId, new ArrayList<NameValuePair>(), GET, null); try { JSONObject jsonResult = (JSONObject) new JSONTokener(stringResult) .nextValue(); item = Item... | @Test public void getItemTest__album() throws G3GalleryException { Item item1 = itemClient.getItem(1); assertEquals("Gallery", item1.getEntity().getTitle()); } |
G3Client implements IG3Client { public String getApiKey() throws G3GalleryException { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("user", username)); nameValuePairs.add(new BasicNameValuePair("password", password)); String jsonResult = sendHttpRequest(I... | @Test public void getApiKey() throws G3GalleryException { String apiKey = itemClient.getApiKey(); assertNotNull(apiKey); } |
G3Client implements IG3Client { public int createItem(Entity entity, File file) throws G3GalleryException { String resultUrl; NameValuePair nameValuePair; try { if (file == null) { nameValuePair = new BasicNameValuePair("entity", ItemUtils.convertAlbumEntityToJSON(entity)); } else { nameValuePair = new BasicNameValuePa... | @Test public void createAlbum() throws G3GalleryException { Entity albumToCreate = new Entity(); albumToCreate.setName("AlbumName" + System.currentTimeMillis()); albumToCreate.setTitle("New Album"); albumToCreate.setParent(G2ANDROID_SECRET_ALBUM); createdAlbumId = itemClient.createItem(albumToCreate, null); assertNotNu... |
G3Client implements IG3Client { public List<Item> getAlbumAndSubAlbums(int albumId) throws G3GalleryException { List<Item> items = new ArrayList<Item>(); Item item = getItems(albumId, items, "album"); items.add(0, item); return items; } G3Client(String galleryUrl, String userAgent); Item getItem(int itemId); int create... | @Test public void getAlbumAndSubAlbumsTest() throws G3GalleryException { List<Item> subAlbums = itemClient.getAlbumAndSubAlbums(11); boolean foundRecentlyAddedAlbum = false; for (Item album : subAlbums) { if (album.getEntity().getId() == createdAlbumId) { foundRecentlyAddedAlbum = true; } } assertTrue(foundRecentlyAdde... |
G3Client implements IG3Client { public List<Item> getAlbumAndSubAlbumsAndPictures(int albumId) throws G3GalleryException { List<Item> items = getTree(albumId, "photo,album"); return items; } G3Client(String galleryUrl, String userAgent); Item getItem(int itemId); int createItem(Entity entity, File file); void updateIte... | @Test public void getAlbumAndSubAlbumsAndPicturesTest() throws G3GalleryException { List<Item> albumAndSubAlbumsAndPictures = itemClient.getAlbumAndSubAlbumsAndPictures(172); Map<Integer,String> actual = new HashMap<Integer, String>(); for (Item album : albumAndSubAlbumsAndPictures) { actual.put(album.getEntity().getId... |
G3Client implements IG3Client { public List<Item> getPictures(int albumId) throws G3GalleryException { List<Item> items = new ArrayList<Item>(); getItems(albumId, items, "photo"); return items; } G3Client(String galleryUrl, String userAgent); Item getItem(int itemId); int createItem(Entity entity, File file); void upda... | @Test public void getPicturesTest() throws G3GalleryException { List<Item> pictures = itemClient.getPictures(11); pictures = itemClient.getPictures(172); for (Item picture : pictures) { if (!picture.getEntity().getType().equals("photo")) { fail("found some other types than photo"); } if (picture.getEntity().getResizeHe... |
G3Client implements IG3Client { public InputStream getPhotoInputStream(String url) throws G3GalleryException { InputStream content = null; String appendToGalleryUrl = url.substring(url.indexOf(galleryItemUrl)+galleryItemUrl.length()); try { content = requestToResponseEntity(appendToGalleryUrl, null, GET, null).getConte... | @Test public void getPhotoInputStream() throws IOException, G3GalleryException, MagicParseException, MagicMatchNotFoundException, MagicException { try { itemClient.getItem(createdPhotoId); }catch(G3ItemNotFoundException ex){ addPhoto(); } Item item1 = itemClient.getItem(createdPhotoId); String url = item1.getEntity().g... |
G3ConvertUtils { public static Album itemToAlbum(Item item) { if(item==null ||item.getEntity()==null){ return null; } Album album = new Album(); album.setId(item.getEntity().getId()); album.setName(item.getEntity().getId()); album.setTitle(item.getEntity().getTitle()); album.setSummary(item.getEntity().getDescription()... | @Test public void itemToAlbum() throws IOException, JSONException { URL resource = Resources.getResource("get-album-1.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); Item albumItem = ItemUtils.parseJSONToItem(jsonResult); A... |
G3ConvertUtils { public static Picture itemToPicture(Item item) { if(item==null ||item.getEntity()==null){ return null; } Picture picture = new Picture(); picture.setId(item.getEntity().getId()); picture.setTitle(item.getEntity().getTitle()); picture.setFileName(item.getEntity().getName()); picture.setThumbUrl(item.get... | @Test public void itemToPicture() throws IOException, JSONException { URL resource = Resources.getResource("get-photo-2.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); Item pictureItem = ItemUtils.parseJSONToItem(jsonResult... |
ItemUtils { public static List<Item> parseJSONToMultipleItems(JSONObject jsonResult) throws JSONException{ JSONArray entityArrayJSON = jsonResult.getJSONArray("entity"); List<Item> list = new ArrayList<Item>(); for (int i = 0; i < entityArrayJSON.length(); i++) { Item item = new Item(); item.setUrl(((JSONObject) entity... | @Test public void parseJSONToMultipleItems() throws IOException, JSONException { URL resource = Resources.getResource("tree-album-1.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); List<Item> items = ItemUtils.parseJSONToMul... |
ItemUtils { public static Item parseJSONToItem(JSONObject jsonResult) throws JSONException { logger.debug("parseJSONToItem jsonResult: {}",jsonResult); Item item = new Item(); item.setUrl(jsonResult.getString("url")); item.setEntity(parseJSONToEntity(jsonResult)); item.setRelationships(parseJSONToRelationShips(jsonResu... | @Test public void parseJSONTest__album() throws IOException, JSONException { URL resource = Resources.getResource("get-album-1.json"); String string = Resources.toString(resource, Charsets.UTF_8); JSONObject jsonResult = (JSONObject) new JSONTokener(string) .nextValue(); Item item = ItemUtils.parseJSONToItem(jsonResult... |
ItemUtils { public static String convertAlbumEntityToJSON(Entity entity) throws JSONException { JSONObject entityJSON = new JSONObject(); entityJSON.put("title", entity.getTitle()); entityJSON.put("type", "album"); entityJSON.put("name", entity.getName()); return entityJSON.toString(); } static Item parseJSONToItem(JS... | @Test public void convertAlbumEntityToJSON() throws JSONException{ Entity albumEntity = new Entity(); albumEntity.setTitle("This is my Sample Album"); albumEntity.setName("Sample Album"); String convertEntityToJSON = ItemUtils.convertAlbumEntityToJSON(albumEntity); assertTrue("invalid JSON", new JSONObject(convertEntit... |
ItemUtils { public static NameValuePair convertJSONStringToNameValuePair(String value) { NameValuePair nameValuePair = new BasicNameValuePair("entity", value); return nameValuePair; } static Item parseJSONToItem(JSONObject jsonResult); static List<Item> parseJSONToMultipleItems(JSONObject jsonResult); static String co... | @Test public void convertItemToNameValuePair(){ Item item = new Item(); Entity albumEntity = new Entity(); albumEntity.setTitle("New Album"); albumEntity.setName("AlbumName"); item.setEntity(albumEntity ); String value = "{\"title\":\"This is my Sample Album\",\"name\":\"Sample Album\",\"type\":\"album\"}"; BasicNameVa... |
ItemUtils { public static String convertJsonResultToApiKey(String jsonResult) { String apiKey; apiKey = jsonResult.replaceAll("\"", "").replaceAll("\n", ""); return apiKey; } static Item parseJSONToItem(JSONObject jsonResult); static List<Item> parseJSONToMultipleItems(JSONObject jsonResult); static String convertAlbu... | @Test public void convertJsonStringToApiKey() { String expectedKey = "e3450cdda082e6a2bddf5114a2bcc14d"; String jsonResult="\"e3450cdda082e6a2bddf5114a2bcc14d\n\""; String key = ItemUtils.convertJsonResultToApiKey(jsonResult); assertEquals(expectedKey, key); } |
ItemUtils { public static String convertJsonStringToUrl(String jsonResult) throws JSONException { JSONObject jsonObject = new JSONObject(jsonResult); return (String) jsonObject.get("url"); } static Item parseJSONToItem(JSONObject jsonResult); static List<Item> parseJSONToMultipleItems(JSONObject jsonResult); static St... | @Test public void convertJsonStringToUrl() throws JSONException{ String jsonResult="{\"url\":\"http:\\/\\/g3.dahanne.net\\/index.php\\/rest\\/item\\/34\"}"; String expectedString = "http: String urlString = ItemUtils.convertJsonStringToUrl(jsonResult); assertEquals(expectedString, urlString); } |
AlbumUtils { public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbu... | @Test public void findAlbumFromAlbumNameTest() { Album rootAlbum = new Album(); rootAlbum.setName(999); Album album1 = new Album(); album1.setName(1); rootAlbum.getSubAlbums().add(album1); Album album2 = new Album(); album2.setName(2); rootAlbum.getSubAlbums().add(album2); Album album3 = new Album(); album3.setName(3);... |
G2Client { public HashMap<String, String> fetchImages(String galleryUrl, int albumName) throws GalleryConnectionException { List<NameValuePair> nameValuePairsFetchImages = new ArrayList<NameValuePair>(); nameValuePairsFetchImages.add(FETCH_ALBUMS_IMAGES_CMD_NAME_VALUE_PAIR); nameValuePairsFetchImages.add(new BasicNameV... | @Test public void fetchImagesTest() throws GalleryConnectionException { HashMap<String, String> fetchImages = g2ConnectionUtils.fetchImages( galleryUrl, 11); assertTrue("no pictures found",fetchImages.size() != 0); assertTrue("the string image_count could not be found",fetchImages.containsKey("image_count")); assertFal... |
InRepaymentCardViewEntityMapper implements Function<CreditDraft, InRepaymentCardViewEntity> { @NonNull public InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft) throws Exception { assertCorrectStatus(draft.status()); final CreditRepaymentInfo repaymentInfo = orThrowUnsafe(draft.creditRepaymentInfo(), new... | @Test public void mapDraft() throws Exception { new ArrangeBuilder().withStringFromProvider("something") .withSubstitutionStringFromProvider("other something") .withFormattedDate("Some date") .withFormattedCurrency("500,00"); CreditDraft draft = CreditDataTestUtils.creditDraftTestBuilder() .id("10") .purpose("Electroni... |
CreditDashboardViewModel extends ViewModel { @NonNull LiveData<List<DisplayableItem>> getCreditListLiveData() { return creditListLiveData; } @Inject CreditDashboardViewModel(@NonNull final RetrieveCreditDraftList retrieveCreditDraftList,
@NonNull final CreditDisplayableItemMapper creditDis... | @Test public void displayableItemsGoIntoLiveDataWhenInteractorEmitsCreditDrafts() throws Exception { List<DisplayableItem> displayableItems = Collections.singletonList(Mockito.mock(DisplayableItem.class)); List<CreditDraft> creditDrafts = Collections.singletonList(Mockito.mock(CreditDraft.class)); arrangeBuilder.withMa... |
CreditDisplayableItemMapper implements Function<List<CreditDraft>, List<DisplayableItem>> { @Override public List<DisplayableItem> apply(@NonNull final List<CreditDraft> creditDrafts) throws Exception { return Observable.fromIterable(creditDrafts) .map(inRepaymentCardViewEntityMapper) .map(this::wrapInDisplayableItem) ... | @Test public void creditDraftsAreMappedToViewEntities() throws Exception { CreditDraft creditDraft = Mockito.mock(CreditDraft.class); new ArrangeBuilder().withMappedViewEntity(Mockito.mock(InRepaymentCardViewEntity.class)); displayableItemMapper.apply(Collections.singletonList(creditDraft)); Mockito.verify(viewEntityMa... |
CreditDraftMapper implements Function<CreditDraftRaw, CreditDraft> { @Override @SuppressWarnings("ConstantConditions") public CreditDraft apply(@NonNull final CreditDraftRaw raw) throws Exception { assertEssentialParams(raw); return CreditDraft.builder() .id(raw.id()) .purpose(raw.purposeName()) .amount(raw.amount()) .... | @Test public void essentialParamMissingExceptionIsThrownWhenTheMandatoryParamsAreMissing() throws Exception { thrown.expect(EssentialParamMissingException.class); thrown.expectMessage("status id purpose imageUrl"); mapper.apply(CreditDataTestUtils.creditDraftRawTestBuilder() .status(null) .id(null) .purposeName(null) .... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.