mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Deduplicate Refaster templates
This commit is contained in:
@@ -401,8 +401,8 @@ final class AssertJTemplates {
|
||||
@BeforeTemplate
|
||||
void before(Iterable<E> iterable) {
|
||||
Refaster.anyOf(
|
||||
assertThat(iterable).hasSize(0),
|
||||
assertThat(iterable.iterator().hasNext()).isFalse(),
|
||||
assertThat(Iterables.size(iterable)).isEqualTo(0),
|
||||
assertThat(Iterables.size(iterable)).isEqualTo(0L),
|
||||
assertThat(Iterables.size(iterable)).isNotPositive());
|
||||
}
|
||||
@@ -411,7 +411,6 @@ final class AssertJTemplates {
|
||||
void before(Collection<E> iterable) {
|
||||
Refaster.anyOf(
|
||||
assertThat(iterable.isEmpty()).isTrue(),
|
||||
assertThat(iterable.size()).isEqualTo(0),
|
||||
assertThat(iterable.size()).isEqualTo(0L),
|
||||
assertThat(iterable.size()).isNotPositive());
|
||||
}
|
||||
@@ -608,8 +607,8 @@ final class AssertJTemplates {
|
||||
@BeforeTemplate
|
||||
void before(Map<K, V> map) {
|
||||
Refaster.anyOf(
|
||||
assertThat(map).hasSize(0),
|
||||
assertThat(map.isEmpty()).isTrue(),
|
||||
assertThat(map.size()).isEqualTo(0),
|
||||
assertThat(map.size()).isEqualTo(0L),
|
||||
assertThat(map.size()).isNotPositive());
|
||||
}
|
||||
@@ -781,18 +780,21 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsAnyOfVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsAnyOf" /* Varargs converted to array. */)
|
||||
IterableAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends Iterable<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).containsAnyOf(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsAnyOf" /* Varargs converted to array. */)
|
||||
ListAssert<T> before2(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).containsAnyOf(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("ObjectEnumerableContainsOneElement" /* Not a true singleton. */)
|
||||
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
|
||||
ListAssert<S> after(Stream<S> stream, @Repeated U elements) {
|
||||
return assertThat(stream).containsAnyOf(elements);
|
||||
@@ -844,12 +846,14 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContains" /* Varargs converted to array. */)
|
||||
IterableAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends Iterable<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).contains(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContains" /* Varargs converted to array. */)
|
||||
ListAssert<T> before2(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).contains(Refaster.asVarargs(elements));
|
||||
@@ -895,6 +899,7 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsExactlyVarargs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsExactly" /* Varargs converted to array. */)
|
||||
ListAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).containsExactly(Refaster.asVarargs(elements));
|
||||
@@ -953,6 +958,7 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsExactlyInAnyOrderVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsExactlyInAnyOrder" /* Varargs converted to array. */)
|
||||
ListAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector))
|
||||
@@ -960,6 +966,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsExactlyInAnyOrder" /* Varargs converted to array. */)
|
||||
IterableAssert<T> before2(
|
||||
Stream<S> stream, Collector<S, ?, ? extends Multiset<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector))
|
||||
@@ -967,6 +974,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("ObjectEnumerableContainsExactlyOneElement" /* Not a true singleton. */)
|
||||
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
|
||||
ListAssert<S> after(Stream<S> stream, @Repeated U elements) {
|
||||
return assertThat(stream).containsExactlyInAnyOrder(elements);
|
||||
@@ -997,12 +1005,14 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsSequenceVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsSequence" /* Varargs converted to array. */)
|
||||
ListAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).containsSequence(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("ObjectEnumerableContainsOneElement" /* Not a true singleton. */)
|
||||
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
|
||||
ListAssert<S> after(Stream<S> stream, @Repeated U elements) {
|
||||
return assertThat(stream).containsSequence(elements);
|
||||
@@ -1033,6 +1043,7 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsSubsequenceVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsSubsequence" /* Varargs converted to array. */)
|
||||
ListAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector))
|
||||
@@ -1040,6 +1051,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("ObjectEnumerableContainsOneElement" /* Not a true singleton. */)
|
||||
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
|
||||
ListAssert<S> after(Stream<S> stream, @Repeated U elements) {
|
||||
return assertThat(stream).containsSubsequence(elements);
|
||||
@@ -1091,12 +1103,14 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamDoesNotContainVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamDoesNotContain" /* Varargs converted to array. */)
|
||||
IterableAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends Iterable<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).doesNotContain(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamDoesNotContain" /* Varargs converted to array. */)
|
||||
ListAssert<T> before2(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).doesNotContain(Refaster.asVarargs(elements));
|
||||
@@ -1133,6 +1147,7 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamDoesNotContainSequenceVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamDoesNotContainSequence" /* Varargs converted to array. */)
|
||||
ListAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector))
|
||||
@@ -1140,6 +1155,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@SuppressWarnings("ObjectEnumerableDoesNotContainOneElement" /* Not a true singleton. */)
|
||||
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
|
||||
ListAssert<S> after(Stream<S> stream, @Repeated U elements) {
|
||||
return assertThat(stream).doesNotContainSequence(elements);
|
||||
@@ -1191,12 +1207,14 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamContainsOnlyVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsOnly" /* Varargs converted to array. */)
|
||||
IterableAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends Iterable<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).containsOnly(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamContainsOnly" /* Varargs converted to array. */)
|
||||
ListAssert<T> before2(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).containsOnly(Refaster.asVarargs(elements));
|
||||
@@ -1245,12 +1263,14 @@ final class AssertJTemplates {
|
||||
// XXX: This rule assumes the `collector` doesn't completely discard certain values.
|
||||
static final class AssertThatStreamIsSubsetOfVarArgs<S, T extends S, U extends T> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamIsSubsetOf" /* Varargs converted to array. */)
|
||||
IterableAssert<T> before(
|
||||
Stream<S> stream, Collector<S, ?, ? extends Iterable<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).isSubsetOf(Refaster.asVarargs(elements));
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("AssertThatStreamIsSubsetOf" /* Varargs converted to array. */)
|
||||
ListAssert<T> before2(
|
||||
Stream<S> stream, Collector<S, ?, ? extends List<T>> collector, @Repeated U elements) {
|
||||
return assertThat(stream.collect(collector)).isSubsetOf(Refaster.asVarargs(elements));
|
||||
|
||||
@@ -233,10 +233,7 @@ final class DoubleStreamTemplates {
|
||||
static final class DoubleStreamAllMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(DoubleStream stream, DoublePredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(predicate.negate()),
|
||||
!stream.anyMatch(predicate.negate()),
|
||||
stream.filter(predicate.negate()).findAny().isEmpty());
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -251,10 +248,7 @@ final class DoubleStreamTemplates {
|
||||
|
||||
@BeforeTemplate
|
||||
boolean before(DoubleStream stream) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(e -> !test(e)),
|
||||
!stream.anyMatch(e -> !test(e)),
|
||||
stream.filter(e -> !test(e)).findAny().isEmpty());
|
||||
return stream.noneMatch(e -> !test(e));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
|
||||
@@ -56,10 +56,7 @@ final class ImmutableListMultimapTemplates {
|
||||
static final class EmptyImmutableListMultimap<K, V> {
|
||||
@BeforeTemplate
|
||||
ImmutableMultimap<K, V> before() {
|
||||
return Refaster.anyOf(
|
||||
ImmutableListMultimap.<K, V>builder().build(),
|
||||
ImmutableMultimap.<K, V>builder().build(),
|
||||
ImmutableMultimap.of());
|
||||
return Refaster.anyOf(ImmutableListMultimap.<K, V>builder().build(), ImmutableMultimap.of());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -80,7 +77,6 @@ final class ImmutableListMultimapTemplates {
|
||||
ImmutableMultimap<K, V> before(K key, V value) {
|
||||
return Refaster.anyOf(
|
||||
ImmutableListMultimap.<K, V>builder().put(key, value).build(),
|
||||
ImmutableMultimap.<K, V>builder().put(key, value).build(),
|
||||
ImmutableMultimap.of(key, value));
|
||||
}
|
||||
|
||||
@@ -99,9 +95,8 @@ final class ImmutableListMultimapTemplates {
|
||||
ImmutableMultimap<K, V> before(Map.Entry<? extends K, ? extends V> entry) {
|
||||
return Refaster.anyOf(
|
||||
ImmutableListMultimap.<K, V>builder().put(entry).build(),
|
||||
Stream.of(entry).collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)),
|
||||
ImmutableMultimap.<K, V>builder().put(entry).build(),
|
||||
ImmutableMultimap.of(entry.getKey(), entry.getValue()));
|
||||
Stream.of(entry)
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -118,8 +113,7 @@ final class ImmutableListMultimapTemplates {
|
||||
ImmutableListMultimap.copyOf(iterable.entries()),
|
||||
ImmutableListMultimap.<K, V>builder().putAll(iterable).build(),
|
||||
ImmutableMultimap.copyOf(iterable),
|
||||
ImmutableMultimap.copyOf(iterable.entries()),
|
||||
ImmutableMultimap.<K, V>builder().putAll(iterable).build());
|
||||
ImmutableMultimap.copyOf(iterable.entries()));
|
||||
}
|
||||
|
||||
@BeforeTemplate
|
||||
@@ -129,7 +123,6 @@ final class ImmutableListMultimapTemplates {
|
||||
ImmutableListMultimap.<K, V>builder().putAll(iterable).build(),
|
||||
Streams.stream(iterable)
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)),
|
||||
ImmutableMultimap.<K, V>builder().putAll(iterable).build(),
|
||||
ImmutableMultimap.copyOf(iterable));
|
||||
}
|
||||
|
||||
|
||||
@@ -246,10 +246,7 @@ final class IntStreamTemplates {
|
||||
static final class IntStreamAllMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(IntStream stream, IntPredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(predicate.negate()),
|
||||
!stream.anyMatch(predicate.negate()),
|
||||
stream.filter(predicate.negate()).findAny().isEmpty());
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -264,10 +261,7 @@ final class IntStreamTemplates {
|
||||
|
||||
@BeforeTemplate
|
||||
boolean before(IntStream stream) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(e -> !test(e)),
|
||||
!stream.anyMatch(e -> !test(e)),
|
||||
stream.filter(e -> !test(e)).findAny().isEmpty());
|
||||
return stream.noneMatch(e -> !test(e));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
|
||||
@@ -246,10 +246,7 @@ final class LongStreamTemplates {
|
||||
static final class LongStreamAllMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(LongStream stream, LongPredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(predicate.negate()),
|
||||
!stream.anyMatch(predicate.negate()),
|
||||
stream.filter(predicate.negate()).findAny().isEmpty());
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -264,10 +261,7 @@ final class LongStreamTemplates {
|
||||
|
||||
@BeforeTemplate
|
||||
boolean before(LongStream stream) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(e -> !test(e)),
|
||||
!stream.anyMatch(e -> !test(e)),
|
||||
stream.filter(e -> !test(e)).findAny().isEmpty());
|
||||
return stream.noneMatch(e -> !test(e));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
|
||||
@@ -20,10 +20,10 @@ final class OptionalTemplates {
|
||||
private OptionalTemplates() {}
|
||||
|
||||
static final class OptionalOfNullable<T> {
|
||||
@BeforeTemplate
|
||||
// XXX: Refaster should be smart enough to also rewrite occurrences in which there are
|
||||
// parentheses around the null check, but that's currently not the case. Try to fix that.
|
||||
// XXX: This is a special case of `TernaryOperatorOptionalNegativeFiltering`.
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("TernaryOperatorOptionalNegativeFiltering" /* Special case. */)
|
||||
Optional<T> before(T object) {
|
||||
return object == null ? Optional.empty() : Optional.of(object);
|
||||
}
|
||||
|
||||
@@ -294,10 +294,7 @@ final class StreamTemplates {
|
||||
static final class StreamAllMatch<T> {
|
||||
@BeforeTemplate
|
||||
boolean before(Stream<T> stream, Predicate<? super T> predicate) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(Refaster.anyOf(not(predicate), predicate.negate())),
|
||||
!stream.anyMatch(Refaster.anyOf(not(predicate), predicate.negate())),
|
||||
stream.filter(Refaster.anyOf(not(predicate), predicate.negate())).findAny().isEmpty());
|
||||
return stream.noneMatch(Refaster.anyOf(not(predicate), predicate.negate()));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
@@ -312,10 +309,7 @@ final class StreamTemplates {
|
||||
|
||||
@BeforeTemplate
|
||||
boolean before(Stream<T> stream) {
|
||||
return Refaster.anyOf(
|
||||
stream.noneMatch(e -> !test(e)),
|
||||
!stream.anyMatch(e -> !test(e)),
|
||||
stream.filter(e -> !test(e)).findAny().isEmpty());
|
||||
return stream.noneMatch(e -> !test(e));
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
|
||||
@@ -83,18 +83,12 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(2).filter(n -> n > 2).findAny().isPresent());
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testDoubleStreamAllMatch() {
|
||||
boolean testDoubleStreamAllMatch() {
|
||||
DoublePredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).noneMatch(pred.negate()),
|
||||
!DoubleStream.of(2).anyMatch(pred.negate()),
|
||||
DoubleStream.of(3).filter(pred.negate()).findAny().isEmpty());
|
||||
return DoubleStream.of(1).noneMatch(pred.negate());
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testDoubleStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).noneMatch(n -> !(n > 1)),
|
||||
!DoubleStream.of(2).anyMatch(n -> !(n > 2)),
|
||||
DoubleStream.of(3).filter(n -> !(n > 3)).findAny().isEmpty());
|
||||
boolean testDoubleStreamAllMatch2() {
|
||||
return DoubleStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,18 +82,12 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(1).anyMatch(n -> n > 1), DoubleStream.of(2).anyMatch(n -> n > 2));
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testDoubleStreamAllMatch() {
|
||||
boolean testDoubleStreamAllMatch() {
|
||||
DoublePredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).allMatch(pred),
|
||||
DoubleStream.of(2).allMatch(pred),
|
||||
DoubleStream.of(3).allMatch(pred));
|
||||
return DoubleStream.of(1).allMatch(pred);
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testDoubleStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).allMatch(n -> n > 1),
|
||||
DoubleStream.of(2).allMatch(n -> n > 2),
|
||||
DoubleStream.of(3).allMatch(n -> n > 3));
|
||||
boolean testDoubleStreamAllMatch2() {
|
||||
return DoubleStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,25 +33,20 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testEmptyImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.<String, Integer>builder().build(),
|
||||
ImmutableMultimap.<String, Integer>builder().build(),
|
||||
ImmutableMultimap.of());
|
||||
ImmutableListMultimap.<String, Integer>builder().build(), ImmutableMultimap.of());
|
||||
}
|
||||
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testPairToImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.<String, Integer>builder().put("foo", 1).build(),
|
||||
ImmutableMultimap.<String, Integer>builder().put("bar", 2).build(),
|
||||
ImmutableMultimap.of("baz", 3));
|
||||
ImmutableMultimap.of("bar", 2));
|
||||
}
|
||||
|
||||
ImmutableList<ImmutableMultimap<String, Integer>> testEntryToImmutableListMultimap() {
|
||||
return ImmutableList.of(
|
||||
ImmutableListMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
|
||||
Stream.of(Map.entry("foo", 1))
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)),
|
||||
ImmutableMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
|
||||
ImmutableMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
ImmutableList<ImmutableMultimap<String, Integer>> testIterableToImmutableListMultimap() {
|
||||
@@ -69,12 +64,6 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)),
|
||||
ImmutableMultimap.copyOf(ImmutableListMultimap.of("foo", 1)),
|
||||
ImmutableMultimap.copyOf(ImmutableListMultimap.of("foo", 1).entries()),
|
||||
ImmutableMultimap.<String, Integer>builder()
|
||||
.putAll(ImmutableListMultimap.of("foo", 1))
|
||||
.build(),
|
||||
ImmutableMultimap.<String, Integer>builder()
|
||||
.putAll(ImmutableListMultimap.of("foo", 1).entries())
|
||||
.build(),
|
||||
ImmutableMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,21 +32,15 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
}
|
||||
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testEmptyImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.of(), ImmutableListMultimap.of(), ImmutableListMultimap.of());
|
||||
return ImmutableSet.of(ImmutableListMultimap.of(), ImmutableListMultimap.of());
|
||||
}
|
||||
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testPairToImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.of("foo", 1),
|
||||
ImmutableListMultimap.of("bar", 2),
|
||||
ImmutableListMultimap.of("baz", 3));
|
||||
return ImmutableSet.of(ImmutableListMultimap.of("foo", 1), ImmutableListMultimap.of("bar", 2));
|
||||
}
|
||||
|
||||
ImmutableList<ImmutableMultimap<String, Integer>> testEntryToImmutableListMultimap() {
|
||||
return ImmutableList.of(
|
||||
ImmutableListMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
|
||||
ImmutableListMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
|
||||
ImmutableListMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
|
||||
ImmutableListMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
|
||||
}
|
||||
@@ -60,8 +54,6 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
ImmutableListMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))),
|
||||
ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1)),
|
||||
ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1)),
|
||||
ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1)),
|
||||
ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1).entries()),
|
||||
ImmutableListMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
|
||||
}
|
||||
|
||||
|
||||
@@ -87,18 +87,12 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(2).filter(n -> n > 2).findAny().isPresent());
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testIntStreamAllMatch() {
|
||||
boolean testIntStreamAllMatch() {
|
||||
IntPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).noneMatch(pred.negate()),
|
||||
!IntStream.of(2).anyMatch(pred.negate()),
|
||||
IntStream.of(3).filter(pred.negate()).findAny().isEmpty());
|
||||
return IntStream.of(1).noneMatch(pred.negate());
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testIntStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).noneMatch(n -> !(n > 1)),
|
||||
!IntStream.of(2).anyMatch(n -> !(n > 2)),
|
||||
IntStream.of(3).filter(n -> !(n > 3)).findAny().isEmpty());
|
||||
boolean testIntStreamAllMatch2() {
|
||||
return IntStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,18 +86,12 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(1).anyMatch(n -> n > 1), IntStream.of(2).anyMatch(n -> n > 2));
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testIntStreamAllMatch() {
|
||||
boolean testIntStreamAllMatch() {
|
||||
IntPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).allMatch(pred),
|
||||
IntStream.of(2).allMatch(pred),
|
||||
IntStream.of(3).allMatch(pred));
|
||||
return IntStream.of(1).allMatch(pred);
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testIntStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).allMatch(n -> n > 1),
|
||||
IntStream.of(2).allMatch(n -> n > 2),
|
||||
IntStream.of(3).allMatch(n -> n > 3));
|
||||
boolean testIntStreamAllMatch2() {
|
||||
return IntStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,18 +87,12 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(2).filter(n -> n > 2).findAny().isPresent());
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testLongStreamAllMatch() {
|
||||
boolean testLongStreamAllMatch() {
|
||||
LongPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).noneMatch(pred.negate()),
|
||||
!LongStream.of(2).anyMatch(pred.negate()),
|
||||
LongStream.of(3).filter(pred.negate()).findAny().isEmpty());
|
||||
return LongStream.of(1).noneMatch(pred.negate());
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testLongStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).noneMatch(n -> !(n > 1)),
|
||||
!LongStream.of(2).anyMatch(n -> !(n > 2)),
|
||||
LongStream.of(3).filter(n -> !(n > 3)).findAny().isEmpty());
|
||||
boolean testLongStreamAllMatch2() {
|
||||
return LongStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,18 +86,12 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(1).anyMatch(n -> n > 1), LongStream.of(2).anyMatch(n -> n > 2));
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testLongStreamAllMatch() {
|
||||
boolean testLongStreamAllMatch() {
|
||||
LongPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).allMatch(pred),
|
||||
LongStream.of(2).allMatch(pred),
|
||||
LongStream.of(3).allMatch(pred));
|
||||
return LongStream.of(1).allMatch(pred);
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testLongStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).allMatch(n -> n > 1),
|
||||
LongStream.of(2).allMatch(n -> n > 2),
|
||||
LongStream.of(3).allMatch(n -> n > 3));
|
||||
boolean testLongStreamAllMatch2() {
|
||||
return LongStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,20 +118,10 @@ final class StreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
Predicate<String> pred = String::isBlank;
|
||||
return ImmutableSet.of(
|
||||
Stream.of("foo").noneMatch(not(String::isBlank)),
|
||||
Stream.of("bar").noneMatch(pred.negate()),
|
||||
!Stream.of("baz").anyMatch(not(s -> s.length() > 1)),
|
||||
!Stream.of("qux").anyMatch(pred.negate()),
|
||||
Stream.of("quux").filter(not(String::isEmpty)).findAny().isEmpty(),
|
||||
Stream.of("quuz").filter(pred.negate()).findAny().isEmpty(),
|
||||
Stream.of(Boolean.TRUE).noneMatch(b -> !b),
|
||||
!Stream.of(Boolean.TRUE).anyMatch(b -> !b),
|
||||
Stream.of(Boolean.TRUE).filter(b -> !b).findAny().isEmpty());
|
||||
Stream.of("bar").noneMatch(pred.negate()));
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of("foo").noneMatch(s -> !s.isBlank()),
|
||||
!Stream.of("bar").anyMatch(s -> !s.isEmpty()),
|
||||
Stream.of("baz").filter(s -> !s.isBlank()).findAny().isEmpty());
|
||||
boolean testStreamAllMatch2() {
|
||||
return Stream.of("foo").noneMatch(s -> !s.isBlank());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,21 +117,10 @@ final class StreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet<Boolean> testStreamAllMatch() {
|
||||
Predicate<String> pred = String::isBlank;
|
||||
return ImmutableSet.of(
|
||||
Stream.of("foo").allMatch(String::isBlank),
|
||||
Stream.of("bar").allMatch(pred),
|
||||
Stream.of("baz").allMatch(s -> s.length() > 1),
|
||||
Stream.of("qux").allMatch(pred),
|
||||
Stream.of("quux").allMatch(String::isEmpty),
|
||||
Stream.of("quuz").allMatch(pred),
|
||||
Stream.of(Boolean.TRUE).allMatch(b -> b),
|
||||
Stream.of(Boolean.TRUE).allMatch(b -> b),
|
||||
Stream.of(Boolean.TRUE).allMatch(b -> b));
|
||||
Stream.of("foo").allMatch(String::isBlank), Stream.of("bar").allMatch(pred));
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testStreamAllMatch2() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of("foo").allMatch(s -> s.isBlank()),
|
||||
Stream.of("bar").allMatch(s -> s.isEmpty()),
|
||||
Stream.of("baz").allMatch(s -> s.isBlank()));
|
||||
boolean testStreamAllMatch2() {
|
||||
return Stream.of("foo").allMatch(s -> s.isBlank());
|
||||
}
|
||||
}
|
||||
|
||||
5
pom.xml
5
pom.xml
@@ -1197,14 +1197,11 @@
|
||||
<!-- XXX: `MethodReferenceUsage` is an extremely expensive
|
||||
check due to its use of `SuggestedFixes.compilesWithFix`. Maybe
|
||||
we should drop it altogether? -->
|
||||
<!-- XXX: We shouldn't disable the `Refaster` check here.
|
||||
Rather, we should fix whatever bug causes templates to flag
|
||||
their own code. -->
|
||||
<!-- XXX: Find a way to assert that test code (both inline
|
||||
`BugChecker` test code and the Refaster test files) does not
|
||||
exhibit anti-patterns other than those associated with the
|
||||
check/template under test. Ideally all test cases are realistic. -->
|
||||
<error-prone.self-check-args>-Xep:MethodReferenceUsage:OFF -Xep:Refaster:OFF</error-prone.self-check-args>
|
||||
<error-prone.self-check-args>-Xep:MethodReferenceUsage:OFF</error-prone.self-check-args>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
Reference in New Issue
Block a user