Skip to content

Commit

Permalink
minor javadoc and test coverage fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Feb 21, 2022
1 parent cb41de7 commit 2b96b7e
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.github.benmanes.caffeine.cache.Caffeine;

/**
* Apache Commons Collections' map tests for against the {@link Cache#asMap()} view.
* Apache Commons Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand All @@ -30,9 +30,7 @@ public final class BoundedMapTest extends CaffeineMapTestCase {
public BoundedMapTest(String testName) {
super(testName);
}

@Override
public Cache<Object, Object> makeCache() {
@Override public Cache<Object, Object> makeCache() {
return Caffeine.newBuilder()
.expireAfterWrite(Long.MAX_VALUE, TimeUnit.DAYS)
.maximumSize(Long.MAX_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.benmanes.caffeine.cache.Cache;

/**
* Apache Commons Collections' map tests for against the {@link Cache#asMap()} view.
* Apache Commons Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand All @@ -31,31 +31,22 @@ public abstract class CaffeineMapTestCase extends AbstractMapTest<Object, Object
public CaffeineMapTestCase(String testName) {
super(testName);
}

@Override
public boolean isAllowNullKey() {
@Override public boolean isAllowNullKey() {
return false;
}

@Override
public boolean isAllowNullValue() {
@Override public boolean isAllowNullValue() {
return false;
}

@Override
public boolean isFailFastExpected() {
@Override public boolean isFailFastExpected() {
return false;
}

@Override
public boolean isSubMapViewsSerializable() {
@Override public boolean isSubMapViewsSerializable() {
return false;
}

@Override
public Map<Object, Object> makeObject() {
@Override public Map<Object, Object> makeObject() {
return makeCache().asMap();
}

/** Returns a new, empty cache instance. */
public abstract Cache<Object, Object> makeCache();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.github.benmanes.caffeine.cache.Caffeine;

/**
* Apache Commons Collections' map tests for against the {@link Cache#asMap()} view.
* Apache Commons Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand All @@ -28,9 +28,7 @@ public final class UnboundedMapTest extends CaffeineMapTestCase {
public UnboundedMapTest(String testName) {
super(testName);
}

@Override
public Cache<Object, Object> makeCache() {
@Override public Cache<Object, Object> makeCache() {
return Caffeine.newBuilder().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
Expand Down Expand Up @@ -789,6 +790,16 @@ public void concat(LinkedDeque<LinkedValue> deque) {
assertThat(actual).containsExactlyElementsIn(expect).inOrder();
}

@Test(dataProvider = "full")
public void concat_peek(LinkedDeque<LinkedValue> deque) {
var iterator = PeekingIterator.concat(deque.iterator(), deque.iterator());
while (iterator.hasNext()) {
var expected = iterator.peek();
assertThat(iterator.next()).isEqualTo(expected);
}
assertThat(iterator.peek()).isNull();
}

@Test(dataProvider = "empty", expectedExceptions = NoSuchElementException.class)
public void concat_noMoreElements(LinkedDeque<LinkedValue> deque) {
PeekingIterator.concat(deque.iterator(), deque.iterator()).next();
Expand All @@ -799,21 +810,25 @@ public void comparing(LinkedDeque<LinkedValue> deque) {
var expect = ImmutableList.copyOf(
Iterators.concat(deque.iterator(), deque.descendingIterator()));
var actual = PeekingIterator.comparing(
deque.iterator(), deque.descendingIterator(), (a, b) -> 1);
deque.iterator(), deque.descendingIterator(), comparator().reversed());
assertThat(actual.peek()).isEqualTo(expect.get(0));
assertThat(ImmutableList.copyOf(actual)).containsExactlyElementsIn(expect).inOrder();
}

@Test(dataProvider = "full")
public void comparing_uneven(LinkedDeque<LinkedValue> deque) {
var empty = new AccessOrderDeque<LinkedValue>().iterator();
var left = PeekingIterator.comparing(deque.iterator(), empty, (a, b) -> 1);
var right = PeekingIterator.comparing(deque.iterator(), empty, (a, b) -> 1);
var left = PeekingIterator.comparing(deque.iterator(), empty, comparator().reversed());
var right = PeekingIterator.comparing(empty, deque.iterator(), comparator().reversed());

assertThat(left.peek()).isEqualTo(deque.getFirst());
assertThat(right.peek()).isEqualTo(deque.getFirst());
}

private static Comparator<LinkedValue> comparator() {
return Comparator.comparing((LinkedValue v) -> v.value);
}

/* --------------- Deque providers --------------- */

@DataProvider(name = "empty")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.github.benmanes.caffeine.eclipse.acceptance.ConcurrentHashMapAcceptanceTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.github.benmanes.caffeine.eclipse.mutable.ConcurrentHashMapTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.github.benmanes.caffeine.eclipse.mutable.ConcurrentMutableHashMapTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.github.benmanes.caffeine.eclipse.acceptance.ParallelMapIteratePutAcceptanceTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.github.benmanes.caffeine.eclipse.acceptance.UnifiedMapAcceptanceTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.github.benmanes.caffeine.eclipse.mutable.UnifiedMapTestCase;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.benmanes.caffeine.eclipse.acceptance.ConcurrentHashMapAcceptanceTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.benmanes.caffeine.eclipse.mutable.ConcurrentHashMapTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.benmanes.caffeine.eclipse.mutable.ConcurrentMutableHashMapTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.github.benmanes.caffeine.eclipse.acceptance.ParallelMapIteratePutAcceptanceTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.benmanes.caffeine.eclipse.acceptance.UnifiedMapAcceptanceTest;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.benmanes.caffeine.eclipse.mutable.UnifiedMapTestCase;

/**
* Eclipse Collections' map tests for against the {@link Cache#asMap()} view.
* Eclipse Collections' map tests for the {@link Cache#asMap()} view.
*
* @author ben.manes@gmail.com (Ben Manes)
*/
Expand Down

0 comments on commit 2b96b7e

Please sign in to comment.