The following issues were found

guava-testlib/src/com/google/common/collect/testing/testers/CollectionCreationTester.java
6 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: 41

              @GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionCreationTester<E> extends AbstractCollectionTester<E> {
  @CollectionFeature.Require(ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testCreateWithNull_supported() {
    E[] array = createArrayWithNullElement();
    collection = getSubjectGenerator().create(array);
    expectContents(array);

            

Reported by PMD.

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

Line: 45

                @CollectionSize.Require(absent = ZERO)
  public void testCreateWithNull_supported() {
    E[] array = createArrayWithNullElement();
    collection = getSubjectGenerator().create(array);
    expectContents(array);
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)

            

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: 49

                  expectContents(array);
  }

  @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES)
  @CollectionSize.Require(absent = ZERO)
  public void testCreateWithNull_unsupported() {
    E[] array = createArrayWithNullElement();

    try {

            

Reported by PMD.

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

Line: 55

                  E[] array = createArrayWithNullElement();

    try {
      getSubjectGenerator().create(array);
      fail("Creating a collection containing null should fail");
    } catch (NullPointerException expected) {
    }
  }


            

Reported by PMD.

Avoid catching NullPointerException; consider removing the cause of the NPE.
Error

Line: 57

                  try {
      getSubjectGenerator().create(array);
      fail("Creating a collection containing null should fail");
    } catch (NullPointerException expected) {
    }
  }

  /**
   * Returns the {@link Method} instance for {@link #testCreateWithNull_unsupported()} so that tests

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 57

                  try {
      getSubjectGenerator().create(array);
      fail("Creating a collection containing null should fail");
    } catch (NullPointerException expected) {
    }
  }

  /**
   * Returns the {@link Method} instance for {@link #testCreateWithNull_unsupported()} so that tests

            

Reported by PMD.

guava-tests/test/com/google/common/eventbus/ReentrantEventsTest.java
6 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

                static final String FIRST = "one";
  static final Double SECOND = 2.0d;

  final EventBus bus = new EventBus();

  public void testNoReentrantEvents() {
    ReentrantEventsHater hater = new ReentrantEventsHater();
    bus.register(hater);


            

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: 35

              
  final EventBus bus = new EventBus();

  public void testNoReentrantEvents() {
    ReentrantEventsHater hater = new ReentrantEventsHater();
    bus.register(hater);

    bus.post(FIRST);


            

Reported by PMD.

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

Line: 48

                }

  public class ReentrantEventsHater {
    boolean ready = true;
    List<Object> eventsReceived = Lists.newArrayList();

    @Subscribe
    public void listenForStrings(String event) {
      eventsReceived.add(event);

            

Reported by PMD.

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

Line: 49

              
  public class ReentrantEventsHater {
    boolean ready = true;
    List<Object> eventsReceived = Lists.newArrayList();

    @Subscribe
    public void listenForStrings(String event) {
      eventsReceived.add(event);
      ready = false;

            

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

                  }
  }

  public void testEventOrderingIsPredictable() {
    EventProcessor processor = new EventProcessor();
    bus.register(processor);

    EventRecorder recorder = new EventRecorder();
    bus.register(recorder);

            

Reported by PMD.

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

Line: 92

                }

  public class EventRecorder {
    List<Object> eventsReceived = Lists.newArrayList();

    @Subscribe
    public void listenForEverything(Object event) {
      eventsReceived.add(event);
    }

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/CollectionEqualsTester.java
6 issues
Avoid using equals() to compare against null
Error

Line: 40

              
  public void testEquals_null() {
    // noinspection ObjectEqualsNull
    assertFalse("An object should not be equal to null.", collection.equals(null));
  }

  public void testEquals_notACollection() {
    // noinspection EqualsBetweenInconvertibleTypes
    assertFalse(

            

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: 33

              public class CollectionEqualsTester<E> extends AbstractCollectionTester<E> {

  // TODO(cpovirk): Consider using EqualsTester from Guava.
  @SuppressWarnings("SelfEquals")
  public void testEquals_self() {
    assertTrue("An Object should be equal to itself.", collection.equals(collection));
  }

  public void testEquals_null() {

            

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: 38

                  assertTrue("An Object should be equal to itself.", collection.equals(collection));
  }

  public void testEquals_null() {
    // noinspection ObjectEqualsNull
    assertFalse("An object should not be equal to null.", collection.equals(null));
  }

  public void testEquals_notACollection() {

            

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: 43

                  assertFalse("An object should not be equal to null.", collection.equals(null));
  }

  public void testEquals_notACollection() {
    // noinspection EqualsBetweenInconvertibleTypes
    assertFalse(
        "A Collection should never equal an object that is not a Collection.",
        collection.equals("huh?"));
  }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 47

                  // noinspection EqualsBetweenInconvertibleTypes
    assertFalse(
        "A Collection should never equal an object that is not a Collection.",
        collection.equals("huh?"));
  }
}

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 47

                  // noinspection EqualsBetweenInconvertibleTypes
    assertFalse(
        "A Collection should never equal an object that is not a Collection.",
        collection.equals("huh?"));
  }
}

            

Reported by PMD.

guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java
6 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 32

              public class SplitterBenchmark {
  // overall size of string
  @Param({"1", "10", "100", "1000"})
  int length;
  // Number of matching strings
  @Param({"xxxx", "xxXx", "xXxX", "XXXX"})
  String text;

  private String input;

            

Reported by PMD.

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

Line: 35

                int length;
  // Number of matching strings
  @Param({"xxxx", "xxXx", "xXxX", "XXXX"})
  String text;

  private String input;

  private static final Splitter CHAR_SPLITTER = Splitter.on('X');
  private static final Splitter STRING_SPLITTER = Splitter.on("X");

            

Reported by PMD.

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

Line: 37

                @Param({"xxxx", "xxXx", "xXxX", "XXXX"})
  String text;

  private String input;

  private static final Splitter CHAR_SPLITTER = Splitter.on('X');
  private static final Splitter STRING_SPLITTER = Splitter.on("X");

  @BeforeExperiment

            

Reported by PMD.

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

Line: 42

                private static final Splitter CHAR_SPLITTER = Splitter.on('X');
  private static final Splitter STRING_SPLITTER = Splitter.on("X");

  @BeforeExperiment
  void setUp() {
    input = Strings.repeat(text, length);
  }

  @Benchmark

            

Reported by PMD.

Found 'DU'-anomaly for variable 'total' (lines '49'-'54').
Error

Line: 49

              
  @Benchmark
  void charSplitter(int reps) {
    int total = 0;

    for (int i = 0; i < reps; i++) {
      total += Iterables.size(CHAR_SPLITTER.split(input));
    }
  }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'total' (lines '58'-'63').
Error

Line: 58

              
  @Benchmark
  void stringSplitter(int reps) {
    int total = 0;

    for (int i = 0; i < reps; i++) {
      total += Iterables.size(STRING_SPLITTER.split(input));
    }
  }

            

Reported by PMD.

guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java
6 issues
This class has too many methods, consider refactoring it.
Design

Line: 48

               */
@GwtIncompatible
class SameThreadScheduledExecutorService extends AbstractExecutorService
    implements ListeningScheduledExecutorService {

  private final ListeningExecutorService delegate = newDirectExecutorService();

  @Override
  public void shutdown() {

            

Reported by PMD.

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

Line: 50

              class SameThreadScheduledExecutorService extends AbstractExecutorService
    implements ListeningScheduledExecutorService {

  private final ListeningExecutorService delegate = newDirectExecutorService();

  @Override
  public void shutdown() {
    delegate.shutdown();
  }

            

Reported by PMD.

The String literal 'unit must not be null!' appears 7 times in this file; the first occurrence is on line 74
Error

Line: 74

              
  @Override
  public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
    Preconditions.checkNotNull(unit, "unit must not be null!");
    return delegate.awaitTermination(timeout, unit);
  }

  @Override
  public <T> ListenableFuture<T> submit(Callable<T> task) {

            

Reported by PMD.

The String literal 'tasks must not be null!' appears 4 times in this file; the first occurrence is on line 100
Error

Line: 100

                @Override
  public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
      throws InterruptedException {
    Preconditions.checkNotNull(tasks, "tasks must not be null!");
    return delegate.invokeAll(tasks);
  }

  @Override
  public <T> List<Future<T>> invokeAll(

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 138

                public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
    Preconditions.checkNotNull(command, "command must not be null");
    Preconditions.checkNotNull(unit, "unit must not be null!");
    return schedule(java.util.concurrent.Executors.callable(command), delay, unit);
  }

  @Override
  public <V> ListenableScheduledFuture<V> schedule(
      final Callable<V> callable, long delay, TimeUnit unit) {

            

Reported by PMD.

Avoid unused private fields such as 'exception'.
Design

Line: 152

              
  private static class ImmediateScheduledFuture<V> extends SimpleForwardingListenableFuture<V>
      implements ListenableScheduledFuture<V> {
    private ExecutionException exception;

    protected ImmediateScheduledFuture(ListenableFuture<V> future) {
      super(future);
    }


            

Reported by PMD.

guava-tests/test/com/google/common/base/StopwatchJavaTimeTest.java
6 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 27

              /** Unit test for the {@code java.time} support in {@link Stopwatch}. */
@GwtIncompatible
public class StopwatchJavaTimeTest extends TestCase {
  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testElapsed_duration() {
    stopwatch.start();
    ticker.advance(999999);

            

Reported by PMD.

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

Line: 28

              @GwtIncompatible
public class StopwatchJavaTimeTest extends TestCase {
  private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testElapsed_duration() {
    stopwatch.start();
    ticker.advance(999999);
    assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());

            

Reported by PMD.

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

Line: 30

                private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testElapsed_duration() {
    stopwatch.start();
    ticker.advance(999999);
    assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());
    ticker.advance(1);
    assertEquals(Duration.ofMillis(1), stopwatch.elapsed());

            

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: 30

                private final FakeTicker ticker = new FakeTicker();
  private final Stopwatch stopwatch = new Stopwatch(ticker);

  public void testElapsed_duration() {
    stopwatch.start();
    ticker.advance(999999);
    assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());
    ticker.advance(1);
    assertEquals(Duration.ofMillis(1), stopwatch.elapsed());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                public void testElapsed_duration() {
    stopwatch.start();
    ticker.advance(999999);
    assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());
    ticker.advance(1);
    assertEquals(Duration.ofMillis(1), stopwatch.elapsed());
  }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                  ticker.advance(999999);
    assertEquals(Duration.ofNanos(999999), stopwatch.elapsed());
    ticker.advance(1);
    assertEquals(Duration.ofMillis(1), stopwatch.elapsed());
  }
}

            

Reported by PMD.

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

Line: 31

              public class HashMultisetAddPresentBenchmark {
  private static final int ARRAY_MASK = 0x0ffff;
  private static final int ARRAY_SIZE = 0x10000;
  List<Multiset<Integer>> multisets = new ArrayList<>(0x10000);
  int[] queries = new int[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    Random random = new Random();

            

Reported by PMD.

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

Line: 32

                private static final int ARRAY_MASK = 0x0ffff;
  private static final int ARRAY_SIZE = 0x10000;
  List<Multiset<Integer>> multisets = new ArrayList<>(0x10000);
  int[] queries = new int[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    Random random = new Random();
    multisets.clear();

            

Reported by PMD.

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

Line: 34

                List<Multiset<Integer>> multisets = new ArrayList<>(0x10000);
  int[] queries = new int[ARRAY_SIZE];

  @BeforeExperiment
  void setUp() {
    Random random = new Random();
    multisets.clear();
    for (int i = 0; i < ARRAY_SIZE; i++) {
      HashMultiset<Integer> multiset = HashMultiset.<Integer>create();

            

Reported by PMD.

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

Line: 42

                    HashMultiset<Integer> multiset = HashMultiset.<Integer>create();
      multisets.add(multiset);
      queries[i] = random.nextInt();
      multiset.add(queries[i]);
    }
  }

  @Benchmark
  int add(int reps) {

            

Reported by PMD.

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

Line: 51

                  int tmp = 0;
    for (int i = 0; i < reps; i++) {
      int j = i & ARRAY_MASK;
      tmp += multisets.get(j).add(queries[j], 4);
    }
    return tmp;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'random' (lines '36'-'44').
Error

Line: 36

              
  @BeforeExperiment
  void setUp() {
    Random random = new Random();
    multisets.clear();
    for (int i = 0; i < ARRAY_SIZE; i++) {
      HashMultiset<Integer> multiset = HashMultiset.<Integer>create();
      multisets.add(multiset);
      queries[i] = random.nextInt();

            

Reported by PMD.

guava-testlib/src/com/google/common/testing/EqualsTester.java
6 issues
Avoid using equals() to compare against null
Error

Line: 121

              
  private void testItems() {
    for (Object item : Iterables.concat(equalityGroups)) {
      assertTrue(item + " must not be Object#equals to null", !item.equals(null));
      assertTrue(
          item + " must not be Object#equals to an arbitrary object of another class",
          !item.equals(NotAnInstance.EQUAL_TO_NOTHING));
      assertEquals(item + " must be Object#equals to itself", item, item);
      assertEquals(

            

Reported by PMD.

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

Line: 82

              public final class EqualsTester {
  private static final int REPETITIONS = 3;

  private final List<List<Object>> equalityGroups = Lists.newArrayList();
  private final RelationshipTester.ItemReporter itemReporter;

  /** Constructs an empty EqualsTester instance */
  public EqualsTester() {
    this(new RelationshipTester.ItemReporter());

            

Reported by PMD.

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

Line: 83

                private static final int REPETITIONS = 3;

  private final List<List<Object>> equalityGroups = Lists.newArrayList();
  private final RelationshipTester.ItemReporter itemReporter;

  /** Constructs an empty EqualsTester instance */
  public EqualsTester() {
    this(new RelationshipTester.ItemReporter());
  }

            

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: 105

                }

  /** Run tests on equals method, throwing a failure on an invalid test */
  public EqualsTester testEquals() {
    RelationshipTester<Object> delegate =
        new RelationshipTester<>(
            Equivalence.equals(), "Object#equals", "Object#hashCode", itemReporter);
    for (List<Object> group : equalityGroups) {
      delegate.addRelatedGroup(group);

            

Reported by PMD.

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

Line: 119

                  return this;
  }

  private void testItems() {
    for (Object item : Iterables.concat(equalityGroups)) {
      assertTrue(item + " must not be Object#equals to null", !item.equals(null));
      assertTrue(
          item + " must not be Object#equals to an arbitrary object of another class",
          !item.equals(NotAnInstance.EQUAL_TO_NOTHING));

            

Reported by PMD.

Found 'DU'-anomaly for variable 'delegate' (lines '106'-'117').
Error

Line: 106

              
  /** Run tests on equals method, throwing a failure on an invalid test */
  public EqualsTester testEquals() {
    RelationshipTester<Object> delegate =
        new RelationshipTester<>(
            Equivalence.equals(), "Object#equals", "Object#hashCode", itemReporter);
    for (List<Object> group : equalityGroups) {
      delegate.addRelatedGroup(group);
    }

            

Reported by PMD.

guava-tests/benchmark/com/google/common/collect/InternersBenchmark.java
6 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 48

                @Benchmark
  int stringIntern(int reps) {
    for (int i = 0; i < reps; i++) {
      String unused = Double.toHexString(Math.random()).intern();
    }
    return reps;
  }
}

            

Reported by PMD.

Avoid unused local variables such as 'unused'.
Design

Line: 48

                @Benchmark
  int stringIntern(int reps) {
    for (int i = 0; i < reps; i++) {
      String unused = Double.toHexString(Math.random()).intern();
    }
    return reps;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'interner' (lines '29'-'34').
Error

Line: 29

              public class InternersBenchmark {
  @Benchmark
  int weakInterner(int reps) {
    Interner<String> interner = Interners.newWeakInterner();
    for (int i = 0; i < reps; i++) {
      interner.intern(Double.toHexString(Math.random()));
    }
    return reps;
  }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'interner' (lines '38'-'43').
Error

Line: 38

              
  @Benchmark
  int strongInterner(int reps) {
    Interner<String> interner = Interners.newStrongInterner();
    for (int i = 0; i < reps; i++) {
      interner.intern(Double.toHexString(Math.random()));
    }
    return reps;
  }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'unused' (lines '48'-'48').
Error

Line: 48

                @Benchmark
  int stringIntern(int reps) {
    for (int i = 0; i < reps; i++) {
      String unused = Double.toHexString(Math.random()).intern();
    }
    return reps;
  }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'unused' (lines '48'-'51').
Error

Line: 48

                @Benchmark
  int stringIntern(int reps) {
    for (int i = 0; i < reps; i++) {
      String unused = Double.toHexString(Math.random()).intern();
    }
    return reps;
  }
}

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/testers/ListAddAllTester.java
6 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: 38

              @GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddAllTester<E> extends AbstractListTester<E> {
  @CollectionFeature.Require(SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAll_supportedAllPresent() {
    assertTrue(
        "addAll(allPresent) should return true", getList().addAll(MinimalCollection.of(e0())));
    expectAdded(e0());

            

Reported by PMD.

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

Line: 42

                @CollectionSize.Require(absent = ZERO)
  public void testAddAll_supportedAllPresent() {
    assertTrue(
        "addAll(allPresent) should return true", getList().addAll(MinimalCollection.of(e0())));
    expectAdded(e0());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)

            

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

                  expectAdded(e0());
  }

  @CollectionFeature.Require(absent = SUPPORTS_ADD)
  @CollectionSize.Require(absent = ZERO)
  public void testAddAll_unsupportedAllPresent() {
    try {
      getList().addAll(MinimalCollection.of(e0()));
      fail("addAll(allPresent) should throw");

            

Reported by PMD.

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

Line: 50

                @CollectionSize.Require(absent = ZERO)
  public void testAddAll_unsupportedAllPresent() {
    try {
      getList().addAll(MinimalCollection.of(e0()));
      fail("addAll(allPresent) should throw");
    } catch (UnsupportedOperationException expected) {
    }
    expectUnchanged();
  }

            

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

                  expectUnchanged();
  }

  @CollectionFeature.Require(SUPPORTS_ADD)
  public void testAddAll_withDuplicates() {
    MinimalCollection<E> elementsToAdd = MinimalCollection.of(e0(), e1(), e0(), e1());
    assertTrue("addAll(hasDuplicates) should return true", getList().addAll(elementsToAdd));
    expectAdded(e0(), e1(), e0(), e1());
  }

            

Reported by PMD.

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

Line: 60

                @CollectionFeature.Require(SUPPORTS_ADD)
  public void testAddAll_withDuplicates() {
    MinimalCollection<E> elementsToAdd = MinimalCollection.of(e0(), e1(), e0(), e1());
    assertTrue("addAll(hasDuplicates) should return true", getList().addAll(elementsToAdd));
    expectAdded(e0(), e1(), e0(), e1());
  }
}

            

Reported by PMD.