method2testcases
stringlengths
118
6.63k
### 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 Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(...
### 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: 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(directio...
### 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: 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 Basic...
### Question: 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,...
### Question: 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...
### Question: 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()...
### 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: 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){ r...
### 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 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 Ba...
### 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: 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, ...
### 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: 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.setThu...
### 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: 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 : rootAl...
### Question: 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(...
### 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...