method2testcases
stringlengths
118
6.63k
### Question: Merlin { public void bind() { merlinServiceBinder.bindService(); } Merlin(MerlinServiceBinder merlinServiceBinder, Registrar registrar); void setEndpoint(Endpoint endpoint, ResponseCodeValidator validator); void bind(); void unbind(); void registerConnectable(Connectable connectable); void registerDisconn...
### Question: Merlin { public void unbind() { merlinServiceBinder.unbind(); registrar.clearRegistrations(); } Merlin(MerlinServiceBinder merlinServiceBinder, Registrar registrar); void setEndpoint(Endpoint endpoint, ResponseCodeValidator validator); void bind(); void unbind(); void registerConnectable(Connectable conne...
### Question: Merlin { public void registerConnectable(Connectable connectable) { registrar.registerConnectable(connectable); } Merlin(MerlinServiceBinder merlinServiceBinder, Registrar registrar); void setEndpoint(Endpoint endpoint, ResponseCodeValidator validator); void bind(); void unbind(); void registerConnectable...
### Question: Merlin { public void registerDisconnectable(Disconnectable disconnectable) { registrar.registerDisconnectable(disconnectable); } Merlin(MerlinServiceBinder merlinServiceBinder, Registrar registrar); void setEndpoint(Endpoint endpoint, ResponseCodeValidator validator); void bind(); void unbind(); void regi...
### Question: Merlin { public void registerBindable(Bindable bindable) { registrar.registerBindable(bindable); } Merlin(MerlinServiceBinder merlinServiceBinder, Registrar registrar); void setEndpoint(Endpoint endpoint, ResponseCodeValidator validator); void bind(); void unbind(); void registerConnectable(Connectable co...
### Question: ConnectivityChangeEventExtractor { ConnectivityChangeEvent extractFrom(Network network) { NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network); if (null != networkInfo) { boolean connected = networkInfo.isConnected(); String reason = networkInfo.getReason(); String extraInfo = networkInfo...
### Question: EndpointPinger { void ping(PingerCallback pingerCallback) { PingTask pingTask = pingTaskFactory.create(endpoint, pingerCallback); pingTask.execute(); } EndpointPinger(Endpoint endpoint, PingTaskFactory pingTaskFactory); }### Answer: @Test public void whenPinging_thenCreatesPingTask() { endpointPinger.pi...
### Question: EndpointPinger { void noNetworkToPing(PingerCallback pingerCallback) { pingerCallback.onFailure(); } EndpointPinger(Endpoint endpoint, PingTaskFactory pingTaskFactory); }### Answer: @Test public void whenNoNetworkToPing_thenCallsOnFailure() { endpointPinger.noNetworkToPing(pingerCallback); verify(pinger...
### Question: ConnectivityReceiverConnectivityChangeNotifier { void notify(Context context, Intent intent) { if (intent != null && connectivityActionMatchesActionFor(intent)) { MerlinsBeard merlinsBeard = merlinsBeardCreator.createMerlinsBeard(context); ConnectivityChangeEvent connectivityChangeEvent = creator.createFr...
### Question: Registrar { void registerConnectable(Connectable connectable) { connectables().register(connectable); } Registrar(Register<Connectable> connectables, Register<Disconnectable> disconnectables, Register<Bindable> bindables); }### Answer: @Test(expected = IllegalStateException.class) public void givenMissi...
### Question: ConnectivityChangesRegister { void register(MerlinService.ConnectivityChangesNotifier connectivityChangesNotifier) { if (androidVersion.isLollipopOrHigher()) { registerNetworkCallbacks(connectivityChangesNotifier); } else { registerBroadcastReceiver(); } } ConnectivityChangesRegister(Context context, ...
### Question: ConnectivityChangesRegister { void unregister() { if (androidVersion.isLollipopOrHigher()) { unregisterNetworkCallbacks(); } else { unregisterBroadcastReceiver(); } } ConnectivityChangesRegister(Context context, ConnectivityManager connectivityManager, ...
### Question: BindCallbackManager extends MerlinCallbackManager<Bindable> { void onMerlinBind(NetworkStatus networkStatus) { Logger.d("onBind"); for (Bindable bindable : registerables()) { bindable.onBind(networkStatus); } } BindCallbackManager(Register<Bindable> register); }### Answer: @Test public void givenRegiste...
### Question: ConnectivityChangesForwarder { void forwardInitialNetworkStatus() { if (bindCallbackManager == null) { return; } if (hasPerformedEndpointPing()) { bindCallbackManager.onMerlinBind(lastEndpointPingNetworkStatus); return; } bindCallbackManager.onMerlinBind(networkStatusRetriever.retrieveNetworkStatus()); } ...
### Question: Registrar { void registerDisconnectable(Disconnectable disconnectable) { disconnectables().register(disconnectable); } Registrar(Register<Connectable> connectables, Register<Disconnectable> disconnectables, Register<Bindable> bindables); }### Answer: @Test(expected = IllegalStateException.class) public ...
### Question: ConnectivityChangesForwarder { void forward(ConnectivityChangeEvent connectivityChangeEvent) { if (matchesPreviousEndpointPingNetworkStatus(connectivityChangeEvent)) { return; } networkStatusRetriever.fetchWithPing(endpointPinger, endpointPingerCallback); lastEndpointPingNetworkStatus = connectivityChange...
### Question: ConnectivityReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { connectivityReceiverConnectivityChangeNotifier.notify(context, intent); } ConnectivityReceiver(); ConnectivityReceiver(ConnectivityReceiverConnectivityChangeNotifier connectivityReceiverCon...
### Question: NetworkStatusRetriever { void fetchWithPing(EndpointPinger endpointPinger, EndpointPinger.PingerCallback pingerCallback) { if (merlinsBeard.isConnected()) { endpointPinger.ping(pingerCallback); } else { endpointPinger.noNetworkToPing(pingerCallback); } } NetworkStatusRetriever(MerlinsBeard merlinsBeard); ...
### Question: NetworkStatusRetriever { NetworkStatus retrieveNetworkStatus() { if (merlinsBeard.isConnected()) { return NetworkStatus.newAvailableInstance(); } else { return NetworkStatus.newUnavailableInstance(); } } NetworkStatusRetriever(MerlinsBeard merlinsBeard); }### Answer: @Test public void givenMerlinsBeardI...
### Question: Registrar { void registerBindable(Bindable bindable) { bindables().register(bindable); } Registrar(Register<Connectable> connectables, Register<Disconnectable> disconnectables, Register<Bindable> bindables); }### Answer: @Test(expected = IllegalStateException.class) public void givenMissingRegister_when...
### Question: MerlinsBeard { public boolean isConnected() { NetworkInfo activeNetworkInfo = networkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); } MerlinsBeard(ConnectivityManager connectivityManager, AndroidVersion androidVersion, EndpointPinger captivePortalPinger, Ping CaptivePortalPin...
### Question: MerlinsBeard { public boolean isConnectedToWifi() { return isConnectedTo(ConnectivityManager.TYPE_WIFI); } MerlinsBeard(ConnectivityManager connectivityManager, AndroidVersion androidVersion, EndpointPinger captivePortalPinger, Ping CaptivePortalPing); @Deprecated static MerlinsBeard from(Context context)...
### Question: MerlinsBeard { public boolean isConnectedToMobileNetwork() { return isConnectedTo(ConnectivityManager.TYPE_MOBILE); } MerlinsBeard(ConnectivityManager connectivityManager, AndroidVersion androidVersion, EndpointPinger captivePortalPinger, Ping CaptivePortalPing); @Deprecated static MerlinsBeard from(Conte...
### Question: MerlinsBeard { public void hasInternetAccess(final InternetAccessCallback callback) { captivePortalPinger.ping(new EndpointPinger.PingerCallback() { @Override public void onSuccess() { callback.onResult(true); } @Override public void onFailure() { callback.onResult(false); } }); } MerlinsBeard(Connectivit...
### Question: DisconnectCallbackManager extends MerlinCallbackManager<Disconnectable> implements Disconnectable { @Override public void onDisconnect() { Logger.d("onDisconnect"); for (Disconnectable disconnectable : registerables()) { disconnectable.onDisconnect(); } } DisconnectCallbackManager(Register<Disconnectable>...
### Question: ConnectivityChangeEventCreator { ConnectivityChangeEvent createFrom(Intent intent, MerlinsBeard merlinsBeard) { boolean isConnected = extractIsConnectedFrom(intent, merlinsBeard); String info = intent.getStringExtra(ConnectivityManager.EXTRA_EXTRA_INFO); String reason = intent.getStringExtra(ConnectivityM...
### Question: ConnectCallbackManager extends MerlinCallbackManager<Connectable> { void onConnect() { Logger.d("onConnect"); for (Connectable connectable : registerables()) { connectable.onConnect(); } } ConnectCallbackManager(Register<Connectable> register); }### Answer: @Test public void givenRegisteredConnectable_w...
### Question: MerlinService extends Service { public static boolean isBound() { return isBound; } static boolean isBound(); @Override IBinder onBind(Intent intent); @Override boolean onUnbind(Intent intent); }### Answer: @Test public void givenOnBindHasBeenCalled_whenCheckingIsBound_thenReturnsTrue() { givenBoundMerl...
### Question: MerlinService extends Service { @Override public boolean onUnbind(Intent intent) { isBound = false; if (connectivityChangesRegister != null) { connectivityChangesRegister.unregister(); connectivityChangesRegister = null; } if (connectivityChangesForwarder != null) { connectivityChangesForwarder = null; } ...
### Question: MerlinService extends Service { @Override public IBinder onBind(Intent intent) { isBound = true; return binder; } static boolean isBound(); @Override IBinder onBind(Intent intent); @Override boolean onUnbind(Intent intent); }### Answer: @Test public void givenConnectivityChangesRegisterIsNotBound_whenBi...
### Question: ConnectivityCallbacks extends ConnectivityManager.NetworkCallback { @Override public void onAvailable(Network network) { notifyMerlinService(network); } ConnectivityCallbacks(MerlinService.ConnectivityChangesNotifier connectivityChangesNotifier, ConnectivityChangeEventExtractor c...
### Question: ConnectivityCallbacks extends ConnectivityManager.NetworkCallback { @Override public void onLosing(Network network, int maxMsToLive) { notifyMerlinService(network); } ConnectivityCallbacks(MerlinService.ConnectivityChangesNotifier connectivityChangesNotifier, ConnectivityChangeEv...
### Question: ConnectivityCallbacks extends ConnectivityManager.NetworkCallback { @Override public void onLost(Network network) { notifyMerlinService(network); } ConnectivityCallbacks(MerlinService.ConnectivityChangesNotifier connectivityChangesNotifier, ConnectivityChangeEventExtractor connec...
### Question: MerlinObservable { public static Observable<NetworkStatus> from(Context context) { return from(context, new Merlin.Builder()); } static Observable<NetworkStatus> from(Context context); static Observable<NetworkStatus> from(Context context, MerlinBuilder merlinBuilder); static Observable<NetworkStatus> fr...
### Question: OktaManagementActivity extends Activity { static PendingIntent createStartIntent( Context context, PendingIntent completeIntent, PendingIntent cancelIntent) { Intent tokenExchangeIntent = new Intent(context, OktaManagementActivity.class); tokenExchangeIntent.putExtra(KEY_COMPLETE_INTENT, completeIntent); ...
### Question: AuthStateManager { @AnyThread @NonNull @VisibleForTesting AuthState readState() { mPrefsLock.lock(); try { String currentState = mPrefs.getString(KEY_STATE, null); if (currentState == null) { return new AuthState(); } try { return AuthState.jsonDeserialize(currentState); } catch (JSONException ex) { Log.w...
### Question: AuthStateManager { @AnyThread @VisibleForTesting void writeState(@Nullable AuthState state) { mPrefsLock.lock(); try { SharedPreferences.Editor editor = mPrefs.edit(); if (state == null) { editor.remove(KEY_STATE); } else { editor.putString(KEY_STATE, state.jsonSerializeString()); } if (!editor.commit()) ...
### Question: OktaAppAuth { public void refreshAccessToken(final OktaAuthListener listener) { if (!hasRefreshToken()) { Log.d(TAG, "Calling refreshAccessToken without a refresh token"); listener.onTokenFailure(AuthorizationException.TokenRequestErrors.INVALID_REQUEST); return; } ClientAuthentication clientAuthenticatio...
### Question: OktaAppAuth { public void signOutFromOkta( final Context context, final PendingIntent completionIntent, final PendingIntent cancelIntent ) { if (!isUserLoggedIn()) { throw new IllegalStateException("No logged in user found"); } mExecutor.submit(new Runnable() { @Override public void run() { doEndSession( ...
### Question: OktaAppAuth { public Tokens getTokens() { return Tokens.fromAuthState(mAuthStateManager.getCurrent()); } @AnyThread protected OktaAppAuth(Context context); @AnyThread static OktaAppAuth getInstance(@NonNull Context context); @AnyThread void init( final Context context, final OktaA...
### Question: SessionAuthenticationService { void performAuthorizationRequest( AuthorizationRequest request, String sessionToken, @Nullable OktaAppAuth.OktaNativeAuthListener listener) { if (sessionToken == null) { if (listener != null) { listener.onTokenFailure(AuthenticationError.createAuthenticationError( Authentica...
### Question: OAuthClientConfiguration { public String getClientId() { return mClientId; } @VisibleForTesting OAuthClientConfiguration( final Context context, final SharedPreferences prefs, final InputStream configurationStream); @AnyThread static OAuthClientConfiguration getInstanc...
### Question: OAuthClientConfiguration { public Uri getRedirectUri() { return mRedirectUri; } @VisibleForTesting OAuthClientConfiguration( final Context context, final SharedPreferences prefs, final InputStream configurationStream); @AnyThread static OAuthClientConfiguration getInst...
### Question: OAuthClientConfiguration { public Uri getDiscoveryUri() { return mDiscoveryUri; } @VisibleForTesting OAuthClientConfiguration( final Context context, final SharedPreferences prefs, final InputStream configurationStream); @AnyThread static OAuthClientConfiguration getIn...
### Question: OAuthClientConfiguration { public Set<String> getScopes() { return mScopes; } @VisibleForTesting OAuthClientConfiguration( final Context context, final SharedPreferences prefs, final InputStream configurationStream); @AnyThread static OAuthClientConfiguration getInstan...
### Question: AuthStateManager { @AnyThread @NonNull public AuthState getCurrent() { if (mCurrentAuthState.get() != null) { return mCurrentAuthState.get(); } AuthState state = readState(); if (mCurrentAuthState.compareAndSet(null, state)) { return state; } else { return mCurrentAuthState.get(); } } @VisibleForTesting ...
### Question: GesturePane extends Control implements GesturePaneOps { public void setScrollBarPolicy(ScrollBarPolicy policy) { setHbarPolicy(policy); setVbarPolicy(policy); } GesturePane(Transformable target); GesturePane(Node target); GesturePane(); @Override String getUserAgentStylesheet(); Point2D viewportCentre()...
### Question: GesturePane extends Control implements GesturePaneOps { public Point2D viewportCentre() { return new Point2D(getViewportWidth() / 2, getViewportHeight() / 2); } GesturePane(Transformable target); GesturePane(Node target); GesturePane(); @Override String getUserAgentStylesheet(); Point2D viewportCentre()...
### Question: GesturePane extends Control implements GesturePaneOps { public Point2D targetPointAtViewportCentre() { try { return affine.inverseTransform(viewportCentre()); } catch (NonInvertibleTransformException e) { throw new RuntimeException(e); } } GesturePane(Transformable target); GesturePane(Node target); Ges...
### Question: GesturePane extends Control implements GesturePaneOps { final void scale(double factor, Point2D origin) { scale(factor, factor, origin); } GesturePane(Transformable target); GesturePane(Node target); GesturePane(); @Override String getUserAgentStylesheet(); Point2D viewportCentre(); Point2D targetPointA...
### Question: GesturePane extends Control implements GesturePaneOps { public double getCurrentScale() { return scaleX.get(); } GesturePane(Transformable target); GesturePane(Node target); GesturePane(); @Override String getUserAgentStylesheet(); Point2D viewportCentre(); Point2D targetPointAtViewportCentre(); Optiona...
### Question: ParentDirectoryAuthorScoreStrategy implements ScoreStrategy<AuthorScore> { @NotNull @Override public AuthorScore score(BookImportContext context) { try { File file = context.getFile(); String dirName = file.getParentFile().getName(); String[] rawTokens = splitAuthorPairTokens(dirName); String[] tokens = t...
### Question: FileNameAuthorScoreStrategy implements ScoreStrategy<AuthorScore> { private Author extractAuthorFromFileName(String fileName) { Assert.isTrue(fileName.contains(SEPARATOR), "Format in " + fileName + " not understood, doesn't contain separator"); String authorIncludingSpecialCharacters = extractAuthorPart(f...
### Question: FileNameAuthorScoreStrategy implements ScoreStrategy<AuthorScore> { @NotNull @Override public AuthorScore score(BookImportContext context) { return new AuthorScore(getAuthors(context.getFile()), FileNameAuthorScoreStrategy.class); } @NotNull @Override AuthorScore score(BookImportContext context); static ...
### Question: MetaDataAuthorScoreStrategy implements ScoreStrategy<AuthorScore> { @NotNull @Override public AuthorScore score(BookImportContext context) { try { List<nl.siegmann.epublib.domain.Author> epubAuthors = context.getEpubBook().getMetadata().getAuthors(); AuthorScore categorizerScore = getAuthorScoreUsingCateg...
### Question: MetaDataIsbn13ScoreStrategy implements ScoreStrategy<Isbn13Score> { @NotNull @Override public Isbn13Score score(BookImportContext context) { Book epubBook = context.getEpubBook(); Metadata metadata = epubBook.getMetadata(); Isbn13Score isbn13UsingScheme = getIsbn13(metadata); if(isbn13UsingScheme == null)...
### Question: MetaDataIsbn10ScoreStrategy implements ScoreStrategy<Isbn10Score> { @NotNull @Override public Isbn10Score score(BookImportContext context) { Book epubBook = context.getEpubBook(); Metadata metadata = epubBook.getMetadata(); Isbn10Score isbn10UsingScheme = getIsbn10(metadata); if (isbn10UsingScheme == null...
### Question: BookProducer { public Book produce(BookImportContext context) throws IOException { Book book = new Book(); book.setAuthors(new AuthorScorer().determineBestScore(context).getValue()); book.setSource("import"); book.setTitle(new TitleScorer().determineBestScore(context).getValue()); book.setLanguage((new La...
### Question: Response { public int getCode() { return code; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }### Answer: @Test public void getCode() throws Exception { }
### Question: BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPreExecute() { super.onPreExecute(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<Bitmap> callback); }### Answer: @Test public void onPreExecute() th...
### Question: BitMapTask extends Task<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); Bitmap bitmap = response.getAsBitmap(); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null)...
### Question: BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onPostExecute(Bitmap data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> ...
### Question: BitMapTask extends Task<String, Void, Bitmap> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } BitMapTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, Ht...
### Question: JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONArray> callback); }### Answer: @Test public void onPre...
### Question: JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected JSONArray doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONArray json = new JSONArray(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.ge...
### Question: JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onPostExecute(JSONArray data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<He...
### Question: JsonArrayTask extends Task<String, Void, JSONArray> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonArrayTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> he...
### Question: RequestParams { public String getKey() { return key; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }### Answer: @Test public void getKey() throws Exception { }
### Question: RequestParams { public RequestParams setKey(String key) { this.key = key; return this; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }### Answer: @Test public void setKey() throws Exception { }
### Question: Response { public Response setCode(int code) { this.code = code; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }### Answer: @Test public void setCode() throws Exception { }
### Question: RequestParams { public String getValue() { return value; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }### Answer: @Test public void getValue() throws Exception { }
### Question: RequestParams { public RequestParams setValue(String value) { this.value = value; return this; } String getKey(); RequestParams setKey(String key); String getValue(); RequestParams setValue(String value); }### Answer: @Test public void setValue() throws Exception { }
### Question: HeaderParams { public String getKey() { return key; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }### Answer: @Test public void getKey() throws Exception { }
### Question: HeaderParams { public HeaderParams setKey(String key) { this.key = key; return this; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }### Answer: @Test public void setKey() throws Exception { }
### Question: HeaderParams { public String getValue() { return value; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }### Answer: @Test public void getValue() throws Exception { }
### Question: HeaderParams { public HeaderParams setValue(String value) { this.value = value; return this; } String getKey(); HeaderParams setKey(String key); String getValue(); HeaderParams setValue(String value); }### Answer: @Test public void setValue() throws Exception { }
### Question: CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override protected int sizeOf(String key, T data) { int bytesCount; if (data instanceof Bitmap) { bytesCount = ((Bitmap) data).getByteCount(); } else if (data instanceof JSONObject) { bytesCount = ((JSONObject) data).toString(...
### Question: CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void addDataToCache(String key, T data) { if (getDataFromCache(key) == null) { synchronized (this) { put(key, data); cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); } } } CacheManager(int cacheSize); @O...
### Question: CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void removeDataFromCache(String key) { if (getDataFromCache(key) != null) { synchronized (this) { remove(key); } } } CacheManager(int cacheSize); @Override void addDataToCache(String key, T data); @Override voi...
### Question: CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public T getDataFromCache(String key) { synchronized (this) { cacheHitTimestamp.put(key, SystemClock.uptimeMillis()); evictUnused(); } return get(key); } CacheManager(int cacheSize); @Override void addDataToCache(Stri...
### Question: Response { public InputStream getData() { return inputStream; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }### Answer: @Test public void getData() throws Exception { }
### Question: CacheManager extends LruCache<String, T> implements CacheManagerInterface<T> { @Override public void evictUnused() { Map<String, T> items = snapshot(); for (String key : items.keySet()) { long cacheTime = cacheHitTimestamp.get(key); if (cacheTime + timeout < SystemClock.uptimeMillis()) { remove(key); } } ...
### Question: JsonArray extends Type<JSONArray> { public JsonArray setCallback(HttpListener<JSONArray> listener) { this.mListener = listener; this.mListener.onRequest(); JSONArray data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; ...
### Question: JsonArray extends Type<JSONArray> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> hea...
### Question: JsonArray extends Type<JSONArray> { public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> l...
### Question: BitMap extends Type<Bitmap> { public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = n...
### Question: BitMap extends Type<Bitmap> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); Bit...
### Question: BitMap extends Type<Bitmap> { public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean can...
### Question: Type { public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }### Answer: @Test public void setCacheManager() throws Exception { }
### Question: Type { public abstract Type setCallback(HttpListener<T> callback); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }### Answer: @Test public void setCallback() throws Exception { }
### Question: Type { public abstract boolean cancel(); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); }### Answer: @Test public void cancel() throws Exception { }
### Question: Response { public Response setData(InputStream data) { this.inputStream = data; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); }### Answer: @Test public void setData() throws Exception {...
### Question: JsonObject extends Type<JSONObject> { public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; ...
### Question: JsonObject extends Type<JSONObject> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> ...
### Question: JsonObject extends Type<JSONObject> { public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONOb...
### Question: Response { public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0...
### Question: Response { public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; } int getCode(); Response setCode(int code); InputStream getData(); Response setDa...
### Question: JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); }### Answer: @Test public void o...
### Question: JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManag...
### Question: JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayLis...