The following issues were found
guava-tests/test/com/google/common/collect/MoreCollectorsTest.java
36 issues
Line: 33
* @author Louis Wasserman
*/
@GwtCompatible
public class MoreCollectorsTest extends TestCase {
public void testToOptionalEmpty() {
assertThat(Stream.empty().collect(MoreCollectors.toOptional())).isEmpty();
}
public void testToOptionalSingleton() {
Reported by PMD.
Line: 34
*/
@GwtCompatible
public class MoreCollectorsTest extends TestCase {
public void testToOptionalEmpty() {
assertThat(Stream.empty().collect(MoreCollectors.toOptional())).isEmpty();
}
public void testToOptionalSingleton() {
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
Reported by PMD.
Line: 35
@GwtCompatible
public class MoreCollectorsTest extends TestCase {
public void testToOptionalEmpty() {
assertThat(Stream.empty().collect(MoreCollectors.toOptional())).isEmpty();
}
public void testToOptionalSingleton() {
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
}
Reported by PMD.
Line: 35
@GwtCompatible
public class MoreCollectorsTest extends TestCase {
public void testToOptionalEmpty() {
assertThat(Stream.empty().collect(MoreCollectors.toOptional())).isEmpty();
}
public void testToOptionalSingleton() {
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
}
Reported by PMD.
Line: 38
assertThat(Stream.empty().collect(MoreCollectors.toOptional())).isEmpty();
}
public void testToOptionalSingleton() {
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
}
public void testToOptionalNull() {
Stream<Object> stream = Stream.of((Object) null);
Reported by PMD.
Line: 39
}
public void testToOptionalSingleton() {
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
}
public void testToOptionalNull() {
Stream<Object> stream = Stream.of((Object) null);
try {
Reported by PMD.
Line: 39
}
public void testToOptionalSingleton() {
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
}
public void testToOptionalNull() {
Stream<Object> stream = Stream.of((Object) null);
try {
Reported by PMD.
Line: 42
assertThat(Stream.of(1).collect(MoreCollectors.toOptional())).hasValue(1);
}
public void testToOptionalNull() {
Stream<Object> stream = Stream.of((Object) null);
try {
stream.collect(MoreCollectors.toOptional());
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
Reported by PMD.
Line: 46
Stream<Object> stream = Stream.of((Object) null);
try {
stream.collect(MoreCollectors.toOptional());
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
}
}
public void testToOptionalMultiple() {
Reported by PMD.
Line: 47
try {
stream.collect(MoreCollectors.toOptional());
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
}
}
public void testToOptionalMultiple() {
try {
Reported by PMD.
guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
36 issues
Line: 52
.put("SHA-512", Hashing.sha512())
.build();
public void testHashing() {
for (String stringToTest : INPUTS) {
for (String algorithmToTest : ALGORITHMS.keySet()) {
assertMessageDigestHashing(HashTestUtils.ascii(stringToTest), algorithmToTest);
}
}
Reported by PMD.
Line: 60
}
}
public void testPutAfterHash() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
Reported by PMD.
Line: 61
}
public void testPutAfterHash() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
Reported by PMD.
Line: 63
public void testPutAfterHash() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
Reported by PMD.
Line: 65
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
sha1.putInt(42);
fail();
Reported by PMD.
Line: 65
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
sha1.putInt(42);
fail();
Reported by PMD.
Line: 65
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
sha1.putInt(42);
fail();
Reported by PMD.
Line: 70
.toString());
try {
sha1.putInt(42);
fail();
} catch (IllegalStateException expected) {
}
}
public void testHashTwice() {
Reported by PMD.
Line: 70
.toString());
try {
sha1.putInt(42);
fail();
} catch (IllegalStateException expected) {
}
}
public void testHashTwice() {
Reported by PMD.
Line: 75
}
}
public void testHashTwice() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java
36 issues
Line: 48
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Uninterruptibles {
// Implementation Note: As of 3-7-11, the logic for each blocking/timeout
// methods is identical, save for method being invoked.
/** Invokes {@code latch.}{@link CountDownLatch#await() await()} uninterruptibly. */
Reported by PMD.
Line: 68
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/**
Reported by PMD.
Line: 79
*/
@CanIgnoreReturnValue // TODO(cpovirk): Consider being more strict.
@GwtIncompatible // concurrency
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
public static boolean awaitUninterruptibly(CountDownLatch latch, long timeout, TimeUnit unit) {
boolean interrupted = false;
try {
long remainingNanos = unit.toNanos(timeout);
long end = System.nanoTime() + remainingNanos;
Reported by PMD.
Line: 97
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/**
Reported by PMD.
Line: 126
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/** Invokes {@code toJoin.}{@link Thread#join() join()} uninterruptibly. */
Reported by PMD.
Line: 146
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/**
Reported by PMD.
Line: 175
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/**
Reported by PMD.
Line: 212
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/**
Reported by PMD.
Line: 257
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/** Invokes {@code queue.}{@link BlockingQueue#take() take()} uninterruptibly. */
Reported by PMD.
Line: 276
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
/**
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/Futures.java
36 issues
Line: 15
* the License.
*/
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
Reported by PMD.
Line: 77
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Futures extends GwtFuturesCatchingSpecialization {
// A note on memory visibility.
// Many of the utilities in this class (transform, withFallback, withTimeout, asList, combine)
// have two requirements that significantly complicate their design.
// 1. Cancellation should propagate from the returned future to the input future(s).
Reported by PMD.
Line: 77
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Futures extends GwtFuturesCatchingSpecialization {
// A note on memory visibility.
// Many of the utilities in this class (transform, withFallback, withTimeout, asList, combine)
// have two requirements that significantly complicate their design.
// 1. Cancellation should propagate from the returned future to the input future(s).
Reported by PMD.
Line: 135
@ParametricNullness V value) {
if (value == null) {
// This cast is safe because null is assignable to V for all V (i.e. it is bivariant)
@SuppressWarnings("unchecked")
ListenableFuture<V> typedNull = (ListenableFuture<V>) ImmediateFuture.NULL;
return typedNull;
}
return new ImmediateFuture<>(value);
}
Reported by PMD.
Line: 518
private O applyTransformation(I input) throws ExecutionException {
try {
return function.apply(input);
} catch (Throwable t) {
throw new ExecutionException(t);
}
}
};
}
Reported by PMD.
Line: 666
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing, especially if we provide run(Runnable)
@GwtCompatible
public static final class FutureCombiner<V extends @Nullable Object> {
private final boolean allMustSucceed;
private final ImmutableList<ListenableFuture<? extends V>> futures;
private FutureCombiner(
boolean allMustSucceed, ImmutableList<ListenableFuture<? extends V>> futures) {
this.allMustSucceed = allMustSucceed;
Reported by PMD.
Line: 667
@GwtCompatible
public static final class FutureCombiner<V extends @Nullable Object> {
private final boolean allMustSucceed;
private final ImmutableList<ListenableFuture<? extends V>> futures;
private FutureCombiner(
boolean allMustSucceed, ImmutableList<ListenableFuture<? extends V>> futures) {
this.allMustSucceed = allMustSucceed;
this.futures = futures;
Reported by PMD.
Line: 760
/** A wrapped future that does not propagate cancellation to its delegate. */
private static final class NonCancellationPropagatingFuture<V extends @Nullable Object>
extends AbstractFuture.TrustedFuture<V> implements Runnable {
@CheckForNull private ListenableFuture<V> delegate;
NonCancellationPropagatingFuture(final ListenableFuture<V> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 788
@Override
protected void afterDone() {
delegate = null;
}
}
/**
* Creates a new {@code ListenableFuture} whose value is a list containing the values of all its
Reported by PMD.
Line: 881
final InCompletionOrderState<T> state = new InCompletionOrderState<>(copy);
ImmutableList.Builder<AbstractFuture<T>> delegatesBuilder =
ImmutableList.builderWithExpectedSize(copy.length);
for (int i = 0; i < copy.length; i++) {
delegatesBuilder.add(new InCompletionOrderFuture<T>(state));
}
final ImmutableList<AbstractFuture<T>> delegates = delegatesBuilder.build();
for (int i = 0; i < copy.length; i++) {
Reported by PMD.
android/guava-tests/test/com/google/common/reflect/SubtypeTester.java
36 issues
Line: 81
boolean suppressGetSupertype() default false;
}
private Method method = null;
/** Call this in a {@link TestSubtype} public method asserting subtype relationship. */
final <T> T isSubtype(T sub) {
Type returnType = method.getGenericReturnType();
Type paramType = getOnlyParameterType();
Reported by PMD.
Line: 81
boolean suppressGetSupertype() default false;
}
private Method method = null;
/** Call this in a {@link TestSubtype} public method asserting subtype relationship. */
final <T> T isSubtype(T sub) {
Type returnType = method.getGenericReturnType();
Type paramType = getOnlyParameterType();
Reported by PMD.
Line: 88
Type returnType = method.getGenericReturnType();
Type paramType = getOnlyParameterType();
TestSubtype spec = method.getAnnotation(TestSubtype.class);
assertWithMessage("%s is subtype of %s", paramType, returnType)
.that(TypeToken.of(paramType).isSubtypeOf(returnType))
.isTrue();
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
Reported by PMD.
Line: 88
Type returnType = method.getGenericReturnType();
Type paramType = getOnlyParameterType();
TestSubtype spec = method.getAnnotation(TestSubtype.class);
assertWithMessage("%s is subtype of %s", paramType, returnType)
.that(TypeToken.of(paramType).isSubtypeOf(returnType))
.isTrue();
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
Reported by PMD.
Line: 89
Type paramType = getOnlyParameterType();
TestSubtype spec = method.getAnnotation(TestSubtype.class);
assertWithMessage("%s is subtype of %s", paramType, returnType)
.that(TypeToken.of(paramType).isSubtypeOf(returnType))
.isTrue();
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
if (!spec.suppressGetSubtype()) {
Reported by PMD.
Line: 91
assertWithMessage("%s is subtype of %s", paramType, returnType)
.that(TypeToken.of(paramType).isSubtypeOf(returnType))
.isTrue();
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
if (!spec.suppressGetSubtype()) {
assertThat(getSubtype(returnType, TypeToken.of(paramType).getRawType())).isEqualTo(paramType);
}
Reported by PMD.
Line: 91
assertWithMessage("%s is subtype of %s", paramType, returnType)
.that(TypeToken.of(paramType).isSubtypeOf(returnType))
.isTrue();
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
if (!spec.suppressGetSubtype()) {
assertThat(getSubtype(returnType, TypeToken.of(paramType).getRawType())).isEqualTo(paramType);
}
Reported by PMD.
Line: 92
.that(TypeToken.of(paramType).isSubtypeOf(returnType))
.isTrue();
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
if (!spec.suppressGetSubtype()) {
assertThat(getSubtype(returnType, TypeToken.of(paramType).getRawType())).isEqualTo(paramType);
}
if (!spec.suppressGetSupertype()) {
Reported by PMD.
Line: 94
assertWithMessage("%s is supertype of %s", returnType, paramType)
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
if (!spec.suppressGetSubtype()) {
assertThat(getSubtype(returnType, TypeToken.of(paramType).getRawType())).isEqualTo(paramType);
}
if (!spec.suppressGetSupertype()) {
assertThat(getSupertype(paramType, TypeToken.of(returnType).getRawType()))
.isEqualTo(returnType);
Reported by PMD.
Line: 95
.that(TypeToken.of(returnType).isSupertypeOf(paramType))
.isTrue();
if (!spec.suppressGetSubtype()) {
assertThat(getSubtype(returnType, TypeToken.of(paramType).getRawType())).isEqualTo(paramType);
}
if (!spec.suppressGetSupertype()) {
assertThat(getSupertype(paramType, TypeToken.of(returnType).getRawType()))
.isEqualTo(returnType);
}
Reported by PMD.
android/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
36 issues
Line: 52
.put("SHA-512", Hashing.sha512())
.build();
public void testHashing() {
for (String stringToTest : INPUTS) {
for (String algorithmToTest : ALGORITHMS.keySet()) {
assertMessageDigestHashing(HashTestUtils.ascii(stringToTest), algorithmToTest);
}
}
Reported by PMD.
Line: 60
}
}
public void testPutAfterHash() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
Reported by PMD.
Line: 61
}
public void testPutAfterHash() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
Reported by PMD.
Line: 63
public void testPutAfterHash() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
Reported by PMD.
Line: 65
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
sha1.putInt(42);
fail();
Reported by PMD.
Line: 65
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
sha1.putInt(42);
fail();
Reported by PMD.
Line: 65
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
try {
sha1.putInt(42);
fail();
Reported by PMD.
Line: 70
.toString());
try {
sha1.putInt(42);
fail();
} catch (IllegalStateException expected) {
}
}
public void testHashTwice() {
Reported by PMD.
Line: 70
.toString());
try {
sha1.putInt(42);
fail();
} catch (IllegalStateException expected) {
}
}
public void testHashTwice() {
Reported by PMD.
Line: 75
}
}
public void testHashTwice() {
Hasher sha1 = Hashing.sha1().newHasher();
assertEquals(
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
Reported by PMD.
android/guava-tests/test/com/google/common/collect/FilteredMultimapTest.java
36 issues
Line: 37
new Predicate<Entry<String, Integer>>() {
@Override
public boolean apply(Entry<String, Integer> entry) {
return !"badkey".equals(entry.getKey()) && !((Integer) 55556).equals(entry.getValue());
}
};
protected Multimap<String, Integer> create() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
Reported by PMD.
Line: 43
protected Multimap<String, Integer> create() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
return Multimaps.filterEntries(unfiltered, ENTRY_PREDICATE);
}
private static final Predicate<String> KEY_PREDICATE =
Reported by PMD.
Line: 43
protected Multimap<String, Integer> create() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
return Multimaps.filterEntries(unfiltered, ENTRY_PREDICATE);
}
private static final Predicate<String> KEY_PREDICATE =
Reported by PMD.
Line: 44
protected Multimap<String, Integer> create() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
return Multimaps.filterEntries(unfiltered, ENTRY_PREDICATE);
}
private static final Predicate<String> KEY_PREDICATE =
new Predicate<String>() {
Reported by PMD.
Line: 56
}
};
public void testFilterKeys() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
Multimap<String, Integer> filtered = Multimaps.filterKeys(unfiltered, KEY_PREDICATE);
assertEquals(1, filtered.size());
Reported by PMD.
Line: 56
}
};
public void testFilterKeys() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
Multimap<String, Integer> filtered = Multimaps.filterKeys(unfiltered, KEY_PREDICATE);
assertEquals(1, filtered.size());
Reported by PMD.
Line: 58
public void testFilterKeys() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
Multimap<String, Integer> filtered = Multimaps.filterKeys(unfiltered, KEY_PREDICATE);
assertEquals(1, filtered.size());
assertTrue(filtered.containsEntry("foo", 55556));
}
Reported by PMD.
Line: 59
public void testFilterKeys() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
Multimap<String, Integer> filtered = Multimaps.filterKeys(unfiltered, KEY_PREDICATE);
assertEquals(1, filtered.size());
assertTrue(filtered.containsEntry("foo", 55556));
}
Reported by PMD.
Line: 61
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
Multimap<String, Integer> filtered = Multimaps.filterKeys(unfiltered, KEY_PREDICATE);
assertEquals(1, filtered.size());
assertTrue(filtered.containsEntry("foo", 55556));
}
private static final Predicate<Integer> VALUE_PREDICATE =
new Predicate<Integer>() {
Reported by PMD.
Line: 61
unfiltered.put("foo", 55556);
unfiltered.put("badkey", 1);
Multimap<String, Integer> filtered = Multimaps.filterKeys(unfiltered, KEY_PREDICATE);
assertEquals(1, filtered.size());
assertTrue(filtered.containsEntry("foo", 55556));
}
private static final Predicate<Integer> VALUE_PREDICATE =
new Predicate<Integer>() {
Reported by PMD.
android/guava-testlib/test/com/google/common/collect/testing/MinimalIterableTest.java
36 issues
Line: 33
@GwtCompatible
public class MinimalIterableTest extends TestCase {
public void testOf_empty() {
Iterable<String> iterable = MinimalIterable.<String>of();
Iterator<String> iterator = iterable.iterator();
assertFalse(iterator.hasNext());
try {
iterator.next();
Reported by PMD.
Line: 35
public void testOf_empty() {
Iterable<String> iterable = MinimalIterable.<String>of();
Iterator<String> iterator = iterable.iterator();
assertFalse(iterator.hasNext());
try {
iterator.next();
fail();
} catch (NoSuchElementException expected) {
Reported by PMD.
Line: 36
public void testOf_empty() {
Iterable<String> iterable = MinimalIterable.<String>of();
Iterator<String> iterator = iterable.iterator();
assertFalse(iterator.hasNext());
try {
iterator.next();
fail();
} catch (NoSuchElementException expected) {
}
Reported by PMD.
Line: 39
assertFalse(iterator.hasNext());
try {
iterator.next();
fail();
} catch (NoSuchElementException expected) {
}
try {
iterable.iterator();
fail();
Reported by PMD.
Line: 39
assertFalse(iterator.hasNext());
try {
iterator.next();
fail();
} catch (NoSuchElementException expected) {
}
try {
iterable.iterator();
fail();
Reported by PMD.
Line: 44
}
try {
iterable.iterator();
fail();
} catch (IllegalStateException expected) {
}
}
public void testOf_one() {
Reported by PMD.
Line: 44
}
try {
iterable.iterator();
fail();
} catch (IllegalStateException expected) {
}
}
public void testOf_one() {
Reported by PMD.
Line: 49
}
}
public void testOf_one() {
Iterable<String> iterable = MinimalIterable.of("a");
Iterator<String> iterator = iterable.iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next());
assertFalse(iterator.hasNext());
Reported by PMD.
Line: 49
}
}
public void testOf_one() {
Iterable<String> iterable = MinimalIterable.of("a");
Iterator<String> iterator = iterable.iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next());
assertFalse(iterator.hasNext());
Reported by PMD.
Line: 51
public void testOf_one() {
Iterable<String> iterable = MinimalIterable.of("a");
Iterator<String> iterator = iterable.iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next());
assertFalse(iterator.hasNext());
try {
iterator.next();
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/MapEntrySetTester.java
36 issues
Line: 55
INSTANCE;
}
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testEntrySetIteratorRemove() {
Set<Entry<K, V>> entrySet = getMap().entrySet();
Iterator<Entry<K, V>> entryItr = entrySet.iterator();
assertEquals(e0(), entryItr.next());
Reported by PMD.
Line: 57
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testEntrySetIteratorRemove() {
Set<Entry<K, V>> entrySet = getMap().entrySet();
Iterator<Entry<K, V>> entryItr = entrySet.iterator();
assertEquals(e0(), entryItr.next());
entryItr.remove();
assertTrue(getMap().isEmpty());
Reported by PMD.
Line: 58
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testEntrySetIteratorRemove() {
Set<Entry<K, V>> entrySet = getMap().entrySet();
Iterator<Entry<K, V>> entryItr = entrySet.iterator();
assertEquals(e0(), entryItr.next());
entryItr.remove();
assertTrue(getMap().isEmpty());
assertFalse(entrySet.contains(e0()));
Reported by PMD.
Line: 59
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testEntrySetIteratorRemove() {
Set<Entry<K, V>> entrySet = getMap().entrySet();
Iterator<Entry<K, V>> entryItr = entrySet.iterator();
assertEquals(e0(), entryItr.next());
entryItr.remove();
assertTrue(getMap().isEmpty());
assertFalse(entrySet.contains(e0()));
}
Reported by PMD.
Line: 62
Iterator<Entry<K, V>> entryItr = entrySet.iterator();
assertEquals(e0(), entryItr.next());
entryItr.remove();
assertTrue(getMap().isEmpty());
assertFalse(entrySet.contains(e0()));
}
public void testContainsEntryWithIncomparableKey() {
try {
Reported by PMD.
Line: 63
assertEquals(e0(), entryItr.next());
entryItr.remove();
assertTrue(getMap().isEmpty());
assertFalse(entrySet.contains(e0()));
}
public void testContainsEntryWithIncomparableKey() {
try {
assertFalse(getMap().entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, v0())));
Reported by PMD.
Line: 66
assertFalse(entrySet.contains(e0()));
}
public void testContainsEntryWithIncomparableKey() {
try {
assertFalse(getMap().entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, v0())));
} catch (ClassCastException acceptable) {
// allowed by the spec
}
Reported by PMD.
Line: 68
public void testContainsEntryWithIncomparableKey() {
try {
assertFalse(getMap().entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, v0())));
} catch (ClassCastException acceptable) {
// allowed by the spec
}
}
Reported by PMD.
Line: 68
public void testContainsEntryWithIncomparableKey() {
try {
assertFalse(getMap().entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, v0())));
} catch (ClassCastException acceptable) {
// allowed by the spec
}
}
Reported by PMD.
Line: 69
public void testContainsEntryWithIncomparableKey() {
try {
assertFalse(getMap().entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, v0())));
} catch (ClassCastException acceptable) {
// allowed by the spec
}
}
public void testContainsEntryWithIncomparableValue() {
Reported by PMD.
android/guava-tests/test/com/google/common/cache/ForwardingLoadingCacheTest.java
36 issues
Line: 33
*
* @author Charles Fry
*/
public class ForwardingLoadingCacheTest extends TestCase {
private LoadingCache<String, Boolean> forward;
private LoadingCache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
Reported by PMD.
Line: 34
* @author Charles Fry
*/
public class ForwardingLoadingCacheTest extends TestCase {
private LoadingCache<String, Boolean> forward;
private LoadingCache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 35
*/
public class ForwardingLoadingCacheTest extends TestCase {
private LoadingCache<String, Boolean> forward;
private LoadingCache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 37
private LoadingCache<String, Boolean> forward;
private LoadingCache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
public void setUp() throws Exception {
super.setUp();
/*
* Class parameters must be raw, so we can't create a proxy with generic
Reported by PMD.
Line: 56
};
}
public void testGet() throws ExecutionException {
when(mock.get("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.get("key"));
}
public void testGetUnchecked() {
Reported by PMD.
Line: 57
}
public void testGet() throws ExecutionException {
when(mock.get("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.get("key"));
}
public void testGetUnchecked() {
when(mock.getUnchecked("key")).thenReturn(Boolean.TRUE);
Reported by PMD.
Line: 57
}
public void testGet() throws ExecutionException {
when(mock.get("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.get("key"));
}
public void testGetUnchecked() {
when(mock.getUnchecked("key")).thenReturn(Boolean.TRUE);
Reported by PMD.
Line: 58
public void testGet() throws ExecutionException {
when(mock.get("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.get("key"));
}
public void testGetUnchecked() {
when(mock.getUnchecked("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getUnchecked("key"));
Reported by PMD.
Line: 61
assertSame(Boolean.TRUE, forward.get("key"));
}
public void testGetUnchecked() {
when(mock.getUnchecked("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getUnchecked("key"));
}
public void testGetAll() throws ExecutionException {
Reported by PMD.
Line: 62
}
public void testGetUnchecked() {
when(mock.getUnchecked("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getUnchecked("key"));
}
public void testGetAll() throws ExecutionException {
when(mock.getAll(ImmutableList.of("key"))).thenReturn(ImmutableMap.of("key", Boolean.TRUE));
Reported by PMD.