method2testcases
stringlengths
118
3.08k
### Question: FilterTrack extends Track implements TileableListener { public MarbleType getMarbleType() { return marbleType; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Overrid...
### Question: FilterTrack extends Track implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnect...
### Question: OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction dir...
### Question: OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Over...
### Question: OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); ...
### Question: OneWayTrack extends Track { public Track getTrack() { return this.track; } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boole...
### Question: OneWayTrack extends Track { public Direction getDirection() { return direction; } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Overrid...
### Question: Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); }### Answer: @Test public void createPinkBall() { Marble marble = new Marble(MarbleType.PINK); assertThat(marble.getType()).isEqualTo(MarbleType.PINK)...
### Question: Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); }### Answer: @Test public ...
### Question: Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); }### Answer: ...
### Question: Empty extends Tileable { @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @...
### Question: SpawningNexus extends Nexus { public Direction getDirection() { return direction; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; }### Answer: @Test ...
### Question: 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 getC...
### Question: 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); NexusConte...
### Question: 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(); }### Answer: @Test public void getContext() ...
### Question: 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); }### Answer: @Test public void testWonFalse() { assertT...
### Question: HardLevelTwo extends AbstractHardLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(2); }
### Question: HardLevelOne extends AbstractHardLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); }
### Question: 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); }### Answer: @Test public void c...
### Question: HardLevelThree extends AbstractHardLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); }
### Question: EasyLevelTwo extends AbstractEasyLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(2); }
### Question: EasyLevelOne extends AbstractEasyLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); }
### Question: 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); }### Answer: @Test public void c...
### Question: EasyLevelThree extends AbstractEasyLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); }
### Question: LevelFactory { public abstract Level create(int level); abstract Level create(int level); }### Answer: @Test public void getFirst() { assertThat(factory.create(1)).isNotNull(); } @Test public void getSecond() { assertThat(factory.create(2)).isNotNull(); } @Test public void getThird() { assertThat(factor...
### Question: MediumLevelThree extends AbstractMediumLevel { @Override public int getIndex() { return 3; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(3); }
### Question: MediumLevelOne extends AbstractMediumLevel { @Override public int getIndex() { return 1; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(1); }
### Question: 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); }### Answer: @Test p...
### Question: MediumLevelTwo extends AbstractMediumLevel { @Override public int getIndex() { return 2; } @Override GameSession create(Configuration config); @Override int getIndex(); }### Answer: @Test public void getIndex() { assertThat(level.getIndex()).isEqualTo(2); }
### Question: 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(); }### Answer: @Test public void isOccupied() { assertThat(gr...
### Question: 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...
### Question: 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(); }### Answer: @Test public void getGridTest() { assertThat(grid.get(0,0).getGrid()).isEqualTo(gri...
### Question: 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 onG...
### Question: 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 ...
### Question: 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); }### Answer: @Test p...
### Question: Tileable implements Entity { public boolean isConnected(Direction direction) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } else if (!allowsConnection(direction)) { return false; } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().allows...
### Question: 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); } abstra...
### Question: 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...
### Question: 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 i...
### Question: 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 isReleasabl...
### Question: 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 dire...
### Question: 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 is...
### Question: 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); bool...
### Question: 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, Marbl...
### Question: 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 ma...
### Question: 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 ma...
### Question: 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<?> ...
### Question: 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)); } @Overri...
### Question: DesktopLauncher implements Runnable { public static void main(String[] args) { getInstance().run(); } private DesktopLauncher(); static DesktopLauncher getInstance(); static void main(String[] args); @Override void run(); }### Answer: @Test public void smokeTest() { assertThatCode(() -> { DesktopLaunche...
### Question: 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(); }### Answer: @Test public void testPlay() { Music theme ...
### Question: 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);...
### Question: 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 Ve...
### Question: 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); }### Answer: @Test pu...
### Question: 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 vo...
### Question: 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(child...
### Question: 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++) {...
### Question: 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); }### Answer: @Test public voi...
### Question: 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("unchecke...
### Question: 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); }### Answer: @Test publ...
### Question: 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); }### Answer: @Test public void pop() { stag...
### Question: 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...
### Question: 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(); PowerU...
### Question: 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 power...
### Question: 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(D...
### Question: 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 isReleasabl...
### Question: 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 un...
### Question: 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(); PowerU...
### Question: 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 ...
### Question: 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(); Sl...
### Question: 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...
### Question: RandomPowerUpFactory extends PowerUpFactory { @Override public PowerUp create() { return cdf.floorEntry(random.nextDouble()).getValue().create(); } RandomPowerUpFactory(Random random, NavigableMap<Double, PowerUpFactory> cdf); @Override PowerUp create(); }### Answer: @Test public void createA() { Navigab...
### Question: BonusPowerUp implements PowerUp { @Override public void activate(Receptor receptor) { receptor.getTile().getGrid().getSession().getProgress().score(100); } @Override void activate(Receptor receptor); }### Answer: @Test public void activate() { receptor.setPowerUp(powerUp); for (Direction direction : Dir...
### Question: 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); }### Answer: @Test public void activate...
### Question: 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 allo...
### Question: 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...
### Question: 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(Direct...
### Question: 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 boole...
### Question: 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...
### Question: 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.getPar...
### Question: 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.setParen...
### Question: 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(...
### Question: 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(...
### Question: 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 = sen...
### Question: 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 itemI...
### Question: 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); ...
### Question: 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 fi...
### Question: 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().ge...
### Question: 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(((JSON...
### Question: 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 pars...
### Question: 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); st...
### Question: 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 Stri...
### Question: 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 jsonResu...
### Question: CreditDashboardViewModel extends ViewModel { @NonNull LiveData<List<DisplayableItem>> getCreditListLiveData() { return creditListLiveData; } @Inject CreditDashboardViewModel(@NonNull final RetrieveCreditDraftList retrieveCreditDraftList, @NonNull final CreditDisplayableItemMa...
### Question: 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::wrapInDis...
### Question: CreditRepository { @NonNull public Observable<Option<List<CreditDraft>>> getAllCreditDrafts() { return store.getAll(); } @Inject CreditRepository(@NonNull final ReactiveStore<String, CreditDraft> store, @NonNull final CreditService creditService, @NonNull final C...
### Question: CreditRepository { @NonNull public Completable fetchCreditDrafts() { return creditService.getCreditDrafts() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .flatMapObservable(Observable::fromIterable) .map(creditDraftMapper) .toList() .doOnSuccess(store::replaceAll) .toCompletable(); } ...
### Question: CreditRepaymentInfoMapper { @NonNull @SuppressWarnings("ConstantConditions") static CreditRepaymentInfo processRaw(@NonNull final CreditRepaymentInfoRaw raw) { assertEssentialParams(raw); return CreditRepaymentInfo.builder() .disbursedDate(raw.disbursedDate()) .nextPaymentDate(raw.nextPaymentDate()) .next...
### Question: RetrieveCreditDraftList implements RetrieveInteractor<Void, List<CreditDraft>> { @NonNull @Override public Observable<List<CreditDraft>> getBehaviorStream(@NonNull final Option<Void> params) { return creditRepository.getAllCreditDrafts() .flatMapSingle(this::fetchWhenNoneAndThenDrafts) .compose(UnwrapOpti...
### Question: MemoryReactiveStore implements ReactiveStore<Key, Value> { public void storeSingular(@NonNull final Value model) { final Key key = extractKeyFromModel.call(model); cache.putSingular(model); getOrCreateSubjectForKey(key).onNext(ofObj(model)); final Option<List<Value>> allValues = cache.getAll().map(Option:...
### Question: MemoryReactiveStore implements ReactiveStore<Key, Value> { public void storeAll(@NonNull final List<Value> modelList) { cache.putAll(modelList); allSubject.onNext(ofObj(modelList)); publishInEachKey(); } MemoryReactiveStore(@NonNull final Func1<Value, Key> extractKeyFromModel, ...