The following issues were found
android/guava-tests/test/com/google/common/base/VerifyTest.java
26 issues
Line: 28
/** Unit test for {@link com.google.common.base.Verify}. */
@GwtCompatible(emulated = true)
public class VerifyTest extends TestCase {
public void testVerify_simple_success() {
verify(true);
}
public void testVerify_simple_failure() {
Reported by PMD.
Line: 29
/** Unit test for {@link com.google.common.base.Verify}. */
@GwtCompatible(emulated = true)
public class VerifyTest extends TestCase {
public void testVerify_simple_success() {
verify(true);
}
public void testVerify_simple_failure() {
try {
Reported by PMD.
Line: 33
verify(true);
}
public void testVerify_simple_failure() {
try {
verify(false);
fail();
} catch (VerifyException expected) {
}
Reported by PMD.
Line: 36
public void testVerify_simple_failure() {
try {
verify(false);
fail();
} catch (VerifyException expected) {
}
}
public void testVerify_simpleMessage_success() {
Reported by PMD.
Line: 36
public void testVerify_simple_failure() {
try {
verify(false);
fail();
} catch (VerifyException expected) {
}
}
public void testVerify_simpleMessage_success() {
Reported by PMD.
Line: 41
}
}
public void testVerify_simpleMessage_success() {
verify(true, "message");
}
public void testVerify_simpleMessage_failure() {
try {
Reported by PMD.
Line: 45
verify(true, "message");
}
public void testVerify_simpleMessage_failure() {
try {
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
Reported by PMD.
Line: 48
public void testVerify_simpleMessage_failure() {
try {
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
}
}
Reported by PMD.
Line: 50
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
}
}
public void testVerify_complexMessage_success() {
verify(true, "%s", IGNORE_ME);
Reported by PMD.
Line: 50
verify(false, "message");
fail();
} catch (VerifyException expected) {
assertThat(expected).hasMessageThat().isEqualTo("message");
}
}
public void testVerify_complexMessage_success() {
verify(true, "%s", IGNORE_ME);
Reported by PMD.
android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
26 issues
Line: 46
// TODO(cpovirk): Figure out Android JUnit 4 support. Does it work with Gingerbread? @RunWith?
@RunWith(Parameterized.class)
public final class DefaultNetworkImplementationsTest {
private MutableNetwork<Integer, String> network;
private NetworkForTest<Integer, String> networkForTest;
private static final Integer N1 = 1;
private static final Integer N2 = 2;
private static final Integer NODE_NOT_IN_GRAPH = 1000;
private static final String E11 = "1-1";
Reported by PMD.
Line: 47
@RunWith(Parameterized.class)
public final class DefaultNetworkImplementationsTest {
private MutableNetwork<Integer, String> network;
private NetworkForTest<Integer, String> networkForTest;
private static final Integer N1 = 1;
private static final Integer N2 = 2;
private static final Integer NODE_NOT_IN_GRAPH = 1000;
private static final String E11 = "1-1";
private static final String E11_A = "1-1a";
Reported by PMD.
Line: 66
});
}
private final EdgeType edgeType;
public DefaultNetworkImplementationsTest(EdgeType edgeType) {
this.edgeType = edgeType;
}
Reported by PMD.
Line: 77
NetworkBuilder<Object, Object> builder =
(edgeType == EdgeType.DIRECTED) ? NetworkBuilder.directed() : NetworkBuilder.undirected();
network = builder.allowsSelfLoops(true).allowsParallelEdges(true).build();
networkForTest = NetworkForTest.from(network);
}
@Test
public void edgesConnecting_disconnectedNodes() {
Reported by PMD.
Line: 77
NetworkBuilder<Object, Object> builder =
(edgeType == EdgeType.DIRECTED) ? NetworkBuilder.directed() : NetworkBuilder.undirected();
network = builder.allowsSelfLoops(true).allowsParallelEdges(true).build();
networkForTest = NetworkForTest.from(network);
}
@Test
public void edgesConnecting_disconnectedNodes() {
Reported by PMD.
Line: 85
public void edgesConnecting_disconnectedNodes() {
network.addNode(N1);
network.addNode(N2);
assertThat(networkForTest.edgesConnecting(N1, N2)).isEmpty();
}
@Test
public void edgesConnecting_nodesNotInGraph() {
network.addNode(N1);
Reported by PMD.
Line: 89
}
@Test
public void edgesConnecting_nodesNotInGraph() {
network.addNode(N1);
network.addNode(N2);
try {
networkForTest.edgesConnecting(N1, NODE_NOT_IN_GRAPH);
fail(ERROR_NODE_NOT_IN_GRAPH);
Reported by PMD.
Line: 122
fail(ERROR_MODIFIABLE_COLLECTION);
} catch (UnsupportedOperationException e) {
network.addEdge(N1, N2, E12);
assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
}
@Test
public void edgesConnecting_oneEdge() {
Reported by PMD.
Line: 127
}
@Test
public void edgesConnecting_oneEdge() {
network.addEdge(N1, N2, E12);
assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactly(E12);
if (edgeType == EdgeType.DIRECTED) {
assertThat(networkForTest.edgesConnecting(N2, N1)).isEmpty();
} else {
Reported by PMD.
Line: 129
@Test
public void edgesConnecting_oneEdge() {
network.addEdge(N1, N2, E12);
assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactly(E12);
if (edgeType == EdgeType.DIRECTED) {
assertThat(networkForTest.edgesConnecting(N2, N1)).isEmpty();
} else {
assertThat(networkForTest.edgesConnecting(N2, N1)).containsExactly(E12);
}
Reported by PMD.
android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
26 issues
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 171
*/
@Beta
@GwtIncompatible
public final class ArbitraryInstances {
private static final Ordering<Field> BY_FIELD_NAME =
new Ordering<Field>() {
@Override
public int compare(Field left, Field right) {
Reported by PMD.
Line: 171
*/
@Beta
@GwtIncompatible
public final class ArbitraryInstances {
private static final Ordering<Field> BY_FIELD_NAME =
new Ordering<Field>() {
@Override
public int compare(Field left, Field right) {
Reported by PMD.
Line: 177
new Ordering<Field>() {
@Override
public int compare(Field left, Field right) {
return left.getName().compareTo(right.getName());
}
};
/**
* Returns a new {@code MatchResult} that corresponds to a successful match. Apache Harmony (used
Reported by PMD.
Line: 187
* http://goo.gl/5VQFmC
*/
private static MatchResult newMatchResult() {
Matcher matcher = Pattern.compile(".").matcher("X");
matcher.find();
return matcher.toMatchResult();
}
private static final ClassToInstanceMap<Object> DEFAULTS =
Reported by PMD.
Line: 188
*/
private static MatchResult newMatchResult() {
Matcher matcher = Pattern.compile(".").matcher("X");
matcher.find();
return matcher.toMatchResult();
}
private static final ClassToInstanceMap<Object> DEFAULTS =
ImmutableClassToInstanceMap.builder()
Reported by PMD.
Line: 189
private static MatchResult newMatchResult() {
Matcher matcher = Pattern.compile(".").matcher("X");
matcher.find();
return matcher.toMatchResult();
}
private static final ClassToInstanceMap<Object> DEFAULTS =
ImmutableClassToInstanceMap.builder()
// primitives
Reported by PMD.
Line: 342
* determined.
*/
@NullableDecl
public static <T> T get(Class<T> type) {
T defaultValue = DEFAULTS.getInstance(type);
if (defaultValue != null) {
return defaultValue;
}
Class<? extends T> implementation = getImplementation(type);
Reported by PMD.
Line: 342
* determined.
*/
@NullableDecl
public static <T> T get(Class<T> type) {
T defaultValue = DEFAULTS.getInstance(type);
if (defaultValue != null) {
return defaultValue;
}
Class<? extends T> implementation = getImplementation(type);
Reported by PMD.
android/guava-testlib/test/com/google/common/testing/TestLogHandlerTest.java
26 issues
Line: 31
*/
public class TestLogHandlerTest extends TestCase {
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 32
public class TestLogHandlerTest extends TestCase {
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 32
public class TestLogHandlerTest extends TestCase {
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 34
private TestLogHandler handler;
private TearDownStack stack = new TearDownStack();
@Override
protected void setUp() throws Exception {
super.setUp();
handler = new TestLogHandler();
Reported by PMD.
Line: 41
handler = new TestLogHandler();
// You could also apply it higher up the Logger hierarchy than this
ExampleClassUnderTest.logger.addHandler(handler);
ExampleClassUnderTest.logger.setUseParentHandlers(false); // optional
stack.addTearDown(
new TearDown() {
Reported by PMD.
Line: 43
// You could also apply it higher up the Logger hierarchy than this
ExampleClassUnderTest.logger.addHandler(handler);
ExampleClassUnderTest.logger.setUseParentHandlers(false); // optional
stack.addTearDown(
new TearDown() {
@Override
public void tearDown() throws Exception {
Reported by PMD.
Line: 47
stack.addTearDown(
new TearDown() {
@Override
public void tearDown() throws Exception {
ExampleClassUnderTest.logger.setUseParentHandlers(true);
ExampleClassUnderTest.logger.removeHandler(handler);
}
});
Reported by PMD.
Line: 49
new TearDown() {
@Override
public void tearDown() throws Exception {
ExampleClassUnderTest.logger.setUseParentHandlers(true);
ExampleClassUnderTest.logger.removeHandler(handler);
}
});
}
Reported by PMD.
Line: 50
@Override
public void tearDown() throws Exception {
ExampleClassUnderTest.logger.setUseParentHandlers(true);
ExampleClassUnderTest.logger.removeHandler(handler);
}
});
}
public void test() throws Exception {
Reported by PMD.
Line: 55
});
}
public void test() throws Exception {
assertTrue(handler.getStoredLogRecords().isEmpty());
ExampleClassUnderTest.foo();
LogRecord record = handler.getStoredLogRecords().get(0);
assertEquals(Level.INFO, record.getLevel());
assertEquals("message", record.getMessage());
Reported by PMD.
android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java
26 issues
Line: 100
@Override
Map<String, String> wrap(final HashMap<String, String> map) {
if (map.containsKey(null)) {
throw new NullPointerException();
}
return new AbstractMap<String, String>() {
@Override
public Set<Entry<String, String>> entrySet() {
return map.entrySet();
Reported by PMD.
Line: 126
@Override
Map<String, String> wrap(final HashMap<String, String> map) {
if (map.containsValue(null)) {
throw new NullPointerException();
}
return new AbstractMap<String, String>() {
@Override
public Set<Entry<String, String>> entrySet() {
Reported by PMD.
Line: 54
*
* @author George van den Driessche
*/
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}
public static Test suite() {
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
Reported by PMD.
Line: 57
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}
public static Test suite() {
TestSuite suite = new TestSuite(MapTestSuiteBuilderTests.class.getSimpleName());
suite.addTest(testsForHashMapNullKeysForbidden());
suite.addTest(testsForHashMapNullValuesForbidden());
suite.addTest(testsForSetUpTearDown());
return suite;
Reported by PMD.
Line: 75
return wrap(map);
}
abstract Map<String, String> wrap(HashMap<String, String> map);
}
private static TestSuite wrappedHashMapTests(
WrappedHashMapGenerator generator, String name, Feature<?>... features) {
List<Feature<?>> featuresList = Lists.newArrayList(features);
Reported by PMD.
Line: 86
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return MapTestSuiteBuilder.using(generator)
.named(name)
.withFeatures(featuresList)
.createTestSuite();
}
Reported by PMD.
Line: 86
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return MapTestSuiteBuilder.using(generator)
.named(name)
.withFeatures(featuresList)
.createTestSuite();
}
Reported by PMD.
Line: 86
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return MapTestSuiteBuilder.using(generator)
.named(name)
.withFeatures(featuresList)
.createTestSuite();
}
Reported by PMD.
Line: 120
ALLOWS_NULL_VALUES);
}
private static Test testsForHashMapNullValuesForbidden() {
return wrappedHashMapTests(
new WrappedHashMapGenerator() {
@Override
Map<String, String> wrap(final HashMap<String, String> map) {
if (map.containsValue(null)) {
Reported by PMD.
Line: 124
return wrappedHashMapTests(
new WrappedHashMapGenerator() {
@Override
Map<String, String> wrap(final HashMap<String, String> map) {
if (map.containsValue(null)) {
throw new NullPointerException();
}
return new AbstractMap<String, String>() {
Reported by PMD.
android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
26 issues
Line: 36
private static final Object FIXTURE_ARGUMENT = new Object();
private EventBus bus;
private boolean methodCalled;
private Object methodArgument;
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 37
private static final Object FIXTURE_ARGUMENT = new Object();
private EventBus bus;
private boolean methodCalled;
private Object methodArgument;
@Override
protected void setUp() throws Exception {
bus = new EventBus();
Reported by PMD.
Line: 38
private EventBus bus;
private boolean methodCalled;
private Object methodArgument;
@Override
protected void setUp() throws Exception {
bus = new EventBus();
methodCalled = false;
Reported by PMD.
Line: 40
private boolean methodCalled;
private Object methodArgument;
@Override
protected void setUp() throws Exception {
bus = new EventBus();
methodCalled = false;
methodArgument = null;
}
Reported by PMD.
Line: 44
protected void setUp() throws Exception {
bus = new EventBus();
methodCalled = false;
methodArgument = null;
}
public void testCreate() {
Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod"));
assertThat(s1).isInstanceOf(Subscriber.SynchronizedSubscriber.class);
Reported by PMD.
Line: 47
methodArgument = null;
}
public void testCreate() {
Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod"));
assertThat(s1).isInstanceOf(Subscriber.SynchronizedSubscriber.class);
// a thread-safe method should not create a synchronized subscriber
Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod"));
Reported by PMD.
Line: 47
methodArgument = null;
}
public void testCreate() {
Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod"));
assertThat(s1).isInstanceOf(Subscriber.SynchronizedSubscriber.class);
// a thread-safe method should not create a synchronized subscriber
Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod"));
Reported by PMD.
Line: 49
public void testCreate() {
Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod"));
assertThat(s1).isInstanceOf(Subscriber.SynchronizedSubscriber.class);
// a thread-safe method should not create a synchronized subscriber
Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod"));
assertThat(s2).isNotInstanceOf(Subscriber.SynchronizedSubscriber.class);
}
Reported by PMD.
Line: 53
// a thread-safe method should not create a synchronized subscriber
Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod"));
assertThat(s2).isNotInstanceOf(Subscriber.SynchronizedSubscriber.class);
}
public void testInvokeSubscriberMethod_basicMethodCall() throws Throwable {
Method method = getTestSubscriberMethod("recordingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
Reported by PMD.
Line: 56
assertThat(s2).isNotInstanceOf(Subscriber.SynchronizedSubscriber.class);
}
public void testInvokeSubscriberMethod_basicMethodCall() throws Throwable {
Method method = getTestSubscriberMethod("recordingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
Reported by PMD.
android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
25 issues
Line: 36
*/
public class FinalizableReferenceQueueTest extends TestCase {
private FinalizableReferenceQueue frq;
@Override
protected void tearDown() throws Exception {
frq = null;
}
Reported by PMD.
Line: 38
private FinalizableReferenceQueue frq;
@Override
protected void tearDown() throws Exception {
frq = null;
}
Reported by PMD.
Line: 40
@Override
protected void tearDown() throws Exception {
frq = null;
}
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());
Reported by PMD.
Line: 44
}
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());
GcFinalization.awaitDone(
new GcFinalization.FinalizationPredicate() {
public boolean isDone() {
Reported by PMD.
Line: 44
}
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());
GcFinalization.awaitDone(
new GcFinalization.FinalizationPredicate() {
public boolean isDone() {
Reported by PMD.
Line: 57
static class MockReference extends FinalizableWeakReference<Object> {
volatile boolean finalizeReferentCalled;
MockReference(FinalizableReferenceQueue frq) {
super(new Object(), frq);
}
Reported by PMD.
Line: 73
* Keeps a weak reference to the underlying reference queue. When this reference is cleared, we
* know that the background thread has stopped and released its strong reference.
*/
private WeakReference<ReferenceQueue<Object>> queueReference;
public void testThatFinalizerStops() {
weaklyReferenceQueue();
GcFinalization.awaitClear(queueReference);
Reported by PMD.
Line: 76
private WeakReference<ReferenceQueue<Object>> queueReference;
public void testThatFinalizerStops() {
weaklyReferenceQueue();
GcFinalization.awaitClear(queueReference);
}
/** If we don't keep a strong reference to the reference object, it won't be enqueued. */
Reported by PMD.
Line: 76
private WeakReference<ReferenceQueue<Object>> queueReference;
public void testThatFinalizerStops() {
weaklyReferenceQueue();
GcFinalization.awaitClear(queueReference);
}
/** If we don't keep a strong reference to the reference object, it won't be enqueued. */
Reported by PMD.
Line: 82
}
/** If we don't keep a strong reference to the reference object, it won't be enqueued. */
FinalizableWeakReference<Object> reference;
/** Create the FRQ in a method that goes out of scope so that we're sure it will be reclaimed. */
private void weaklyReferenceQueue() {
frq = new FinalizableReferenceQueue();
queueReference = new WeakReference<>(frq.queue);
Reported by PMD.
android/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java
25 issues
Line: 39
private static final Joiner JOINER_ON_CHARACTER = Joiner.on(DELIMITER_CHARACTER);
@Param({"3", "30", "300"})
int count;
@Param({"0", "1", "16", "32", "100"})
int componentLength;
private Iterable<String> components;
Reported by PMD.
Line: 42
int count;
@Param({"0", "1", "16", "32", "100"})
int componentLength;
private Iterable<String> components;
@BeforeExperiment
void setUp() {
Reported by PMD.
Line: 44
@Param({"0", "1", "16", "32", "100"})
int componentLength;
private Iterable<String> components;
@BeforeExperiment
void setUp() {
String component = Strings.repeat("a", componentLength);
String[] raw = new String[count];
Reported by PMD.
Line: 46
private Iterable<String> components;
@BeforeExperiment
void setUp() {
String component = Strings.repeat("a", componentLength);
String[] raw = new String[count];
Arrays.fill(raw, component);
components = Arrays.asList(raw);
Reported by PMD.
Line: 59
int joinerWithStringDelimiter(int reps) {
int dummy = 0;
for (int i = 0; i < reps; i++) {
dummy ^= JOINER_ON_STRING.join(components).length();
}
return dummy;
}
/** {@link Joiner} with a character delimiter. */
Reported by PMD.
Line: 69
int joinerWithCharacterDelimiter(int reps) {
int dummy = 0;
for (int i = 0; i < reps; i++) {
dummy ^= JOINER_ON_CHARACTER.join(components).length();
}
return dummy;
}
/**
Reported by PMD.
Line: 82
int joinerInlined(int reps) {
int dummy = 0;
for (int i = 0; i < reps; i++) {
StringBuilder sb = new StringBuilder();
Iterator<String> iterator = components.iterator();
if (iterator.hasNext()) {
sb.append(iterator.next().toString());
while (iterator.hasNext()) {
sb.append(DELIMITER_STRING);
Reported by PMD.
Line: 85
StringBuilder sb = new StringBuilder();
Iterator<String> iterator = components.iterator();
if (iterator.hasNext()) {
sb.append(iterator.next().toString());
while (iterator.hasNext()) {
sb.append(DELIMITER_STRING);
sb.append(iterator.next());
}
}
Reported by PMD.
Line: 91
sb.append(iterator.next());
}
}
dummy ^= sb.toString().length();
}
return dummy;
}
/**
Reported by PMD.
Line: 104
int stringBuilderIsEmpty(int reps) {
int dummy = 0;
for (int i = 0; i < reps; i++) {
StringBuilder sb = new StringBuilder();
for (String comp : components) {
if (sb.length() > 0) {
sb.append(DELIMITER_STRING);
}
sb.append(comp);
Reported by PMD.
android/guava-tests/test/com/google/common/graph/GraphEquivalenceTest.java
25 issues
Line: 39
private static final Integer N2 = 2;
private static final Integer N3 = 3;
private final EdgeType edgeType;
private final MutableGraph<Integer> graph;
// add parameters: directed/undirected
@Parameters
public static Collection<Object[]> parameters() {
Reported by PMD.
Line: 40
private static final Integer N3 = 3;
private final EdgeType edgeType;
private final MutableGraph<Integer> graph;
// add parameters: directed/undirected
@Parameters
public static Collection<Object[]> parameters() {
return Arrays.asList(new Object[][] {{EdgeType.UNDIRECTED}, {EdgeType.DIRECTED}});
Reported by PMD.
Line: 56
private static MutableGraph<Integer> createGraph(EdgeType edgeType) {
switch (edgeType) {
case UNDIRECTED:
return GraphBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return GraphBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
Reported by PMD.
Line: 56
private static MutableGraph<Integer> createGraph(EdgeType edgeType) {
switch (edgeType) {
case UNDIRECTED:
return GraphBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return GraphBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
Reported by PMD.
Line: 58
case UNDIRECTED:
return GraphBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return GraphBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
}
Reported by PMD.
Line: 58
case UNDIRECTED:
return GraphBuilder.undirected().allowsSelfLoops(true).build();
case DIRECTED:
return GraphBuilder.directed().allowsSelfLoops(true).build();
default:
throw new IllegalStateException("Unexpected edge type: " + edgeType);
}
}
Reported by PMD.
Line: 80
graph.addNode(N1);
MutableGraph<Integer> g2 = createGraph(edgeType);
g2.addNode(N2);
assertThat(graph).isNotEqualTo(g2);
}
// Node/edge sets are the same, but node/edge connections differ due to edge type.
Reported by PMD.
Line: 82
MutableGraph<Integer> g2 = createGraph(edgeType);
g2.addNode(N2);
assertThat(graph).isNotEqualTo(g2);
}
// Node/edge sets are the same, but node/edge connections differ due to edge type.
@Test
public void equivalent_directedVsUndirected() {
Reported by PMD.
Line: 91
graph.putEdge(N1, N2);
MutableGraph<Integer> g2 = createGraph(oppositeType(edgeType));
g2.putEdge(N1, N2);
assertThat(graph).isNotEqualTo(g2);
}
// Node/edge sets and node/edge connections are the same, but directedness differs.
Reported by PMD.
Line: 93
MutableGraph<Integer> g2 = createGraph(oppositeType(edgeType));
g2.putEdge(N1, N2);
assertThat(graph).isNotEqualTo(g2);
}
// Node/edge sets and node/edge connections are the same, but directedness differs.
@Test
public void equivalent_selfLoop_directedVsUndirected() {
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/ListAddAtIndexTester.java
25 issues
Line: 45
@SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAtIndex_supportedPresent() {
getList().add(0, e0());
expectAdded(0, e0());
Reported by PMD.
Line: 46
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListAddAtIndexTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAtIndex_supportedPresent() {
getList().add(0, e0());
expectAdded(0, e0());
}
Reported by PMD.
Line: 49
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
public void testAddAtIndex_supportedPresent() {
getList().add(0, e0());
expectAdded(0, e0());
}
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 53
expectAdded(0, e0());
}
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
@CollectionSize.Require(absent = ZERO)
/*
* absent = ZERO isn't required, since unmodList.add() must
* throw regardless, but it keeps the method name accurate.
*/
Reported by PMD.
Line: 61
*/
public void testAddAtIndex_unsupportedPresent() {
try {
getList().add(0, e0());
fail("add(n, present) should throw");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
}
Reported by PMD.
Line: 68
expectUnchanged();
}
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAtIndex_supportedNotPresent() {
getList().add(0, e3());
expectAdded(0, e3());
}
Reported by PMD.
Line: 70
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAtIndex_supportedNotPresent() {
getList().add(0, e3());
expectAdded(0, e3());
}
@CollectionFeature.Require(FAILS_FAST_ON_CONCURRENT_MODIFICATION)
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
Reported by PMD.
Line: 74
expectAdded(0, e3());
}
@CollectionFeature.Require(FAILS_FAST_ON_CONCURRENT_MODIFICATION)
@ListFeature.Require(SUPPORTS_ADD_WITH_INDEX)
public void testAddAtIndexConcurrentWithIteration() {
try {
Iterator<E> iterator = collection.iterator();
getList().add(0, e3());
Reported by PMD.
Line: 79
public void testAddAtIndexConcurrentWithIteration() {
try {
Iterator<E> iterator = collection.iterator();
getList().add(0, e3());
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
// success
}
Reported by PMD.
Line: 87
}
}
@ListFeature.Require(absent = SUPPORTS_ADD_WITH_INDEX)
public void testAddAtIndex_unsupportedNotPresent() {
try {
getList().add(0, e3());
fail("add(n, notPresent) should throw");
} catch (UnsupportedOperationException expected) {
Reported by PMD.