The following issues were found

android/guava-testlib/src/com/google/common/collect/testing/google/BiMapClearTester.java
40 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 34

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 35

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 36

              public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 37

                @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 38

                public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 39

                  BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 42

                  assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 43

                }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 44

              
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 45

                @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

android/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java
40 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 49

               */
public class ConcurrentHashMultisetBenchmark {
  @Param({"1", "2", "4", "8"})
  int threads;

  @Param({"3", "30", "300"})
  int size;

  @Param MultisetSupplier implSupplier;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 52

                int threads;

  @Param({"3", "30", "300"})
  int size;

  @Param MultisetSupplier implSupplier;

  private Multiset<Integer> multiset;
  private ImmutableList<Integer> keys;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 54

                @Param({"3", "30", "300"})
  int size;

  @Param MultisetSupplier implSupplier;

  private Multiset<Integer> multiset;
  private ImmutableList<Integer> keys;
  private ExecutorService threadPool;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 56

              
  @Param MultisetSupplier implSupplier;

  private Multiset<Integer> multiset;
  private ImmutableList<Integer> keys;
  private ExecutorService threadPool;

  @BeforeExperiment
  void setUp() throws Exception {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 57

                @Param MultisetSupplier implSupplier;

  private Multiset<Integer> multiset;
  private ImmutableList<Integer> keys;
  private ExecutorService threadPool;

  @BeforeExperiment
  void setUp() throws Exception {
    multiset = implSupplier.get();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 58

              
  private Multiset<Integer> multiset;
  private ImmutableList<Integer> keys;
  private ExecutorService threadPool;

  @BeforeExperiment
  void setUp() throws Exception {
    multiset = implSupplier.get();
    ImmutableList.Builder<Integer> builder = ImmutableList.builder();

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 60

                private ImmutableList<Integer> keys;
  private ExecutorService threadPool;

  @BeforeExperiment
  void setUp() throws Exception {
    multiset = implSupplier.get();
    ImmutableList.Builder<Integer> builder = ImmutableList.builder();
    for (int i = 0; i < size; i++) {
      builder.add(i);

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 61

                private ExecutorService threadPool;

  @BeforeExperiment
  void setUp() throws Exception {
    multiset = implSupplier.get();
    ImmutableList.Builder<Integer> builder = ImmutableList.builder();
    for (int i = 0; i < size; i++) {
      builder.add(i);
    }

            

Reported by PMD.

Possible God Class (WMC=51, ATFD=7, TCC=24.308%)
Design

Line: 168

                 * Duplication of the old version of ConcurrentHashMultiset (with some unused stuff removed, like
   * serialization code) which used a map with boxed integers for the values.
   */
  private static final class OldConcurrentHashMultiset<E> extends AbstractMultiset<E> {
    /** The number of occurrences of each element. */
    private final transient ConcurrentMap<E, Integer> countMap;

    /**
     * Creates a new, empty {@code OldConcurrentHashMultiset} using the default initial capacity,

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 168

                 * Duplication of the old version of ConcurrentHashMultiset (with some unused stuff removed, like
   * serialization code) which used a map with boxed integers for the values.
   */
  private static final class OldConcurrentHashMultiset<E> extends AbstractMultiset<E> {
    /** The number of occurrences of each element. */
    private final transient ConcurrentMap<E, Integer> countMap;

    /**
     * Creates a new, empty {@code OldConcurrentHashMultiset} using the default initial capacity,

            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/MultimapClearTester.java
40 issues
This class has too many methods, consider refactoring it.
Design

Line: 40

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapClearTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(absent = SUPPORTS_REMOVE)
  public void testClearUnsupported() {
    try {
      multimap().clear();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 41

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapClearTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(absent = SUPPORTS_REMOVE)
  public void testClearUnsupported() {
    try {
      multimap().clear();
      fail("Expected UnsupportedOperationException");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 45

                @MapFeature.Require(absent = SUPPORTS_REMOVE)
  public void testClearUnsupported() {
    try {
      multimap().clear();
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException expected) {
    }
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 52

                }

  private void assertCleared() {
    assertEquals(0, multimap().size());
    assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

                private void assertCleared() {
    assertEquals(0, multimap().size());
    assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 55

                  assertEquals(0, multimap().size());
    assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 56

                  assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 57

                  assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 58

                  assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);
    }
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 59

                  assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);
    }
  }


            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/BiMapClearTester.java
40 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 34

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 35

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 36

              public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 37

                @MapFeature.Require(SUPPORTS_REMOVE)
  public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 38

                public void testClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 39

                  BiMap<V, K> inv = getMap().inverse();
    getMap().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 42

                  assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 43

                }

  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 44

              
  @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 45

                @MapFeature.Require(SUPPORTS_REMOVE)
  public void testKeySetClearClearsInverse() {
    BiMap<V, K> inv = getMap().inverse();
    getMap().keySet().clear();
    assertTrue(getMap().isEmpty());
    assertTrue(inv.isEmpty());
  }

  @MapFeature.Require(SUPPORTS_REMOVE)

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/TestThread.java
40 issues
This class has too many methods, consider refactoring it.
Design

Line: 51

               * @param <L> the type of the lock-like object to be used
 * @author Justin T. Sampson
 */
public final class TestThread<L> extends Thread implements TearDown {

  private static final long DUE_DILIGENCE_MILLIS = 100;
  private static final long TIMEOUT_MILLIS = 5000;

  private final L lockLikeObject;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 56

                private static final long DUE_DILIGENCE_MILLIS = 100;
  private static final long TIMEOUT_MILLIS = 5000;

  private final L lockLikeObject;

  private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 58

              
  private final L lockLikeObject;

  private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 59

                private final L lockLikeObject;

  private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {
    super(threadName);

            

Reported by PMD.

Avoid using redundant field initializer for 'uncaughtThrowable'
Performance

Line: 61

                private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {
    super(threadName);
    this.lockLikeObject = checkNotNull(lockLikeObject);
    start();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 61

                private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {
    super(threadName);
    this.lockLikeObject = checkNotNull(lockLikeObject);
    start();

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 73

                // so there is no object state put at risk by stopping the threads abruptly. In some cases a test
  // may put a thread into an uninterruptible operation intentionally, so there is no other way to
  // clean up these threads.
  @SuppressWarnings("deprecation")
  @Override
  public void tearDown() throws Exception {
    stop();
    join();


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 89

                /**
   * Causes this thread to call the named void method, and asserts that the call returns normally.
   */
  public void callAndAssertReturns(String methodName, Object... arguments) throws Exception {
    checkNotNull(methodName);
    checkNotNull(arguments);
    sendRequest(methodName, arguments);
    assertSame(null, getResponse(methodName).getResult());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 93

                  checkNotNull(methodName);
    checkNotNull(arguments);
    sendRequest(methodName, arguments);
    assertSame(null, getResponse(methodName).getResult());
  }

  /**
   * Causes this thread to call the named method, and asserts that the call returns the expected
   * boolean value.

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 101

                 * boolean value.
   */
  public void callAndAssertReturns(boolean expected, String methodName, Object... arguments)
      throws Exception {
    checkNotNull(methodName);
    checkNotNull(arguments);
    sendRequest(methodName, arguments);
    assertEquals(expected, getResponse(methodName).getResult());
  }

            

Reported by PMD.

android/guava-tests/test/com/google/common/util/concurrent/WrappingExecutorServiceTest.java
40 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 46

              public class WrappingExecutorServiceTest extends TestCase {
  private static final String RESULT_VALUE = "ran";
  // Uninteresting delegations
  public void testDelegations() throws InterruptedException {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 46

              public class WrappingExecutorServiceTest extends TestCase {
  private static final String RESULT_VALUE = "ran";
  // Uninteresting delegations
  public void testDelegations() throws InterruptedException {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                public void testDelegations() throws InterruptedException {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());
    mock.assertLastMethodCalled("isTerminated");
    assertFalse(testExecutor.isShutdown());
    mock.assertLastMethodCalled("isShutdown");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                  TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());
    mock.assertLastMethodCalled("isTerminated");
    assertFalse(testExecutor.isShutdown());
    mock.assertLastMethodCalled("isShutdown");
    testExecutor.shutdown();
    mock.assertLastMethodCalled("shutdown");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());
    mock.assertLastMethodCalled("isTerminated");
    assertFalse(testExecutor.isShutdown());
    mock.assertLastMethodCalled("isShutdown");
    testExecutor.shutdown();
    mock.assertLastMethodCalled("shutdown");
    List<Runnable> list = testExecutor.shutdownNow();
    mock.assertLastMethodCalled("shutdownNow");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                  mock.assertLastMethodCalled("shutdown");
    List<Runnable> list = testExecutor.shutdownNow();
    mock.assertLastMethodCalled("shutdownNow");
    assertEquals(ImmutableList.of(), list);
  }

  public void testExecute() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 62

                  assertEquals(ImmutableList.of(), list);
  }

  public void testExecute() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    testExecutor.execute(doNothing());
    mock.assertLastMethodCalled("execute");
  }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 62

                  assertEquals(ImmutableList.of(), list);
  }

  public void testExecute() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    testExecutor.execute(doNothing());
    mock.assertLastMethodCalled("execute");
  }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 69

                  mock.assertLastMethodCalled("execute");
  }

  public void testSubmit() throws InterruptedException, ExecutionException {
    {
      MockExecutor mock = new MockExecutor();
      TestExecutor testExecutor = new TestExecutor(mock);
      Future<?> f = testExecutor.submit(doNothing());
      mock.assertLastMethodCalled("submit");

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 69

                  mock.assertLastMethodCalled("execute");
  }

  public void testSubmit() throws InterruptedException, ExecutionException {
    {
      MockExecutor mock = new MockExecutor();
      TestExecutor testExecutor = new TestExecutor(mock);
      Future<?> f = testExecutor.submit(doNothing());
      mock.assertLastMethodCalled("submit");

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/MultimapClearTester.java
40 issues
This class has too many methods, consider refactoring it.
Design

Line: 40

               */
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapClearTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(absent = SUPPORTS_REMOVE)
  public void testClearUnsupported() {
    try {
      multimap().clear();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 41

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapClearTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
  @CollectionSize.Require(absent = ZERO)
  @MapFeature.Require(absent = SUPPORTS_REMOVE)
  public void testClearUnsupported() {
    try {
      multimap().clear();
      fail("Expected UnsupportedOperationException");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 45

                @MapFeature.Require(absent = SUPPORTS_REMOVE)
  public void testClearUnsupported() {
    try {
      multimap().clear();
      fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException expected) {
    }
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 52

                }

  private void assertCleared() {
    assertEquals(0, multimap().size());
    assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

                private void assertCleared() {
    assertEquals(0, multimap().size());
    assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 55

                  assertEquals(0, multimap().size());
    assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 56

                  assertEmpty(multimap());
    assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 57

                  assertEquals(multimap(), getSubjectGenerator().create());
    assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 58

                  assertEmpty(multimap().entries());
    assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);
    }
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 59

                  assertEmpty(multimap().asMap());
    assertEmpty(multimap().keySet());
    assertEmpty(multimap().keys());
    assertEmpty(multimap().values());
    for (K key : sampleKeys()) {
      assertGet(key);
    }
  }


            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/WrappingExecutorServiceTest.java
40 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 46

              public class WrappingExecutorServiceTest extends TestCase {
  private static final String RESULT_VALUE = "ran";
  // Uninteresting delegations
  public void testDelegations() throws InterruptedException {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 46

              public class WrappingExecutorServiceTest extends TestCase {
  private static final String RESULT_VALUE = "ran";
  // Uninteresting delegations
  public void testDelegations() throws InterruptedException {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 49

                public void testDelegations() throws InterruptedException {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());
    mock.assertLastMethodCalled("isTerminated");
    assertFalse(testExecutor.isShutdown());
    mock.assertLastMethodCalled("isShutdown");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 51

                  TestExecutor testExecutor = new TestExecutor(mock);
    assertFalse(testExecutor.awaitTermination(10, TimeUnit.MILLISECONDS));
    mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());
    mock.assertLastMethodCalled("isTerminated");
    assertFalse(testExecutor.isShutdown());
    mock.assertLastMethodCalled("isShutdown");
    testExecutor.shutdown();
    mock.assertLastMethodCalled("shutdown");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 53

                  mock.assertLastMethodCalled("awaitTermination");
    assertFalse(testExecutor.isTerminated());
    mock.assertLastMethodCalled("isTerminated");
    assertFalse(testExecutor.isShutdown());
    mock.assertLastMethodCalled("isShutdown");
    testExecutor.shutdown();
    mock.assertLastMethodCalled("shutdown");
    List<Runnable> list = testExecutor.shutdownNow();
    mock.assertLastMethodCalled("shutdownNow");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 59

                  mock.assertLastMethodCalled("shutdown");
    List<Runnable> list = testExecutor.shutdownNow();
    mock.assertLastMethodCalled("shutdownNow");
    assertEquals(ImmutableList.of(), list);
  }

  public void testExecute() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 62

                  assertEquals(ImmutableList.of(), list);
  }

  public void testExecute() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    testExecutor.execute(doNothing());
    mock.assertLastMethodCalled("execute");
  }

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 62

                  assertEquals(ImmutableList.of(), list);
  }

  public void testExecute() {
    MockExecutor mock = new MockExecutor();
    TestExecutor testExecutor = new TestExecutor(mock);
    testExecutor.execute(doNothing());
    mock.assertLastMethodCalled("execute");
  }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 69

                  mock.assertLastMethodCalled("execute");
  }

  public void testSubmit() throws InterruptedException, ExecutionException {
    {
      MockExecutor mock = new MockExecutor();
      TestExecutor testExecutor = new TestExecutor(mock);
      Future<?> f = testExecutor.submit(doNothing());
      mock.assertLastMethodCalled("submit");

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 69

                  mock.assertLastMethodCalled("execute");
  }

  public void testSubmit() throws InterruptedException, ExecutionException {
    {
      MockExecutor mock = new MockExecutor();
      TestExecutor testExecutor = new TestExecutor(mock);
      Future<?> f = testExecutor.submit(doNothing());
      mock.assertLastMethodCalled("submit");

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/TestThread.java
40 issues
This class has too many methods, consider refactoring it.
Design

Line: 51

               * @param <L> the type of the lock-like object to be used
 * @author Justin T. Sampson
 */
public final class TestThread<L> extends Thread implements TearDown {

  private static final long DUE_DILIGENCE_MILLIS = 100;
  private static final long TIMEOUT_MILLIS = 5000;

  private final L lockLikeObject;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 56

                private static final long DUE_DILIGENCE_MILLIS = 100;
  private static final long TIMEOUT_MILLIS = 5000;

  private final L lockLikeObject;

  private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 58

              
  private final L lockLikeObject;

  private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 59

                private final L lockLikeObject;

  private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {
    super(threadName);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 61

                private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {
    super(threadName);
    this.lockLikeObject = checkNotNull(lockLikeObject);
    start();

            

Reported by PMD.

Avoid using redundant field initializer for 'uncaughtThrowable'
Performance

Line: 61

                private final SynchronousQueue<Request> requestQueue = new SynchronousQueue<>();
  private final SynchronousQueue<Response> responseQueue = new SynchronousQueue<>();

  private Throwable uncaughtThrowable = null;

  public TestThread(L lockLikeObject, String threadName) {
    super(threadName);
    this.lockLikeObject = checkNotNull(lockLikeObject);
    start();

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 73

                // so there is no object state put at risk by stopping the threads abruptly. In some cases a test
  // may put a thread into an uninterruptible operation intentionally, so there is no other way to
  // clean up these threads.
  @SuppressWarnings("deprecation")
  @Override
  public void tearDown() throws Exception {
    stop();
    join();


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 89

                /**
   * Causes this thread to call the named void method, and asserts that the call returns normally.
   */
  public void callAndAssertReturns(String methodName, Object... arguments) throws Exception {
    checkNotNull(methodName);
    checkNotNull(arguments);
    sendRequest(methodName, arguments);
    assertSame(null, getResponse(methodName).getResult());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 93

                  checkNotNull(methodName);
    checkNotNull(arguments);
    sendRequest(methodName, arguments);
    assertSame(null, getResponse(methodName).getResult());
  }

  /**
   * Causes this thread to call the named method, and asserts that the call returns the expected
   * boolean value.

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 101

                 * boolean value.
   */
  public void callAndAssertReturns(boolean expected, String methodName, Object... arguments)
      throws Exception {
    checkNotNull(methodName);
    checkNotNull(arguments);
    sendRequest(methodName, arguments);
    assertEquals(expected, getResponse(methodName).getResult());
  }

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/MapRemoveTester.java
40 issues
This class has too many methods, consider refactoring it.
Design

Line: 46

              @SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapRemoveTester<K, V> extends AbstractMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    int initialSize = getMap().size();
    assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 47

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapRemoveTester<K, V> extends AbstractMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    int initialSize = getMap().size();
    assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
    assertEquals(

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 49

              public class MapRemoveTester<K, V> extends AbstractMapTester<K, V> {
  @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    int initialSize = getMap().size();
    assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
    assertEquals(
        "remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
    expectMissing(e0());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 50

                @MapFeature.Require(SUPPORTS_REMOVE)
  @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    int initialSize = getMap().size();
    assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
    assertEquals(
        "remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
    expectMissing(e0());
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 51

                @CollectionSize.Require(absent = ZERO)
  public void testRemove_present() {
    int initialSize = getMap().size();
    assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
    assertEquals(
        "remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
    expectMissing(e0());
  }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 53

                  int initialSize = getMap().size();
    assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
    assertEquals(
        "remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
    expectMissing(e0());
  }

  @MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_REMOVE})
  @CollectionSize.Require(SEVERAL)

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 57

                  expectMissing(e0());
  }

  @MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_REMOVE})
  @CollectionSize.Require(SEVERAL)
  public void testRemovePresentConcurrentWithEntrySetIteration() {
    try {
      Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
      getMap().remove(k0());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 61

                @CollectionSize.Require(SEVERAL)
  public void testRemovePresentConcurrentWithEntrySetIteration() {
    try {
      Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
      getMap().remove(k0());
      iterator.next();
      fail("Expected ConcurrentModificationException");
    } catch (ConcurrentModificationException expected) {
      // success

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 61

                @CollectionSize.Require(SEVERAL)
  public void testRemovePresentConcurrentWithEntrySetIteration() {
    try {
      Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
      getMap().remove(k0());
      iterator.next();
      fail("Expected ConcurrentModificationException");
    } catch (ConcurrentModificationException expected) {
      // success

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 62

                public void testRemovePresentConcurrentWithEntrySetIteration() {
    try {
      Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
      getMap().remove(k0());
      iterator.next();
      fail("Expected ConcurrentModificationException");
    } catch (ConcurrentModificationException expected) {
      // success
    }

            

Reported by PMD.