The following issues were found
picasso/src/oldTests/java/com/squareup/picasso3/BitmapHunterTest.java
456 issues
Line: 981
@Test public void crashingOnTransformationThrows() {
Transformation badTransformation = new Transformation() {
@Override public RequestHandler.Result transform(RequestHandler.Result source) {
throw new NullPointerException("hello");
}
@Override public String key() {
return "test";
}
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Matrix;
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Matrix;
Reported by PMD.
Line: 100
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
Reported by PMD.
Line: 100
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
Reported by PMD.
Line: 100
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
Reported by PMD.
Line: 100
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
Reported by PMD.
Line: 102
@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
@Mock Dispatcher dispatcher;
Reported by PMD.
Line: 103
public final class BitmapHunterTest {
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
@Mock Dispatcher dispatcher;
final Bitmap bitmap = makeBitmap();
Reported by PMD.
Line: 104
@Mock Context context;
@Mock Picasso picasso;
final PlatformLruCache cache = new PlatformLruCache(2048);
final Stats stats = new Stats(cache);
@Mock Dispatcher dispatcher;
final Bitmap bitmap = makeBitmap();
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/RequestCreatorTest.java
222 issues
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.app.Notification;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.app.Notification;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
Reported by PMD.
Line: 78
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
public class RequestCreatorTest {
@Mock Picasso picasso;
@Captor ArgumentCaptor<Action> actionCaptor;
final Bitmap bitmap = makeBitmap();
Reported by PMD.
Line: 78
import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricTestRunner.class)
public class RequestCreatorTest {
@Mock Picasso picasso;
@Captor ArgumentCaptor<Action> actionCaptor;
final Bitmap bitmap = makeBitmap();
Reported by PMD.
Line: 80
@RunWith(RobolectricTestRunner.class)
public class RequestCreatorTest {
@Mock Picasso picasso;
@Captor ArgumentCaptor<Action> actionCaptor;
final Bitmap bitmap = makeBitmap();
@Before public void shutUp() {
Reported by PMD.
Line: 81
public class RequestCreatorTest {
@Mock Picasso picasso;
@Captor ArgumentCaptor<Action> actionCaptor;
final Bitmap bitmap = makeBitmap();
@Before public void shutUp() {
initMocks(this);
Reported by PMD.
Line: 83
@Mock Picasso picasso;
@Captor ArgumentCaptor<Action> actionCaptor;
final Bitmap bitmap = makeBitmap();
@Before public void shutUp() {
initMocks(this);
when(picasso.transformRequest(any(Request.class))).thenAnswer(TRANSFORM_REQUEST_ANSWER);
}
Reported by PMD.
Line: 87
@Before public void shutUp() {
initMocks(this);
when(picasso.transformRequest(any(Request.class))).thenAnswer(TRANSFORM_REQUEST_ANSWER);
}
@Test
public void getOnMainCrashes() throws IOException {
try {
Reported by PMD.
Line: 94
public void getOnMainCrashes() throws IOException {
try {
new RequestCreator(picasso, URI_1, 0).get();
fail("Calling get() on main thread should throw exception");
} catch (IllegalStateException ignored) {
}
}
@Test public void loadWithShutdownCrashes() {
Reported by PMD.
Line: 103
picasso.shutdown = true;
try {
new RequestCreator(picasso, URI_1, 0).fetch();
fail("Should have crashed with a shutdown picasso.");
} catch (IllegalStateException ignored) {
}
}
@Test public void getReturnsNullIfNullUriAndResourceId() throws InterruptedException {
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/PicassoTest.java
211 issues
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;
Reported by PMD.
Line: 75
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23) // Works around https://github.com/robolectric/robolectric/issues/2566.
public final class PicassoTest {
private static final int NUM_BUILTIN_HANDLERS = 8;
private static final int NUM_BUILTIN_TRANSFORMERS = 0;
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Mock Context context;
Reported by PMD.
Line: 79
private static final int NUM_BUILTIN_HANDLERS = 8;
private static final int NUM_BUILTIN_TRANSFORMERS = 0;
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Mock Context context;
@Mock Dispatcher dispatcher;
@Mock RequestHandler requestHandler;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
Reported by PMD.
Line: 80
private static final int NUM_BUILTIN_TRANSFORMERS = 0;
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Mock Context context;
@Mock Dispatcher dispatcher;
@Mock RequestHandler requestHandler;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
Reported by PMD.
Line: 81
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Mock Context context;
@Mock Dispatcher dispatcher;
@Mock RequestHandler requestHandler;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
private Picasso picasso;
Reported by PMD.
Line: 82
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Mock Context context;
@Mock Dispatcher dispatcher;
@Mock RequestHandler requestHandler;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
private Picasso picasso;
private EventRecorder eventRecorder = new EventRecorder();
Reported by PMD.
Line: 83
@Mock Context context;
@Mock Dispatcher dispatcher;
@Mock RequestHandler requestHandler;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
private Picasso picasso;
private EventRecorder eventRecorder = new EventRecorder();
final Bitmap bitmap = makeBitmap();
Reported by PMD.
Line: 84
@Mock Dispatcher dispatcher;
@Mock RequestHandler requestHandler;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
private Picasso picasso;
private EventRecorder eventRecorder = new EventRecorder();
final Bitmap bitmap = makeBitmap();
Reported by PMD.
Line: 86
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Listener listener;
private Picasso picasso;
private EventRecorder eventRecorder = new EventRecorder();
final Bitmap bitmap = makeBitmap();
@Before public void setUp() {
initMocks(this);
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/DispatcherTest.java
178 issues
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
Reported by PMD.
Line: 70
import static org.mockito.MockitoAnnotations.initMocks;
@RunWith(RobolectricTestRunner.class)
public class DispatcherTest {
@Mock Context context;
@Mock ConnectivityManager connectivityManager;
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
Reported by PMD.
Line: 71
@RunWith(RobolectricTestRunner.class)
public class DispatcherTest {
@Mock Context context;
@Mock ConnectivityManager connectivityManager;
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
Reported by PMD.
Line: 72
@RunWith(RobolectricTestRunner.class)
public class DispatcherTest {
@Mock Context context;
@Mock ConnectivityManager connectivityManager;
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
private Dispatcher dispatcher;
Reported by PMD.
Line: 73
public class DispatcherTest {
@Mock Context context;
@Mock ConnectivityManager connectivityManager;
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
private Dispatcher dispatcher;
Reported by PMD.
Line: 74
@Mock Context context;
@Mock ConnectivityManager connectivityManager;
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
private Dispatcher dispatcher;
final Bitmap bitmap1 = makeBitmap();
Reported by PMD.
Line: 75
@Mock ConnectivityManager connectivityManager;
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
private Dispatcher dispatcher;
final Bitmap bitmap1 = makeBitmap();
final Bitmap bitmap2 = makeBitmap();
Reported by PMD.
Line: 76
@Mock PicassoExecutorService service;
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
private Dispatcher dispatcher;
final Bitmap bitmap1 = makeBitmap();
final Bitmap bitmap2 = makeBitmap();
Reported by PMD.
Line: 77
@Mock ExecutorService serviceMock;
final PlatformLruCache cache = new PlatformLruCache(2048);
@Mock Stats stats;
private Dispatcher dispatcher;
final Bitmap bitmap1 = makeBitmap();
final Bitmap bitmap2 = makeBitmap();
@Before public void setUp() {
Reported by PMD.
Line: 79
@Mock Stats stats;
private Dispatcher dispatcher;
final Bitmap bitmap1 = makeBitmap();
final Bitmap bitmap2 = makeBitmap();
@Before public void setUp() {
initMocks(this);
dispatcher = createDispatcher();
Reported by PMD.
picasso/src/main/java/com/squareup/picasso3/Picasso.java
89 issues
Line: 511
return requestHandlers;
}
Request transformRequest(Request request) {
for (int i = 0, size = requestTransformers.size(); i < size; i++) {
RequestTransformer transformer = requestTransformers.get(i);
Request transformed = transformer.transformRequest(request);
if (transformed == null) {
throw new IllegalStateException("Request transformer "
Reported by PMD.
Line: 601
// Resumed action is cached, complete immediately.
deliverAction(new Result.Bitmap(bitmap, MEMORY), action, null);
if (loggingEnabled) {
log(OWNER_MAIN, VERB_COMPLETED, action.request.logId(), "from " + MEMORY);
}
} else {
// Re-submit the action to the executor.
enqueueAndSubmit(action);
if (loggingEnabled) {
Reported by PMD.
Line: 623
if (result != null) {
action.complete(result);
if (loggingEnabled) {
log(OWNER_MAIN, VERB_COMPLETED, action.request.logId(), "from " + result.loadedFrom);
}
} else {
Exception exception = checkNotNull(e, "e == null");
action.error(exception);
if (loggingEnabled) {
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
Reported by PMD.
Line: 68
* Use {@see PicassoProvider#get()} for a global singleton instance
* or construct your own instance with {@link Builder}.
*/
public class Picasso implements LifecycleObserver {
/** Callbacks for Picasso events. */
public interface Listener {
/**
* Invoked when an image has failed to load. This is useful for reporting image failures to a
Reported by PMD.
Line: 68
* Use {@see PicassoProvider#get()} for a global singleton instance
* or construct your own instance with {@link Builder}.
*/
public class Picasso implements LifecycleObserver {
/** Callbacks for Picasso events. */
public interface Listener {
/**
* Invoked when an image has failed to load. This is useful for reporting image failures to a
Reported by PMD.
Line: 68
* Use {@see PicassoProvider#get()} for a global singleton instance
* or construct your own instance with {@link Builder}.
*/
public class Picasso implements LifecycleObserver {
/** Callbacks for Picasso events. */
public interface Listener {
/**
* Invoked when an image has failed to load. This is useful for reporting image failures to a
Reported by PMD.
Line: 68
* Use {@see PicassoProvider#get()} for a global singleton instance
* or construct your own instance with {@link Builder}.
*/
public class Picasso implements LifecycleObserver {
/** Callbacks for Picasso events. */
public interface Listener {
/**
* Invoked when an image has failed to load. This is useful for reporting image failures to a
Reported by PMD.
Line: 117
switch (msg.what) {
case HUNTER_COMPLETE: {
BitmapHunter hunter = (BitmapHunter) msg.obj;
hunter.picasso.complete(hunter);
break;
}
case REQUEST_BATCH_RESUME:
@SuppressWarnings("unchecked") List<Action> batch = (List<Action>) msg.obj;
//noinspection ForLoopReplaceableByForEach
Reported by PMD.
Line: 123
case REQUEST_BATCH_RESUME:
@SuppressWarnings("unchecked") List<Action> batch = (List<Action>) msg.obj;
//noinspection ForLoopReplaceableByForEach
for (int i = 0, n = batch.size(); i < n; i++) {
Action action = batch.get(i);
action.picasso.resumeAction(action);
}
break;
default:
Reported by PMD.
picasso-pollexor/src/test/java/com/squareup/picasso3/pollexor/PollexorRequestTransformerTest.java
79 issues
Line: 22
sdk = 17,
manifest = NONE
)
public class PollexorRequestTransformerTest {
private static final String HOST = "http://example.com/";
private static final String KEY = "omgsecretpassword";
private static final String IMAGE = "http://google.com/logo.png";
private static final Uri IMAGE_URI = Uri.parse(IMAGE);
Reported by PMD.
Line: 28
private static final String IMAGE = "http://google.com/logo.png";
private static final Uri IMAGE_URI = Uri.parse(IMAGE);
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);
@Test public void resourceIdRequestsAreNotTransformed() {
Reported by PMD.
Line: 28
private static final String IMAGE = "http://google.com/logo.png";
private static final Uri IMAGE_URI = Uri.parse(IMAGE);
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);
@Test public void resourceIdRequestsAreNotTransformed() {
Reported by PMD.
Line: 29
private static final Uri IMAGE_URI = Uri.parse(IMAGE);
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);
@Test public void resourceIdRequestsAreNotTransformed() {
Request input = new Request.Builder(12).build();
Reported by PMD.
Line: 29
private static final Uri IMAGE_URI = Uri.parse(IMAGE);
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);
@Test public void resourceIdRequestsAreNotTransformed() {
Request input = new Request.Builder(12).build();
Reported by PMD.
Line: 31
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);
@Test public void resourceIdRequestsAreNotTransformed() {
Request input = new Request.Builder(12).build();
Request output = transformer.transformRequest(input);
assertThat(output).isSameAs(input);
Reported by PMD.
Line: 31
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);
@Test public void resourceIdRequestsAreNotTransformed() {
Request input = new Request.Builder(12).build();
Request output = transformer.transformRequest(input);
assertThat(output).isSameAs(input);
Reported by PMD.
Line: 36
@Test public void resourceIdRequestsAreNotTransformed() {
Request input = new Request.Builder(12).build();
Request output = transformer.transformRequest(input);
assertThat(output).isSameAs(input);
}
@Test public void resourceIdRequestsAreNotTransformedWhenAlwaysTransformIsTrue() {
Request input = new Request.Builder(12).build();
Request output = alwaysResizeTransformer.transformRequest(input);
Reported by PMD.
Line: 42
@Test public void resourceIdRequestsAreNotTransformedWhenAlwaysTransformIsTrue() {
Request input = new Request.Builder(12).build();
Request output = alwaysResizeTransformer.transformRequest(input);
assertThat(output).isSameAs(input);
}
@Test public void nonHttpRequestsAreNotTransformed() {
Request input = new Request.Builder(IMAGE_URI).build();
Request output = transformer.transformRequest(input);
Reported by PMD.
Line: 48
@Test public void nonHttpRequestsAreNotTransformed() {
Request input = new Request.Builder(IMAGE_URI).build();
Request output = transformer.transformRequest(input);
assertThat(output).isSameAs(input);
}
@Test public void nonResizedRequestsAreNotTransformed() {
Request input = new Request.Builder(IMAGE_URI).build();
Request output = transformer.transformRequest(input);
Reported by PMD.
picasso/src/main/java/com/squareup/picasso3/Dispatcher.java
75 issues
Line: 174
if (pausedTags.contains(action.getTag())) {
pausedActions.put(action.getTarget(), action);
if (action.picasso.loggingEnabled) {
log(OWNER_DISPATCHER, VERB_PAUSED, action.request.logId(),
"because tag '" + action.getTag() + "' is paused");
}
return;
}
Reported by PMD.
Line: 257
hunter.detach(single);
pausedActions.put(single.getTarget(), single);
if (loggingEnabled) {
log(OWNER_DISPATCHER, VERB_PAUSED, single.request.logId(),
"because tag '" + tag + "' was paused");
}
}
if (joined != null) {
Reported by PMD.
Line: 272
hunter.detach(action);
pausedActions.put(action.getTarget(), action);
if (loggingEnabled) {
log(OWNER_DISPATCHER, VERB_PAUSED, action.request.logId(),
"because tag '" + tag + "' was paused");
}
}
}
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
Reported by PMD.
Line: 61
import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;
class Dispatcher {
private static final int RETRY_DELAY = 500;
private static final int AIRPLANE_MODE_ON = 1;
private static final int AIRPLANE_MODE_OFF = 0;
static final int REQUEST_SUBMIT = 1;
Reported by PMD.
Line: 61
import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;
class Dispatcher {
private static final int RETRY_DELAY = 500;
private static final int AIRPLANE_MODE_ON = 1;
private static final int AIRPLANE_MODE_OFF = 0;
static final int REQUEST_SUBMIT = 1;
Reported by PMD.
Line: 61
import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;
class Dispatcher {
private static final int RETRY_DELAY = 500;
private static final int AIRPLANE_MODE_ON = 1;
private static final int AIRPLANE_MODE_OFF = 0;
static final int REQUEST_SUBMIT = 1;
Reported by PMD.
Line: 61
import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;
class Dispatcher {
private static final int RETRY_DELAY = 500;
private static final int AIRPLANE_MODE_ON = 1;
private static final int AIRPLANE_MODE_OFF = 0;
static final int REQUEST_SUBMIT = 1;
Reported by PMD.
Line: 61
import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;
class Dispatcher {
private static final int RETRY_DELAY = 500;
private static final int AIRPLANE_MODE_ON = 1;
private static final int AIRPLANE_MODE_OFF = 0;
static final int REQUEST_SUBMIT = 1;
Reported by PMD.
Line: 79
private static final String DISPATCHER_THREAD_NAME = "Dispatcher";
final DispatcherThread dispatcherThread;
final Context context;
final ExecutorService service;
final Map<String, BitmapHunter> hunterMap;
final Map<Object, Action> failedActions;
final Map<Object, Action> pausedActions;
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/NetworkRequestHandlerTest.java
66 issues
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.net.NetworkInfo;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.squareup.picasso3.RequestHandler.Result;
Reported by PMD.
Line: 55
import static org.mockito.MockitoAnnotations.initMocks;
@RunWith(RobolectricTestRunner.class)
public class NetworkRequestHandlerTest {
final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();
@Mock Picasso picasso;
@Mock Dispatcher dispatcher;
Reported by PMD.
Line: 56
@RunWith(RobolectricTestRunner.class)
public class NetworkRequestHandlerTest {
final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();
@Mock Picasso picasso;
@Mock Dispatcher dispatcher;
Reported by PMD.
Line: 57
@RunWith(RobolectricTestRunner.class)
public class NetworkRequestHandlerTest {
final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();
@Mock Picasso picasso;
@Mock Dispatcher dispatcher;
private NetworkRequestHandler networkHandler;
Reported by PMD.
Line: 59
final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();
@Mock Picasso picasso;
@Mock Dispatcher dispatcher;
private NetworkRequestHandler networkHandler;
@Before public void setUp() {
Reported by PMD.
Line: 60
final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();
@Mock Picasso picasso;
@Mock Dispatcher dispatcher;
private NetworkRequestHandler networkHandler;
@Before public void setUp() {
initMocks(this);
Reported by PMD.
Line: 62
@Mock Picasso picasso;
@Mock Dispatcher dispatcher;
private NetworkRequestHandler networkHandler;
@Before public void setUp() {
initMocks(this);
networkHandler = new NetworkRequestHandler(new Call.Factory() {
@Override public Call newCall(Request request) {
Reported by PMD.
Line: 78
});
}
@Test public void doesNotForceLocalCacheOnlyWithAirplaneModeOffAndRetryCount() throws Exception {
responses.add(responseOf(ResponseBody.create(null, new byte[10])));
Action action = TestUtils.mockAction(URI_KEY_1, URI_1);
final CountDownLatch latch = new CountDownLatch(1);
networkHandler.load(picasso, action.request, new RequestHandler.Callback() {
@Override public void onSuccess(Result result) {
Reported by PMD.
Line: 78
});
}
@Test public void doesNotForceLocalCacheOnlyWithAirplaneModeOffAndRetryCount() throws Exception {
responses.add(responseOf(ResponseBody.create(null, new byte[10])));
Action action = TestUtils.mockAction(URI_KEY_1, URI_1);
final CountDownLatch latch = new CountDownLatch(1);
networkHandler.load(picasso, action.request, new RequestHandler.Callback() {
@Override public void onSuccess(Result result) {
Reported by PMD.
Line: 85
networkHandler.load(picasso, action.request, new RequestHandler.Callback() {
@Override public void onSuccess(Result result) {
try {
assertThat(requests.takeFirst().cacheControl().toString()).isEmpty();
latch.countDown();
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/TestUtils.java
62 issues
Line: 121
try {
doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
return context;
}
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;
import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
Reported by PMD.
Line: 60
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
class TestUtils {
static final Answer<Object> TRANSFORM_REQUEST_ANSWER = new Answer<Object>() {
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0];
}
};
Reported by PMD.
Line: 117
PackageManager pm = mock(PackageManager.class);
Resources res = mock(Resources.class);
doReturn(pm).when(context).getPackageManager();
try {
doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
Reported by PMD.
Line: 117
PackageManager pm = mock(PackageManager.class);
Resources res = mock(Resources.class);
doReturn(pm).when(context).getPackageManager();
try {
doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
Reported by PMD.
Line: 119
doReturn(pm).when(context).getPackageManager();
try {
doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
return context;
Reported by PMD.
Line: 119
doReturn(pm).when(context).getPackageManager();
try {
doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
return context;
Reported by PMD.
Line: 123
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
return context;
}
static Resources mockResources(final String resValueString) {
Resources resources = mock(Resources.class);
Reported by PMD.
Line: 123
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
return context;
}
static Resources mockResources(final String resValueString) {
Resources resources = mock(Resources.class);
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/PlatformLruCacheTest.java
48 issues
Line: 33
import static junit.framework.Assert.fail;
@RunWith(RobolectricTestRunner.class)
public class PlatformLruCacheTest {
// The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
Reported by PMD.
Line: 35
@RunWith(RobolectricTestRunner.class)
public class PlatformLruCacheTest {
// The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
Reported by PMD.
Line: 36
public class PlatformLruCacheTest {
// The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
private int expectedPutCount;
Reported by PMD.
Line: 37
// The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
private int expectedPutCount;
private int expectedHitCount;
Reported by PMD.
Line: 38
private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
private int expectedPutCount;
private int expectedHitCount;
private int expectedMissCount;
Reported by PMD.
Line: 39
private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
private int expectedPutCount;
private int expectedHitCount;
private int expectedMissCount;
private int expectedEvictionCount;
Reported by PMD.
Line: 41
private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
private int expectedPutCount;
private int expectedHitCount;
private int expectedMissCount;
private int expectedEvictionCount;
@Test public void testStatistics() {
Reported by PMD.
Line: 42
private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);
private int expectedPutCount;
private int expectedHitCount;
private int expectedMissCount;
private int expectedEvictionCount;
@Test public void testStatistics() {
PlatformLruCache cache = new PlatformLruCache(3);
Reported by PMD.
Line: 43
private int expectedPutCount;
private int expectedHitCount;
private int expectedMissCount;
private int expectedEvictionCount;
@Test public void testStatistics() {
PlatformLruCache cache = new PlatformLruCache(3);
assertStatistics(cache);
Reported by PMD.
Line: 44
private int expectedPutCount;
private int expectedHitCount;
private int expectedMissCount;
private int expectedEvictionCount;
@Test public void testStatistics() {
PlatformLruCache cache = new PlatformLruCache(3);
assertStatistics(cache);
Reported by PMD.