mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Compare commits
7 Commits
v0.21.0
...
rossendrij
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
326b4da610 | ||
|
|
7aca87679c | ||
|
|
5a57725204 | ||
|
|
4cde21bca1 | ||
|
|
2dd3068a63 | ||
|
|
828892fb23 | ||
|
|
37dbf0d6ec |
@@ -6,7 +6,6 @@ import static java.util.Objects.requireNonNullElseGet;
|
||||
import static java.util.function.Predicate.not;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -68,9 +67,12 @@ public final class RefasterCheck extends BugChecker implements CompilationUnitTr
|
||||
private static final String REFASTER_TEMPLATE_SUFFIX = ".refaster";
|
||||
private static final String INCLUDED_TEMPLATES_PATTERN_FLAG = "Refaster:NamePattern";
|
||||
|
||||
@VisibleForTesting
|
||||
static final Supplier<ImmutableListMultimap<String, CodeTransformer>> ALL_CODE_TRANSFORMERS =
|
||||
Suppliers.memoize(RefasterCheck::loadAllCodeTransformers);
|
||||
/**
|
||||
* Retrieve all code transformers by calling {@link
|
||||
* Suppliers#memoize(com.google.common.base.Supplier)}.
|
||||
*/
|
||||
public static final Supplier<ImmutableListMultimap<String, CodeTransformer>>
|
||||
ALL_CODE_TRANSFORMERS = Suppliers.memoize(RefasterCheck::loadAllCodeTransformers);
|
||||
|
||||
private final CodeTransformer codeTransformer;
|
||||
|
||||
@@ -179,7 +181,13 @@ public final class RefasterCheck extends BugChecker implements CompilationUnitTr
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
|
||||
private static ImmutableListMultimap<String, CodeTransformer> loadAllCodeTransformers() {
|
||||
/**
|
||||
* Use the classpath to find all resources that are {@link CodeTransformer}s. Next, map the {@link
|
||||
* CodeTransformer}s based on the template name.
|
||||
*
|
||||
* @return all {@link CodeTransformer}s by template name.
|
||||
*/
|
||||
public static ImmutableListMultimap<String, CodeTransformer> loadAllCodeTransformers() {
|
||||
ImmutableListMultimap.Builder<String, CodeTransformer> transformers =
|
||||
ImmutableListMultimap.builder();
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import static com.google.errorprone.matchers.ChildMultiMatcher.MatchType.AT_LEAST_ONE;
|
||||
import static com.google.errorprone.matchers.Matchers.annotations;
|
||||
import static com.google.errorprone.matchers.Matchers.hasAnnotation;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.google.common.base.VerifyException;
|
||||
import com.google.errorprone.BugPattern;
|
||||
import com.google.errorprone.BugPattern.LinkType;
|
||||
import com.google.errorprone.BugPattern.SeverityLevel;
|
||||
import com.google.errorprone.BugPattern.StandardTags;
|
||||
import com.google.errorprone.VisitorState;
|
||||
import com.google.errorprone.bugpatterns.BugChecker;
|
||||
import com.google.errorprone.matchers.Description;
|
||||
import com.google.errorprone.matchers.MultiMatcher;
|
||||
import com.google.errorprone.refaster.Refaster;
|
||||
import com.google.errorprone.util.ASTHelpers;
|
||||
import com.sun.source.tree.AnnotationTree;
|
||||
import com.sun.source.tree.ClassTree;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
|
||||
/**
|
||||
* A {@link BugChecker} which flags unnecessary {@link Refaster#anyOf(Object[])} usages.
|
||||
*
|
||||
* <p>Note that this logic can't be implemented as a Refaster template, as the {@link Refaster}
|
||||
* class is treated specially.
|
||||
*/
|
||||
@AutoService(BugChecker.class)
|
||||
@BugPattern(
|
||||
name = "RefasterTestAnnotations",
|
||||
summary = "`Refaster#anyOf` should be passed at least two parameters",
|
||||
linkType = LinkType.NONE,
|
||||
severity = SeverityLevel.WARNING,
|
||||
tags = StandardTags.STYLE)
|
||||
public final class RefasterTestAnnotationsCheck extends BugChecker
|
||||
implements BugChecker.ClassTreeMatcher {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final MultiMatcher<ClassTree, AnnotationTree> TEMPLATE_COLLECTION_ANNOTATION =
|
||||
annotations(AT_LEAST_ONE, hasAnnotation(TemplateCollection.class.toString()));
|
||||
|
||||
@Override
|
||||
public Description matchClass(ClassTree tree, VisitorState state) {
|
||||
boolean b = ASTHelpers.hasAnnotation(tree, TemplateCollection.class.toString(), state);
|
||||
if (TEMPLATE_COLLECTION_ANNOTATION.matches(tree, state) || b) {
|
||||
throw new VerifyException("Test");
|
||||
}
|
||||
return Description.NO_MATCH;
|
||||
// long methodTypes =
|
||||
// tree.getMembers().stream()
|
||||
// .filter(member -> member.getKind() == Tree.Kind.METHOD)
|
||||
// .map(MethodTree.class::cast)
|
||||
// .filter(method -> !ASTHelpers.isGeneratedConstructor(method))
|
||||
// .map(method -> TEMPLATE_COLLECTION_ANNOTATION.matches(method, state))
|
||||
// .distinct()
|
||||
// .count();
|
||||
//
|
||||
// return methodTypes < 2 ? Description.NO_MATCH : buildDescription(tree).build();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import org.assertj.core.api.NumberAssert;
|
||||
final class AssertJNumberTemplates {
|
||||
private AssertJNumberTemplates() {}
|
||||
|
||||
static final class NumberIsPositive {
|
||||
static final class NumberAssertIsPositive {
|
||||
@BeforeTemplate
|
||||
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
|
||||
return Refaster.anyOf(
|
||||
@@ -69,7 +69,7 @@ final class AssertJNumberTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class NumberIsNotPositive {
|
||||
static final class NumberAssertIsNotPositive {
|
||||
@BeforeTemplate
|
||||
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
|
||||
return Refaster.anyOf(
|
||||
@@ -120,7 +120,7 @@ final class AssertJNumberTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class NumberIsNegative {
|
||||
static final class NumberAssertIsNegative {
|
||||
@BeforeTemplate
|
||||
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
|
||||
return Refaster.anyOf(
|
||||
@@ -171,7 +171,7 @@ final class AssertJNumberTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class NumberIsNotNegative {
|
||||
static final class NumberAssertIsNotNegative {
|
||||
@BeforeTemplate
|
||||
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
|
||||
return Refaster.anyOf(
|
||||
|
||||
@@ -564,7 +564,7 @@ final class AssertJTemplates {
|
||||
// Map
|
||||
//
|
||||
|
||||
static final class AssertThatMapIsEmpty<K, V> {
|
||||
static final class AbstractMapAssertIsEmpty<K, V> {
|
||||
@BeforeTemplate
|
||||
@SuppressWarnings("unchecked")
|
||||
void before(AbstractMapAssert<?, ?, K, V> mapAssert) {
|
||||
@@ -615,8 +615,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Find a better name.
|
||||
static final class AssertThatMapIsEmpty2<K, V> {
|
||||
static final class AssertThatIsEmpty<K, V> {
|
||||
@BeforeTemplate
|
||||
void before(Map<K, V> map) {
|
||||
Refaster.anyOf(
|
||||
@@ -638,7 +637,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class AssertThatMapIsNotEmpty<K, V> {
|
||||
static final class AbstractMapAssertIsNotEmpty<K, V> {
|
||||
@BeforeTemplate
|
||||
AbstractMapAssert<?, ?, K, V> before(AbstractMapAssert<?, ?, K, V> mapAssert) {
|
||||
return mapAssert.isNotEqualTo(
|
||||
@@ -657,8 +656,7 @@ final class AssertJTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Find a better name.
|
||||
static final class AssertThatMapIsNotEmpty2<K, V> {
|
||||
static final class AssertThatIsNotEmpty<K, V> {
|
||||
@BeforeTemplate
|
||||
AbstractAssert<?, ?> before(Map<K, V> map) {
|
||||
return Refaster.anyOf(
|
||||
|
||||
@@ -187,7 +187,7 @@ final class CollectionTemplates {
|
||||
* Don't call {@link ImmutableCollection#asList()} if the result is going to be streamed; stream
|
||||
* directly.
|
||||
*/
|
||||
static final class ImmutableCollectionAsListToStream<T> {
|
||||
static final class ImmutableCollectionStream<T> {
|
||||
@BeforeTemplate
|
||||
Stream<T> before(ImmutableCollection<T> collection) {
|
||||
return collection.asList().stream();
|
||||
|
||||
@@ -185,23 +185,7 @@ final class DoubleStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link DoubleStream#noneMatch(DoublePredicate)} over more contrived alternatives. */
|
||||
static final class DoubleStreamNoneMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(DoubleStream stream, DoublePredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(predicate.negate()),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(DoubleStream stream, DoublePredicate predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class DoubleStreamNoneMatch2 {
|
||||
abstract static class DoubleStreamNoneMatch {
|
||||
@Placeholder
|
||||
abstract boolean test(@MayOptionallyUse double element);
|
||||
|
||||
@@ -216,6 +200,22 @@ final class DoubleStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link DoubleStream#noneMatch(DoublePredicate)} over more contrived alternatives. */
|
||||
static final class DoubleStreamNoneMatchPredicate {
|
||||
@BeforeTemplate
|
||||
boolean before(DoubleStream stream, DoublePredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(predicate.negate()),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(DoubleStream stream, DoublePredicate predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link DoubleStream#anyMatch(DoublePredicate)} over more contrived alternatives. */
|
||||
static final class DoubleStreamAnyMatch {
|
||||
@BeforeTemplate
|
||||
@@ -230,19 +230,7 @@ final class DoubleStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DoubleStreamAllMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(DoubleStream stream, DoublePredicate predicate) {
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(DoubleStream stream, DoublePredicate predicate) {
|
||||
return stream.allMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class DoubleStreamAllMatch2 {
|
||||
abstract static class DoubleStreamAllMatch {
|
||||
@Placeholder
|
||||
abstract boolean test(@MayOptionallyUse double element);
|
||||
|
||||
@@ -256,4 +244,16 @@ final class DoubleStreamTemplates {
|
||||
return stream.allMatch(e -> test(e));
|
||||
}
|
||||
}
|
||||
|
||||
static final class DoubleStreamAllMatchPredicate {
|
||||
@BeforeTemplate
|
||||
boolean before(DoubleStream stream, DoublePredicate predicate) {
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(DoubleStream stream, DoublePredicate predicate) {
|
||||
return stream.allMatch(predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ final class ImmutableListMultimapTemplates {
|
||||
* Prefer creating an immutable copy of the result of {@link Multimaps#transformValues(Multimap,
|
||||
* com.google.common.base.Function)} over creating and directly collecting a stream.
|
||||
*/
|
||||
abstract static class TransformMultimapValuesToImmutableListMultimap<K, V1, V2> {
|
||||
abstract static class ImmutableListMultimapCopyOfMultimapsTransformValues<K, V1, V2> {
|
||||
@Placeholder(allowsIdentity = true)
|
||||
abstract V2 valueTransformation(@MayOptionallyUse V1 value);
|
||||
|
||||
@@ -227,7 +227,7 @@ final class ImmutableListMultimapTemplates {
|
||||
* Prefer creating an immutable copy of the result of {@link Multimaps#transformValues(Multimap,
|
||||
* com.google.common.base.Function)} over creating and directly collecting a stream.
|
||||
*/
|
||||
static final class TransformMultimapValuesToImmutableListMultimap2<K, V1, V2> {
|
||||
static final class ImmutableListMultimapCopyOfMultimapsTransformValuesTransformation<K, V1, V2> {
|
||||
// XXX: Drop the `Refaster.anyOf` if we decide to rewrite one to the other.
|
||||
@BeforeTemplate
|
||||
ImmutableListMultimap<K, V2> before(
|
||||
|
||||
@@ -121,7 +121,7 @@ final class ImmutableSetMultimapTemplates {
|
||||
* Don't map a a stream's elements to map entries, only to subsequently collect them into an
|
||||
* {@link ImmutableSetMultimap}. The collection can be performed directly.
|
||||
*/
|
||||
abstract static class StreamOfMapEntriesToImmutableSetMultimap<E, K, V> {
|
||||
abstract static class StreamCollectToImmutableSetMultimap<E, K, V> {
|
||||
@Placeholder(allowsIdentity = true)
|
||||
abstract K keyFunction(@MayOptionallyUse E element);
|
||||
|
||||
@@ -148,7 +148,7 @@ final class ImmutableSetMultimapTemplates {
|
||||
* Prefer creating an immutable copy of the result of {@link Multimaps#transformValues(Multimap,
|
||||
* com.google.common.base.Function)} over creating and directly collecting a stream.
|
||||
*/
|
||||
abstract static class TransformMultimapValuesToImmutableSetMultimap<K, V1, V2> {
|
||||
abstract static class ImmutableSetMultimapCopyOfMultimapsTransformValues<K, V1, V2> {
|
||||
@Placeholder(allowsIdentity = true)
|
||||
abstract V2 valueTransformation(@MayOptionallyUse V1 value);
|
||||
|
||||
@@ -170,7 +170,7 @@ final class ImmutableSetMultimapTemplates {
|
||||
* Prefer creating an immutable copy of the result of {@link Multimaps#transformValues(Multimap,
|
||||
* com.google.common.base.Function)} over creating and directly collecting a stream.
|
||||
*/
|
||||
static final class TransformMultimapValuesToImmutableSetMultimap2<K, V1, V2> {
|
||||
static final class ImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation<K, V1, V2> {
|
||||
// XXX: Drop the `Refaster.anyOf` if we decide to rewrite one to the other.
|
||||
@BeforeTemplate
|
||||
ImmutableSetMultimap<K, V2> before(
|
||||
|
||||
@@ -198,23 +198,7 @@ final class IntStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link IntStream#noneMatch(IntPredicate)} over more contrived alternatives. */
|
||||
static final class IntStreamNoneMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(IntStream stream, IntPredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(predicate.negate()),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(IntStream stream, IntPredicate predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class IntStreamNoneMatch2 {
|
||||
abstract static class IntStreamNoneMatch {
|
||||
@Placeholder
|
||||
abstract boolean test(@MayOptionallyUse int element);
|
||||
|
||||
@@ -229,6 +213,22 @@ final class IntStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link IntStream#noneMatch(IntPredicate)} over more contrived alternatives. */
|
||||
static final class IntStreamNoneMatchPredicate {
|
||||
@BeforeTemplate
|
||||
boolean before(IntStream stream, IntPredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(predicate.negate()),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(IntStream stream, IntPredicate predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link IntStream#anyMatch(IntPredicate)} over more contrived alternatives. */
|
||||
static final class IntStreamAnyMatch {
|
||||
@BeforeTemplate
|
||||
@@ -243,19 +243,7 @@ final class IntStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class IntStreamAllMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(IntStream stream, IntPredicate predicate) {
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(IntStream stream, IntPredicate predicate) {
|
||||
return stream.allMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class IntStreamAllMatch2 {
|
||||
abstract static class IntStreamAllMatch {
|
||||
@Placeholder
|
||||
abstract boolean test(@MayOptionallyUse int element);
|
||||
|
||||
@@ -269,4 +257,16 @@ final class IntStreamTemplates {
|
||||
return stream.allMatch(e -> test(e));
|
||||
}
|
||||
}
|
||||
|
||||
static final class IntStreamAllMatchPredicate {
|
||||
@BeforeTemplate
|
||||
boolean before(IntStream stream, IntPredicate predicate) {
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(IntStream stream, IntPredicate predicate) {
|
||||
return stream.allMatch(predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,23 +198,7 @@ final class LongStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link LongStream#noneMatch(LongPredicate)} over more contrived alternatives. */
|
||||
static final class LongStreamNoneMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(LongStream stream, LongPredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(predicate.negate()),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(LongStream stream, LongPredicate predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class LongStreamNoneMatch2 {
|
||||
abstract static class LongStreamNoneMatch {
|
||||
@Placeholder
|
||||
abstract boolean test(@MayOptionallyUse long element);
|
||||
|
||||
@@ -229,6 +213,22 @@ final class LongStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link LongStream#noneMatch(LongPredicate)} over more contrived alternatives. */
|
||||
static final class LongStreamNoneMatchPredicate {
|
||||
@BeforeTemplate
|
||||
boolean before(LongStream stream, LongPredicate predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(predicate.negate()),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(LongStream stream, LongPredicate predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link LongStream#anyMatch(LongPredicate)} over more contrived alternatives. */
|
||||
static final class LongStreamAnyMatch {
|
||||
@BeforeTemplate
|
||||
@@ -243,19 +243,7 @@ final class LongStreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
static final class LongStreamAllMatch {
|
||||
@BeforeTemplate
|
||||
boolean before(LongStream stream, LongPredicate predicate) {
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(LongStream stream, LongPredicate predicate) {
|
||||
return stream.allMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class LongStreamAllMatch2 {
|
||||
abstract static class LongStreamAllMatch {
|
||||
@Placeholder
|
||||
abstract boolean test(@MayOptionallyUse long element);
|
||||
|
||||
@@ -269,4 +257,16 @@ final class LongStreamTemplates {
|
||||
return stream.allMatch(e -> test(e));
|
||||
}
|
||||
}
|
||||
|
||||
static final class LongStreamAllMatchPredicate {
|
||||
@BeforeTemplate
|
||||
boolean before(LongStream stream, LongPredicate predicate) {
|
||||
return stream.noneMatch(predicate.negate());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(LongStream stream, LongPredicate predicate) {
|
||||
return stream.allMatch(predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,23 +248,7 @@ final class StreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link Stream#noneMatch(Predicate)} over more contrived alternatives. */
|
||||
static final class StreamNoneMatch<T> {
|
||||
@BeforeTemplate
|
||||
boolean before(Stream<T> stream, Predicate<? super T> predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(Refaster.anyOf(not(predicate), predicate.negate())),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(Stream<T> stream, Predicate<? super T> predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class StreamNoneMatch2<T> {
|
||||
abstract static class StreamNoneMatch<T> {
|
||||
@Placeholder(allowsIdentity = true)
|
||||
abstract boolean test(@MayOptionallyUse T element);
|
||||
|
||||
@@ -279,6 +263,22 @@ final class StreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link Stream#noneMatch(Predicate)} over more contrived alternatives. */
|
||||
static final class StreamNoneMatchPredicate<T> {
|
||||
@BeforeTemplate
|
||||
boolean before(Stream<T> stream, Predicate<? super T> predicate) {
|
||||
return Refaster.anyOf(
|
||||
!stream.anyMatch(predicate),
|
||||
stream.allMatch(Refaster.anyOf(not(predicate), predicate.negate())),
|
||||
stream.filter(predicate).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@AfterTemplate
|
||||
boolean after(Stream<T> stream, Predicate<? super T> predicate) {
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
/** Prefer {@link Stream#anyMatch(Predicate)} over more contrived alternatives. */
|
||||
static final class StreamAnyMatch<T> {
|
||||
@BeforeTemplate
|
||||
@@ -305,7 +305,7 @@ final class StreamTemplates {
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class StreamAllMatch2<T> {
|
||||
abstract static class StreamAllMatchPredicate<T> {
|
||||
@Placeholder(allowsIdentity = true)
|
||||
abstract boolean test(@MayOptionallyUse T element);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSetMultimap.toImmutableSetMultimap;
|
||||
import static java.util.function.Function.identity;
|
||||
@@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import tech.picnic.errorprone.bugpatterns.RefasterCheck;
|
||||
|
||||
public final class RefasterCheckTest {
|
||||
/** The names of all Refaster template groups defined in this module. */
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.MoreCollectors.onlyElement;
|
||||
import static com.google.errorprone.BugPattern.SeverityLevel.ERROR;
|
||||
import static com.google.errorprone.util.MoreAnnotations.getValue;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.errorprone.BugCheckerRefactoringTestHelper;
|
||||
import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode;
|
||||
import com.google.errorprone.BugPattern;
|
||||
import com.google.errorprone.BugPattern.LinkType;
|
||||
import com.google.errorprone.CompilationTestHelper;
|
||||
import com.google.errorprone.VisitorState;
|
||||
import com.google.errorprone.annotations.Var;
|
||||
import com.google.errorprone.bugpatterns.BugChecker;
|
||||
import com.google.errorprone.bugpatterns.BugChecker.ClassTreeMatcher;
|
||||
import com.google.errorprone.bugpatterns.BugChecker.MethodTreeMatcher;
|
||||
import com.google.errorprone.fixes.SuggestedFix;
|
||||
import com.google.errorprone.fixes.SuggestedFixes;
|
||||
import com.google.errorprone.matchers.Description;
|
||||
import com.google.errorprone.util.ASTHelpers;
|
||||
import com.sun.source.tree.ClassTree;
|
||||
import com.sun.source.tree.MethodTree;
|
||||
import com.sun.tools.javac.code.Attribute;
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
import com.sun.tools.javac.code.Type.ClassType;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
|
||||
public final class RefasterTestsValidationsCheckTest {
|
||||
private final CompilationTestHelper compilationTestHelper =
|
||||
CompilationTestHelper.newInstance(RefasterTestValidationsCheck.class, getClass());
|
||||
|
||||
static final ImmutableSet<String> TEMPLATE_GROUPS =
|
||||
ImmutableSet.of(
|
||||
// "AssertJ", --> This template doesn't have a test yet.
|
||||
"AssertJBigDecimal",
|
||||
"AssertJBigInteger",
|
||||
"AssertJBoolean",
|
||||
"AssertJByte",
|
||||
"AssertJCharSequence",
|
||||
"AssertJDouble",
|
||||
"AssertJEnumerable",
|
||||
"AssertJFloat",
|
||||
"AssertJInteger",
|
||||
"AssertJLong",
|
||||
"AssertJNumber",
|
||||
// "AssertJObject",
|
||||
// "AssertJOptional",
|
||||
// "AssertJShort",
|
||||
// "AssertJString",
|
||||
// "Assorted",
|
||||
// "BigDecimal",
|
||||
// "Collection",
|
||||
// "Comparator",
|
||||
// "DoubleStream",
|
||||
// "Equality",
|
||||
// "ImmutableList",
|
||||
// "ImmutableListMultimap",
|
||||
// "ImmutableMap",
|
||||
// "ImmutableMultiset",
|
||||
// "ImmutableSet",
|
||||
// "ImmutableSetMultimap",
|
||||
// "ImmutableSortedMap",
|
||||
// "ImmutableSortedMultiset",
|
||||
// "ImmutableSortedSet",
|
||||
// "IntStream",
|
||||
// "JUnit",
|
||||
// "LongStream",
|
||||
// "MapEntry",
|
||||
// "Mockito",
|
||||
// "Multimap",
|
||||
// "Null",
|
||||
// "Optional",
|
||||
// "Primitive",
|
||||
// "Reactor",
|
||||
// "RxJava2Adapter",
|
||||
"Stream",
|
||||
"String",
|
||||
"TestNGToAssertJ",
|
||||
"Time",
|
||||
"WebClient");
|
||||
|
||||
/**
|
||||
* Returns every known (template group name, template name) pair as a parameterized test argument.
|
||||
*/
|
||||
@SuppressWarnings("UnusedMethod" /* Used as a `@MethodSource`. */)
|
||||
private static Stream<Arguments> templatesUnderTest() {
|
||||
return TEMPLATE_GROUPS.stream().map(Arguments::arguments);
|
||||
}
|
||||
|
||||
@Test
|
||||
void classHasTemplateCollectionAnnotation() {
|
||||
compilationTestHelper
|
||||
.addSourceLines(
|
||||
"StringTemplatesTest.java",
|
||||
"import tech.picnic.errorprone.annotations.Template;",
|
||||
"",
|
||||
"// BUG: Diagnostic contains:",
|
||||
"final class StringTemplatesTest {",
|
||||
" @Template(String.class)",
|
||||
" void testString() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
void classHasCorrectTemplateCollectionAnnotationValue() {
|
||||
compilationTestHelper
|
||||
.addSourceLines("StringTemplates.java", "package pkg; public class StringTemplates { }")
|
||||
.addSourceLines(
|
||||
"StringTemplatesTest.java",
|
||||
"import tech.picnic.errorprone.annotations.Template;",
|
||||
"import tech.picnic.errorprone.annotations.TemplateCollection;",
|
||||
"",
|
||||
"@TemplateCollection(String.class)",
|
||||
"// BUG: Diagnostic contains:",
|
||||
"final class StringTemplatesTest {",
|
||||
" @Template(String.class)",
|
||||
" void testString() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
void methodHasPrefixTest() {
|
||||
compilationTestHelper
|
||||
.addSourceLines("StringTemplates.java", "package pkg; public class StringTemplates { }")
|
||||
.addSourceLines(
|
||||
"SimpleTemplatesTest.java",
|
||||
"package pkg;",
|
||||
"",
|
||||
"import tech.picnic.errorprone.annotations.TemplateCollection;",
|
||||
"",
|
||||
"@TemplateCollection(StringTemplates.class)",
|
||||
"final class StringTemplatesTest {",
|
||||
" // BUG: Diagnostic contains:",
|
||||
" void simpleMethodWithoutPrefix() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
void methodHasTemplateAnnotation() {
|
||||
compilationTestHelper
|
||||
.addSourceLines("StringTemplates.java", "package pkg; public class StringTemplates { }")
|
||||
.addSourceLines(
|
||||
"SimpleTemplatesTest.java",
|
||||
"package pkg;",
|
||||
"",
|
||||
"import tech.picnic.errorprone.annotations.TemplateCollection;",
|
||||
"",
|
||||
"@TemplateCollection(StringTemplates.class)",
|
||||
"final class StringTemplatesTest {",
|
||||
" // BUG: Diagnostic contains:",
|
||||
" void testSimpleMethod() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
void methodHasCorrectTemplateAnnotationValue() {
|
||||
compilationTestHelper
|
||||
.addSourceLines("StringTemplates.java", "package pkg; public class StringTemplates { }")
|
||||
.addSourceLines(
|
||||
"SimpleTemplatesTest.java",
|
||||
"package pkg;",
|
||||
"",
|
||||
"import tech.picnic.errorprone.annotations.TemplateCollection;",
|
||||
"import tech.picnic.errorprone.annotations.Template;",
|
||||
"",
|
||||
"@TemplateCollection(StringTemplates.class)",
|
||||
"final class StringTemplatesTest {",
|
||||
" @Template(Integer.class)",
|
||||
" // BUG: Diagnostic contains:",
|
||||
" void testString() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
void omitNumberSuffixOfMethodName() {
|
||||
compilationTestHelper
|
||||
.addSourceLines("StringTemplates.java", "package pkg; public class StringTemplates { }")
|
||||
.addSourceLines(
|
||||
"SimpleTemplatesTest.java",
|
||||
"package pkg;",
|
||||
"",
|
||||
"import tech.picnic.errorprone.annotations.TemplateCollection;",
|
||||
"import tech.picnic.errorprone.annotations.Template;",
|
||||
"",
|
||||
"@TemplateCollection(StringTemplates.class)",
|
||||
"final class StringTemplatesTest {",
|
||||
" @Template(String.class)",
|
||||
" void testString3() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
void correctTestCollection() {
|
||||
compilationTestHelper
|
||||
.addSourceLines("StringTemplates.java", "package pkg; public class StringTemplates { }")
|
||||
.addSourceLines(
|
||||
"SimpleTemplatesTest.java",
|
||||
"package pkg;",
|
||||
"",
|
||||
"import tech.picnic.errorprone.annotations.TemplateCollection;",
|
||||
"import tech.picnic.errorprone.annotations.Template;",
|
||||
"",
|
||||
"@TemplateCollection(StringTemplates.class)",
|
||||
"final class StringTemplatesTest {",
|
||||
" @Template(String.class)",
|
||||
" void testString() { }",
|
||||
"}")
|
||||
.doTest();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("templatesUnderTest")
|
||||
void validateAllTestMethods(String group) {
|
||||
verifyRefactoring(group);
|
||||
}
|
||||
|
||||
private void verifyRefactoring(String groupName) {
|
||||
BugCheckerRefactoringTestHelper.newInstance(RefasterTestValidationsCheck.class, getClass())
|
||||
.addInput(groupName + "TemplatesTestInput.java")
|
||||
.expectUnchanged()
|
||||
.doTest(TestMode.TEXT_MATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link BugChecker} that validates the *Templates{Input,Output} test resources for the
|
||||
* Refaster templates.
|
||||
*/
|
||||
@BugPattern(
|
||||
name = "RefasterTestValidations",
|
||||
summary = "Flag incorrect set up of tests resources for Refaster templates.",
|
||||
linkType = LinkType.NONE,
|
||||
severity = ERROR)
|
||||
public static final class RefasterTestValidationsCheck extends BugChecker
|
||||
implements ClassTreeMatcher, MethodTreeMatcher {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String TEST_METHOD_PREFIX = "test";
|
||||
private static final Pattern LAST_TEST_OCCURRENCE = Pattern.compile("(?s)Test(?!.*?Test)");
|
||||
|
||||
@Override
|
||||
public Description matchClass(ClassTree tree, VisitorState state) {
|
||||
// XXX: Check package name to decide whether we should analyze, instead of using the
|
||||
// `TemplatesTest` suffix.
|
||||
String className = tree.getSimpleName().toString();
|
||||
if (!className.contains("TemplatesTest")) {
|
||||
return Description.NO_MATCH;
|
||||
}
|
||||
|
||||
if (!ASTHelpers.hasAnnotation(tree, TemplateCollection.class, state)
|
||||
|| templateAnnotationHasIncorrectValue(
|
||||
ASTHelpers.getSymbol(tree), className, TemplateCollection.class)) {
|
||||
return describeMatch(
|
||||
tree,
|
||||
SuggestedFix.prefixWith(
|
||||
tree,
|
||||
String.format("@TemplateCollection(\"%s\".class)\n", dropTestSuffix(className))));
|
||||
}
|
||||
return Description.NO_MATCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Description matchMethod(MethodTree tree, VisitorState state) {
|
||||
// XXX: Verify that you are in a class that is a test for a collection?
|
||||
if (ASTHelpers.hasAnnotation(tree, Override.class, state)) {
|
||||
return Description.NO_MATCH;
|
||||
}
|
||||
|
||||
MethodSymbol symbol = ASTHelpers.getSymbol(tree);
|
||||
@Var String methodName = symbol.getSimpleName().toString();
|
||||
methodName = dropTrailingNumbers(methodName);
|
||||
boolean containsPrefix = methodName.startsWith(TEST_METHOD_PREFIX);
|
||||
if (!containsPrefix) {
|
||||
return describeMatch(
|
||||
tree,
|
||||
SuggestedFixes.renameMethod(
|
||||
tree, TEST_METHOD_PREFIX + capitalizeFirstLetter(methodName), state));
|
||||
}
|
||||
|
||||
boolean hasTemplateAnnotation = ASTHelpers.hasAnnotation(tree, Template.class, state);
|
||||
if (!hasTemplateAnnotation
|
||||
|| templateAnnotationHasIncorrectValue(symbol, methodName, Template.class)) {
|
||||
String expectedTemplateName = methodName.replaceFirst(TEST_METHOD_PREFIX, "");
|
||||
return describeMatch(
|
||||
tree,
|
||||
SuggestedFix.prefixWith(
|
||||
tree, String.format("@Template(\"%s\".class)\n", expectedTemplateName)));
|
||||
}
|
||||
return Description.NO_MATCH;
|
||||
}
|
||||
|
||||
private static boolean templateAnnotationHasIncorrectValue(
|
||||
Symbol symbol, String nameToCompare, Class<?> clazz) {
|
||||
String fullyQualifiedClassOfAnnotationValue =
|
||||
getClassFromAnnotation(symbol, clazz.getName()).toString();
|
||||
String expectedAnnotationValue =
|
||||
fullyQualifiedClassOfAnnotationValue.substring(
|
||||
fullyQualifiedClassOfAnnotationValue.lastIndexOf('.') + 1);
|
||||
String finalName =
|
||||
symbol instanceof MethodSymbol
|
||||
? nameToCompare.replace(TEST_METHOD_PREFIX, "")
|
||||
: dropTestSuffix(nameToCompare);
|
||||
return !finalName.endsWith(expectedAnnotationValue);
|
||||
}
|
||||
|
||||
private static ClassType getClassFromAnnotation(Symbol symbol, String name) {
|
||||
Attribute.Compound templateClass =
|
||||
symbol.getRawAttributes().stream()
|
||||
.filter(a -> a.type.tsym.getQualifiedName().contentEquals(name))
|
||||
.collect(onlyElement());
|
||||
return (ClassType) getValue(templateClass, "value").orElseThrow().getValue();
|
||||
}
|
||||
|
||||
private static String capitalizeFirstLetter(String s) {
|
||||
return Ascii.toUpperCase(s.substring(0, 1)) + s.substring(1);
|
||||
}
|
||||
|
||||
private static String dropTrailingNumbers(String methodName) {
|
||||
return methodName.replaceAll("\\d*$", "");
|
||||
}
|
||||
|
||||
private static String dropTestSuffix(String text) {
|
||||
return LAST_TEST_OCCURRENCE.matcher(text).replaceFirst("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
|
||||
final class AssertJCharSequenceTemplatesTest implements RefasterTemplateTestCase {
|
||||
void testAssertThatCharSequenceIsEmpty1() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
void testAssertThatCharSequenceIsEmpty2() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatCharSequenceIsNotEmpty() {
|
||||
return ImmutableSet.of(assertThat("foo").isNotEmpty(), assertThat("bar").isNotEmpty());
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatCharSequenceHasSize() {
|
||||
return assertThat("foo").hasSize(3);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
|
||||
final class AssertJObjectTemplatesTest implements RefasterTemplateTestCase {
|
||||
AbstractAssert<?, ?> testAssertThatIsInstanceOf() {
|
||||
return assertThat("foo" instanceof String).isTrue();
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatIsNotInstanceOf() {
|
||||
return assertThat("foo" instanceof String).isFalse();
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatIsIsEqualTo() {
|
||||
return assertThat("foo".equals("bar")).isTrue();
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatIsIsNotEqualTo() {
|
||||
return assertThat("foo".equals("bar")).isFalse();
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatHasToString() {
|
||||
return assertThat(new Object().toString()).isEqualTo("foo");
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
|
||||
final class AssertJObjectTemplatesTest implements RefasterTemplateTestCase {
|
||||
AbstractAssert<?, ?> testAssertThatIsInstanceOf() {
|
||||
return assertThat("foo").isInstanceOf(String.class);
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatIsNotInstanceOf() {
|
||||
return assertThat("foo").isNotInstanceOf(String.class);
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatIsIsEqualTo() {
|
||||
return assertThat("foo").isEqualTo("bar");
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatIsIsNotEqualTo() {
|
||||
return assertThat("foo").isNotEqualTo("bar");
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatHasToString() {
|
||||
return assertThat(new Object()).hasToString("foo");
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AbstractStringAssert;
|
||||
|
||||
final class AssertJStringTemplatesTest implements RefasterTemplateTestCase {
|
||||
void testAbstractStringAssertStringIsEmpty() {
|
||||
assertThat("foo").isEqualTo("");
|
||||
}
|
||||
|
||||
void testAssertThatStringIsEmpty() {
|
||||
assertThat("foo".isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
AbstractStringAssert<?> testAbstractStringAssertStringIsNotEmpty() {
|
||||
return assertThat("foo").isNotEqualTo("");
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatStringIsNotEmpty() {
|
||||
return assertThat("foo".isEmpty()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AbstractStringAssert;
|
||||
|
||||
final class AssertJStringTemplatesTest implements RefasterTemplateTestCase {
|
||||
void testAbstractStringAssertStringIsEmpty() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
void testAssertThatStringIsEmpty() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
AbstractStringAssert<?> testAbstractStringAssertStringIsNotEmpty() {
|
||||
return assertThat("foo").isNotEmpty();
|
||||
}
|
||||
|
||||
AbstractAssert<?, ?> testAssertThatStringIsNotEmpty() {
|
||||
return assertThat("foo").isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
final class BigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet<BigDecimal> testBigDecimalZero() {
|
||||
return ImmutableSet.of(BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
ImmutableSet<BigDecimal> testBigDecimalOne() {
|
||||
return ImmutableSet.of(BigDecimal.ONE, BigDecimal.ONE, BigDecimal.ONE);
|
||||
}
|
||||
|
||||
ImmutableSet<BigDecimal> testBigDecimalTen() {
|
||||
return ImmutableSet.of(BigDecimal.TEN, BigDecimal.TEN, BigDecimal.TEN);
|
||||
}
|
||||
|
||||
ImmutableSet<BigDecimal> testBigDecimalFactoryMethod() {
|
||||
return ImmutableSet.of(BigDecimal.valueOf(0), BigDecimal.valueOf(0L));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -7,25 +7,36 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
import org.assertj.core.api.AbstractBigDecimalAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJBigDecimalTemplates.class)
|
||||
final class AssertJBigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isCloseTo(BigDecimal.ONE, offset(BigDecimal.ZERO)),
|
||||
assertThat(BigDecimal.ZERO).isCloseTo(BigDecimal.ONE, withPercentage(0)));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isNotCloseTo(BigDecimal.ONE, offset(BigDecimal.ZERO)),
|
||||
assertThat(BigDecimal.ZERO).isNotCloseTo(BigDecimal.ONE, withPercentage(0)));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsZero.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isZero(),
|
||||
@@ -33,6 +44,7 @@ final class AssertJBigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isEqualTo(BigDecimal.ZERO));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsNotZero.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsNotZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isNotZero(),
|
||||
@@ -40,6 +52,7 @@ final class AssertJBigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isNotEqualTo(BigDecimal.ZERO));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsOne.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsOne() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isOne(),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -7,25 +7,36 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
import org.assertj.core.api.AbstractBigDecimalAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigDecimalTemplates.AbstractBigDecimalAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJBigDecimalTemplates.class)
|
||||
final class AssertJBigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isEqualTo(BigDecimal.ONE),
|
||||
assertThat(BigDecimal.ZERO).isEqualTo(BigDecimal.ONE));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isNotEqualTo(BigDecimal.ONE),
|
||||
assertThat(BigDecimal.ZERO).isNotEqualTo(BigDecimal.ONE));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsZero.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isEqualTo(0),
|
||||
@@ -33,6 +44,7 @@ final class AssertJBigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isEqualTo(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsNotZero.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsNotZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isNotEqualTo(0),
|
||||
@@ -40,6 +52,7 @@ final class AssertJBigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isNotEqualTo(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigDecimalAssertIsOne.class)
|
||||
ImmutableSet<AbstractBigDecimalAssert<?>> testAbstractBigDecimalAssertIsOne() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigDecimal.ZERO).isEqualTo(1),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -7,25 +7,36 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigInteger;
|
||||
import org.assertj.core.api.AbstractBigIntegerAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJBigIntegerTemplates.class)
|
||||
final class AssertJBigIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isCloseTo(BigInteger.ONE, offset(BigInteger.ZERO)),
|
||||
assertThat(BigInteger.ZERO).isCloseTo(BigInteger.ONE, withPercentage(0)));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isNotCloseTo(BigInteger.ONE, offset(BigInteger.ZERO)),
|
||||
assertThat(BigInteger.ZERO).isNotCloseTo(BigInteger.ONE, withPercentage(0)));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsZero.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isZero(),
|
||||
@@ -33,6 +44,7 @@ final class AssertJBigIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigInteger.ZERO).isEqualTo(BigInteger.ZERO));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsNotZero.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsNotZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isNotZero(),
|
||||
@@ -40,6 +52,7 @@ final class AssertJBigIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigInteger.ZERO).isNotEqualTo(BigInteger.ZERO));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsOne.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsOne() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isOne(),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -7,25 +7,36 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigInteger;
|
||||
import org.assertj.core.api.AbstractBigIntegerAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBigIntegerTemplates.AbstractBigIntegerAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJBigIntegerTemplates.class)
|
||||
final class AssertJBigIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isEqualTo(BigInteger.ONE),
|
||||
assertThat(BigInteger.ZERO).isEqualTo(BigInteger.ONE));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isNotEqualTo(BigInteger.ONE),
|
||||
assertThat(BigInteger.ZERO).isNotEqualTo(BigInteger.ONE));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsZero.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isEqualTo(0),
|
||||
@@ -33,6 +44,7 @@ final class AssertJBigIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigInteger.ZERO).isEqualTo(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsNotZero.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsNotZero() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isNotEqualTo(0),
|
||||
@@ -40,6 +52,7 @@ final class AssertJBigIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigInteger.ZERO).isNotEqualTo(0));
|
||||
}
|
||||
|
||||
@Template(AbstractBigIntegerAssertIsOne.class)
|
||||
ImmutableSet<AbstractBigIntegerAssert<?>> testAbstractBigIntegerAssertIsOne() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(BigInteger.ZERO).isEqualTo(1),
|
||||
@@ -1,19 +1,31 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractBooleanAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsFalse;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsTrue;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AssertThatBooleanIsFalse;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AssertThatBooleanIsTrue;
|
||||
|
||||
@TemplateCollection(AssertJBooleanTemplates.class)
|
||||
final class AssertJBooleanTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AbstractBooleanAssertIsEqualTo.class)
|
||||
AbstractBooleanAssert<?> testAbstractBooleanAssertIsEqualTo() {
|
||||
return assertThat(true).isNotEqualTo(!false);
|
||||
}
|
||||
|
||||
@Template(AbstractBooleanAssertIsNotEqualTo.class)
|
||||
AbstractBooleanAssert<?> testAbstractBooleanAssertIsNotEqualTo() {
|
||||
return assertThat(true).isEqualTo(!false);
|
||||
}
|
||||
|
||||
@Template(AbstractBooleanAssertIsTrue.class)
|
||||
ImmutableSet<AbstractBooleanAssert<?>> testAbstractBooleanAssertIsTrue() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(true).isEqualTo(true),
|
||||
@@ -22,10 +34,12 @@ final class AssertJBooleanTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(true).isNotEqualTo(Boolean.FALSE));
|
||||
}
|
||||
|
||||
@Template(AssertThatBooleanIsTrue.class)
|
||||
AbstractBooleanAssert<?> testAssertThatBooleanIsTrue() {
|
||||
return assertThat(!true).isFalse();
|
||||
}
|
||||
|
||||
@Template(AbstractBooleanAssertIsFalse.class)
|
||||
ImmutableSet<AbstractBooleanAssert<?>> testAbstractBooleanAssertIsFalse() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(true).isEqualTo(false),
|
||||
@@ -34,6 +48,7 @@ final class AssertJBooleanTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(true).isNotEqualTo(Boolean.TRUE));
|
||||
}
|
||||
|
||||
@Template(AssertThatBooleanIsFalse.class)
|
||||
AbstractBooleanAssert<?> testAssertThatBooleanIsFalse() {
|
||||
return assertThat(!true).isTrue();
|
||||
}
|
||||
@@ -1,19 +1,31 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractBooleanAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsFalse;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AbstractBooleanAssertIsTrue;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AssertThatBooleanIsFalse;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJBooleanTemplates.AssertThatBooleanIsTrue;
|
||||
|
||||
@TemplateCollection(AssertJBooleanTemplates.class)
|
||||
final class AssertJBooleanTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AbstractBooleanAssertIsEqualTo.class)
|
||||
AbstractBooleanAssert<?> testAbstractBooleanAssertIsEqualTo() {
|
||||
return assertThat(true).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Template(AbstractBooleanAssertIsNotEqualTo.class)
|
||||
AbstractBooleanAssert<?> testAbstractBooleanAssertIsNotEqualTo() {
|
||||
return assertThat(true).isNotEqualTo(false);
|
||||
}
|
||||
|
||||
@Template(AbstractBooleanAssertIsTrue.class)
|
||||
ImmutableSet<AbstractBooleanAssert<?>> testAbstractBooleanAssertIsTrue() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(true).isTrue(),
|
||||
@@ -22,10 +34,12 @@ final class AssertJBooleanTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(true).isTrue());
|
||||
}
|
||||
|
||||
@Template(AssertThatBooleanIsTrue.class)
|
||||
AbstractBooleanAssert<?> testAssertThatBooleanIsTrue() {
|
||||
return assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
@Template(AbstractBooleanAssertIsFalse.class)
|
||||
ImmutableSet<AbstractBooleanAssert<?>> testAbstractBooleanAssertIsFalse() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(true).isFalse(),
|
||||
@@ -34,6 +48,7 @@ final class AssertJBooleanTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(true).isFalse());
|
||||
}
|
||||
|
||||
@Template(AssertThatBooleanIsFalse.class)
|
||||
AbstractBooleanAssert<?> testAssertThatBooleanIsFalse() {
|
||||
return assertThat(true).isFalse();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractByteAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJByteTemplates.class)
|
||||
final class AssertJByteTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractByteAssert<?>> testAbstractByteAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isCloseTo((byte) 1, offset((byte) 0)),
|
||||
@@ -22,6 +31,7 @@ final class AssertJByteTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((byte) 0).isEqualTo(Byte.valueOf((byte) 1)));
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractByteAssert<?>> testAbstractByteAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isNotCloseTo((byte) 1, offset((byte) 0)),
|
||||
@@ -31,14 +41,17 @@ final class AssertJByteTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((byte) 0).isNotEqualTo(Byte.valueOf((byte) 1)));
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsZero.class)
|
||||
AbstractByteAssert<?> testAbstractByteAssertIsZero() {
|
||||
return assertThat((byte) 0).isZero();
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsNotZero.class)
|
||||
AbstractByteAssert<?> testAbstractByteAssertIsNotZero() {
|
||||
return assertThat((byte) 0).isNotZero();
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsOne.class)
|
||||
AbstractByteAssert<?> testAbstractByteAssertIsOne() {
|
||||
return assertThat((byte) 0).isOne();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractByteAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJByteTemplates.AbstractByteAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJByteTemplates.class)
|
||||
final class AssertJByteTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractByteAssert<?>> testAbstractByteAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isEqualTo((byte) 1),
|
||||
@@ -22,6 +31,7 @@ final class AssertJByteTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((byte) 0).isEqualTo((byte) 1));
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractByteAssert<?>> testAbstractByteAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isNotEqualTo((byte) 1),
|
||||
@@ -31,14 +41,17 @@ final class AssertJByteTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((byte) 0).isNotEqualTo((byte) 1));
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsZero.class)
|
||||
AbstractByteAssert<?> testAbstractByteAssertIsZero() {
|
||||
return assertThat((byte) 0).isEqualTo((byte) 0);
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsNotZero.class)
|
||||
AbstractByteAssert<?> testAbstractByteAssertIsNotZero() {
|
||||
return assertThat((byte) 0).isNotEqualTo((byte) 0);
|
||||
}
|
||||
|
||||
@Template(AbstractByteAssertIsOne.class)
|
||||
AbstractByteAssert<?> testAbstractByteAssertIsOne() {
|
||||
return assertThat((byte) 0).isEqualTo((byte) 1);
|
||||
}
|
||||
@@ -1,24 +1,34 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJCharSequenceTemplates.AssertThatCharSequenceHasSize;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJCharSequenceTemplates.AssertThatCharSequenceIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJCharSequenceTemplates.AssertThatCharSequenceIsNotEmpty;
|
||||
|
||||
@TemplateCollection(AssertJCharSequenceTemplates.class)
|
||||
final class AssertJCharSequenceTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AssertThatCharSequenceIsEmpty.class)
|
||||
void testAssertThatCharSequenceIsEmpty1() {
|
||||
assertThat("foo".length()).isEqualTo(0L);
|
||||
}
|
||||
|
||||
@Template(AssertThatCharSequenceIsEmpty.class)
|
||||
void testAssertThatCharSequenceIsEmpty2() {
|
||||
assertThat("foo".length()).isNotPositive();
|
||||
}
|
||||
|
||||
@Template(AssertThatCharSequenceIsNotEmpty.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatCharSequenceIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
assertThat("foo".length()).isNotEqualTo(0), assertThat("bar".length()).isPositive());
|
||||
}
|
||||
|
||||
@Template(AssertThatCharSequenceHasSize.class)
|
||||
AbstractAssert<?, ?> testAssertThatCharSequenceHasSize() {
|
||||
return assertThat("foo".length()).isEqualTo(3);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJCharSequenceTemplates.AssertThatCharSequenceHasSize;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJCharSequenceTemplates.AssertThatCharSequenceIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJCharSequenceTemplates.AssertThatCharSequenceIsNotEmpty;
|
||||
|
||||
@TemplateCollection(AssertJCharSequenceTemplates.class)
|
||||
final class AssertJCharSequenceTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AssertThatCharSequenceIsEmpty.class)
|
||||
void testAssertThatCharSequenceIsEmpty1() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
@Template(AssertThatCharSequenceIsEmpty.class)
|
||||
void testAssertThatCharSequenceIsEmpty2() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
@Template(AssertThatCharSequenceIsNotEmpty.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatCharSequenceIsNotEmpty() {
|
||||
return ImmutableSet.of(assertThat("foo").isNotEmpty(), assertThat("bar").isNotEmpty());
|
||||
}
|
||||
|
||||
@Template(AssertThatCharSequenceHasSize.class)
|
||||
AbstractAssert<?, ?> testAssertThatCharSequenceHasSize() {
|
||||
return assertThat("foo").hasSize(3);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,19 +6,30 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractDoubleAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsCloseToWithOffset;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJDoubleTemplates.class)
|
||||
final class AssertJDoubleTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsCloseToWithOffset.class)
|
||||
ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsCloseToWithOffset() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0.0).isEqualTo(1, offset(0.0)),
|
||||
assertThat(0.0).isEqualTo(Double.valueOf(1), offset(0.0)));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0.0).isCloseTo(1, offset(0.0)),
|
||||
@@ -28,6 +39,7 @@ final class AssertJDoubleTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0.0).isEqualTo(Double.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0.0).isNotCloseTo(1, offset(0.0)),
|
||||
@@ -37,14 +49,17 @@ final class AssertJDoubleTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0.0).isNotEqualTo(Double.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsZero.class)
|
||||
AbstractDoubleAssert<?> testAbstractDoubleAssertIsZero() {
|
||||
return assertThat(0.0).isZero();
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsNotZero.class)
|
||||
AbstractDoubleAssert<?> testAbstractDoubleAssertIsNotZero() {
|
||||
return assertThat(0.0).isNotZero();
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsOne.class)
|
||||
AbstractDoubleAssert<?> testAbstractDoubleAssertIsOne() {
|
||||
return assertThat(0.0).isOne();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,19 +6,30 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractDoubleAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsCloseToWithOffset;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJDoubleTemplates.AbstractDoubleAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJDoubleTemplates.class)
|
||||
final class AssertJDoubleTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsCloseToWithOffset.class)
|
||||
ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsCloseToWithOffset() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0.0).isCloseTo(1, offset(0.0)),
|
||||
assertThat(0.0).isCloseTo(Double.valueOf(1), offset(0.0)));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0.0).isEqualTo(1),
|
||||
@@ -28,6 +39,7 @@ final class AssertJDoubleTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0.0).isEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0.0).isNotEqualTo(1),
|
||||
@@ -37,14 +49,17 @@ final class AssertJDoubleTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0.0).isNotEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsZero.class)
|
||||
AbstractDoubleAssert<?> testAbstractDoubleAssertIsZero() {
|
||||
return assertThat(0.0).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsNotZero.class)
|
||||
AbstractDoubleAssert<?> testAbstractDoubleAssertIsNotZero() {
|
||||
return assertThat(0.0).isNotEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractDoubleAssertIsOne.class)
|
||||
AbstractDoubleAssert<?> testAbstractDoubleAssertIsOne() {
|
||||
return assertThat(0.0).isEqualTo(1);
|
||||
}
|
||||
@@ -1,34 +1,45 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.assertj.core.api.EnumerableAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJEnumerableTemplates.EnumerableAssertHasSameSizeAs;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJEnumerableTemplates.EnumerableAssertIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJEnumerableTemplates.EnumerableAssertIsNotEmpty;
|
||||
|
||||
final class AssertJEnumableTemplatesTest implements RefasterTemplateTestCase {
|
||||
@TemplateCollection(AssertJEnumerableTemplates.class)
|
||||
final class AssertJEnumerableTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Iterables.class);
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsEmpty.class)
|
||||
void testEnumerableAssertIsEmpty1() {
|
||||
assertThat(ImmutableSet.of()).hasSize(0);
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsEmpty.class)
|
||||
void testEnumerableAssertIsEmpty2() {
|
||||
assertThat(ImmutableSet.of()).hasSizeLessThanOrEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsEmpty.class)
|
||||
void testEnumerableAssertIsEmpty3() {
|
||||
assertThat(ImmutableSet.of()).hasSizeLessThan(1);
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsNotEmpty.class)
|
||||
ImmutableSet<EnumerableAssert<?, Character>> testEnumerableAssertIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
assertThat("foo").hasSizeGreaterThan(0), assertThat("bar").hasSizeGreaterThanOrEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertHasSameSizeAs.class)
|
||||
ImmutableSet<EnumerableAssert<?, Integer>> testEnumerableAssertHasSameSizeAs() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(ImmutableSet.of(1)).hasSize(Iterables.size(ImmutableSet.of(2))),
|
||||
@@ -1,33 +1,44 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.assertj.core.api.EnumerableAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJEnumerableTemplates.EnumerableAssertHasSameSizeAs;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJEnumerableTemplates.EnumerableAssertIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJEnumerableTemplates.EnumerableAssertIsNotEmpty;
|
||||
|
||||
final class AssertJEnumableTemplatesTest implements RefasterTemplateTestCase {
|
||||
@TemplateCollection(AssertJEnumerableTemplates.class)
|
||||
final class AssertJEnumerableTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Iterables.class);
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsEmpty.class)
|
||||
void testEnumerableAssertIsEmpty1() {
|
||||
assertThat(ImmutableSet.of()).isEmpty();
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsEmpty.class)
|
||||
void testEnumerableAssertIsEmpty2() {
|
||||
assertThat(ImmutableSet.of()).isEmpty();
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsEmpty.class)
|
||||
void testEnumerableAssertIsEmpty3() {
|
||||
assertThat(ImmutableSet.of()).isEmpty();
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertIsNotEmpty.class)
|
||||
ImmutableSet<EnumerableAssert<?, Character>> testEnumerableAssertIsNotEmpty() {
|
||||
return ImmutableSet.of(assertThat("foo").isNotEmpty(), assertThat("bar").isNotEmpty());
|
||||
}
|
||||
|
||||
@Template(EnumerableAssertHasSameSizeAs.class)
|
||||
ImmutableSet<EnumerableAssert<?, Integer>> testEnumerableAssertHasSameSizeAs() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(ImmutableSet.of(1)).hasSameSizeAs(ImmutableSet.of(2)),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,19 +6,30 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractFloatAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsCloseToWithOffset;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJFloatTemplates.class)
|
||||
final class AssertJFloatTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsCloseToWithOffset.class)
|
||||
ImmutableSet<AbstractFloatAssert<?>> testAbstractFloatAssertIsCloseToWithOffset() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0F).isEqualTo(1, offset(0F)),
|
||||
assertThat(0F).isEqualTo(Float.valueOf(1), offset(0F)));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractFloatAssert<?>> testAbstractFloatAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0F).isCloseTo(1, offset(0F)),
|
||||
@@ -28,6 +39,7 @@ final class AssertJFloatTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0F).isEqualTo(Float.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractFloatAssert<?>> testAbstractFloatAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0F).isNotCloseTo(1, offset(0F)),
|
||||
@@ -37,14 +49,17 @@ final class AssertJFloatTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0F).isNotEqualTo(Float.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsZero.class)
|
||||
AbstractFloatAssert<?> testAbstractFloatAssertIsZero() {
|
||||
return assertThat(0F).isZero();
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsNotZero.class)
|
||||
AbstractFloatAssert<?> testAbstractFloatAssertIsNotZero() {
|
||||
return assertThat(0F).isNotZero();
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsOne.class)
|
||||
AbstractFloatAssert<?> testAbstractFloatAssertIsOne() {
|
||||
return assertThat(0F).isOne();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,19 +6,30 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractFloatAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsCloseToWithOffset;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJFloatTemplates.AbstractFloatAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJFloatTemplates.class)
|
||||
final class AssertJFloatTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsCloseToWithOffset.class)
|
||||
ImmutableSet<AbstractFloatAssert<?>> testAbstractFloatAssertIsCloseToWithOffset() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0F).isCloseTo(1, offset(0F)),
|
||||
assertThat(0F).isCloseTo(Float.valueOf(1), offset(0F)));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractFloatAssert<?>> testAbstractFloatAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0F).isEqualTo(1),
|
||||
@@ -28,6 +39,7 @@ final class AssertJFloatTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0F).isEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractFloatAssert<?>> testAbstractFloatAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0F).isNotEqualTo(1),
|
||||
@@ -37,14 +49,17 @@ final class AssertJFloatTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0F).isNotEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsZero.class)
|
||||
AbstractFloatAssert<?> testAbstractFloatAssertIsZero() {
|
||||
return assertThat(0F).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsNotZero.class)
|
||||
AbstractFloatAssert<?> testAbstractFloatAssertIsNotZero() {
|
||||
return assertThat(0F).isNotEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractFloatAssertIsOne.class)
|
||||
AbstractFloatAssert<?> testAbstractFloatAssertIsOne() {
|
||||
return assertThat(0F).isEqualTo(1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractIntegerAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJIntegerTemplates.class)
|
||||
final class AssertJIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractIntegerAssert<?>> testAbstractIntegerAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0).isCloseTo(1, offset(0)),
|
||||
@@ -22,6 +31,7 @@ final class AssertJIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0).isEqualTo(Integer.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractIntegerAssert<?>> testAbstractIntegerAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0).isNotCloseTo(1, offset(0)),
|
||||
@@ -31,14 +41,17 @@ final class AssertJIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0).isNotEqualTo(Integer.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsZero.class)
|
||||
AbstractIntegerAssert<?> testAbstractIntegerAssertIsZero() {
|
||||
return assertThat(0).isZero();
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsNotZero.class)
|
||||
AbstractIntegerAssert<?> testAbstractIntegerAssertIsNotZero() {
|
||||
return assertThat(0).isNotZero();
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsOne.class)
|
||||
AbstractIntegerAssert<?> testAbstractIntegerAssertIsOne() {
|
||||
return assertThat(0).isOne();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractIntegerAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJIntegerTemplates.AbstractIntegerAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJIntegerTemplates.class)
|
||||
final class AssertJIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractIntegerAssert<?>> testAbstractIntegerAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0).isEqualTo(1),
|
||||
@@ -22,6 +31,7 @@ final class AssertJIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0).isEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractIntegerAssert<?>> testAbstractIntegerAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0).isNotEqualTo(1),
|
||||
@@ -31,14 +41,17 @@ final class AssertJIntegerTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0).isNotEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsZero.class)
|
||||
AbstractIntegerAssert<?> testAbstractIntegerAssertIsZero() {
|
||||
return assertThat(0).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsNotZero.class)
|
||||
AbstractIntegerAssert<?> testAbstractIntegerAssertIsNotZero() {
|
||||
return assertThat(0).isNotEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractIntegerAssertIsOne.class)
|
||||
AbstractIntegerAssert<?> testAbstractIntegerAssertIsOne() {
|
||||
return assertThat(0).isEqualTo(1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractLongAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJLongTemplates.class)
|
||||
final class AssertJLongTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractLongAssert<?>> testAbstractLongAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0L).isCloseTo(1, offset(0L)),
|
||||
@@ -22,6 +31,7 @@ final class AssertJLongTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0L).isEqualTo(Long.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractLongAssert<?>> testAbstractLongAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0L).isNotCloseTo(1, offset(0L)),
|
||||
@@ -31,14 +41,17 @@ final class AssertJLongTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0L).isNotEqualTo(Long.valueOf(1)));
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsZero.class)
|
||||
AbstractLongAssert<?> testAbstractLongAssertIsZero() {
|
||||
return assertThat(0L).isZero();
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsNotZero.class)
|
||||
AbstractLongAssert<?> testAbstractLongAssertIsNotZero() {
|
||||
return assertThat(0L).isNotZero();
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsOne.class)
|
||||
AbstractLongAssert<?> testAbstractLongAssertIsOne() {
|
||||
return assertThat(0L).isOne();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractLongAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJLongTemplates.AbstractLongAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJLongTemplates.class)
|
||||
final class AssertJLongTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractLongAssert<?>> testAbstractLongAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0L).isEqualTo(1),
|
||||
@@ -22,6 +31,7 @@ final class AssertJLongTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0L).isEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractLongAssert<?>> testAbstractLongAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(0L).isNotEqualTo(1),
|
||||
@@ -31,14 +41,17 @@ final class AssertJLongTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(0L).isNotEqualTo(1));
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsZero.class)
|
||||
AbstractLongAssert<?> testAbstractLongAssertIsZero() {
|
||||
return assertThat(0L).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsNotZero.class)
|
||||
AbstractLongAssert<?> testAbstractLongAssertIsNotZero() {
|
||||
return assertThat(0L).isNotEqualTo(0);
|
||||
}
|
||||
|
||||
@Template(AbstractLongAssertIsOne.class)
|
||||
AbstractLongAssert<?> testAbstractLongAssertIsOne() {
|
||||
return assertThat(0L).isEqualTo(1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -6,9 +6,17 @@ import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import org.assertj.core.api.NumberAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsNegative;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsNotNegative;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsNotPositive;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsPositive;
|
||||
|
||||
@TemplateCollection(AssertJNumberTemplates.class)
|
||||
final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsPositive() {
|
||||
@Template(NumberAssertIsPositive.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsPositive() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isGreaterThan((byte) 0),
|
||||
assertThat((byte) 0).isGreaterThanOrEqualTo((byte) 1),
|
||||
@@ -25,7 +33,8 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ZERO));
|
||||
}
|
||||
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotPositive() {
|
||||
@Template(NumberAssertIsNotPositive.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotPositive() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isLessThanOrEqualTo((byte) 0),
|
||||
assertThat((byte) 0).isLessThan((byte) 1),
|
||||
@@ -42,7 +51,8 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ZERO));
|
||||
}
|
||||
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNegative() {
|
||||
@Template(NumberAssertIsNegative.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNegative() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isLessThan((byte) 0),
|
||||
assertThat((byte) 0).isLessThanOrEqualTo((byte) -1),
|
||||
@@ -59,7 +69,8 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ZERO));
|
||||
}
|
||||
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotNegative() {
|
||||
@Template(NumberAssertIsNotNegative.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotNegative() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isGreaterThanOrEqualTo((byte) 0),
|
||||
assertThat((byte) 0).isGreaterThan((byte) -1),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -6,9 +6,17 @@ import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import org.assertj.core.api.NumberAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsNegative;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsNotNegative;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsNotPositive;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJNumberTemplates.NumberAssertIsPositive;
|
||||
|
||||
@TemplateCollection(AssertJNumberTemplates.class)
|
||||
final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsPositive() {
|
||||
@Template(NumberAssertIsPositive.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsPositive() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isPositive(),
|
||||
assertThat((byte) 0).isPositive(),
|
||||
@@ -25,7 +33,8 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isPositive());
|
||||
}
|
||||
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotPositive() {
|
||||
@Template(NumberAssertIsNotPositive.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotPositive() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isNotPositive(),
|
||||
assertThat((byte) 0).isNotPositive(),
|
||||
@@ -42,7 +51,8 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isNotPositive());
|
||||
}
|
||||
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNegative() {
|
||||
@Template(NumberAssertIsNegative.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNegative() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isNegative(),
|
||||
assertThat((byte) 0).isNegative(),
|
||||
@@ -59,7 +69,8 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(BigDecimal.ZERO).isNegative());
|
||||
}
|
||||
|
||||
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotNegative() {
|
||||
@Template(NumberAssertIsNotNegative.class)
|
||||
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotNegative() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((byte) 0).isNotNegative(),
|
||||
assertThat((byte) 0).isNotNegative(),
|
||||
@@ -0,0 +1,40 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatHasToString;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsInstanceOf;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsNotInstanceOf;
|
||||
|
||||
@TemplateCollection(AssertJObjectTemplates.class)
|
||||
final class AssertJObjectTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AssertThatIsInstanceOf.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsInstanceOf() {
|
||||
return assertThat("foo" instanceof String).isTrue();
|
||||
}
|
||||
|
||||
@Template(AssertThatIsNotInstanceOf.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsNotInstanceOf() {
|
||||
return assertThat("foo" instanceof String).isFalse();
|
||||
}
|
||||
|
||||
@Template(AssertThatIsIsEqualTo.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsIsEqualTo() {
|
||||
return assertThat("foo".equals("bar")).isTrue();
|
||||
}
|
||||
|
||||
@Template(AssertThatIsIsNotEqualTo.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsIsNotEqualTo() {
|
||||
return assertThat("foo".equals("bar")).isFalse();
|
||||
}
|
||||
|
||||
@Template(AssertThatHasToString.class)
|
||||
AbstractAssert<?, ?> testAssertThatHasToString() {
|
||||
return assertThat(new Object().toString()).isEqualTo("foo");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatHasToString;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsInstanceOf;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJObjectTemplates.AssertThatIsNotInstanceOf;
|
||||
|
||||
@TemplateCollection(AssertJObjectTemplates.class)
|
||||
final class AssertJObjectTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AssertThatIsInstanceOf.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsInstanceOf() {
|
||||
return assertThat("foo").isInstanceOf(String.class);
|
||||
}
|
||||
|
||||
@Template(AssertThatIsNotInstanceOf.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsNotInstanceOf() {
|
||||
return assertThat("foo").isNotInstanceOf(String.class);
|
||||
}
|
||||
|
||||
@Template(AssertThatIsIsEqualTo.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsIsEqualTo() {
|
||||
return assertThat("foo").isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Template(AssertThatIsIsNotEqualTo.class)
|
||||
AbstractAssert<?, ?> testAssertThatIsIsNotEqualTo() {
|
||||
return assertThat("foo").isNotEqualTo("bar");
|
||||
}
|
||||
|
||||
@Template(AssertThatHasToString.class)
|
||||
AbstractAssert<?, ?> testAssertThatHasToString() {
|
||||
return assertThat(new Object()).hasToString("foo");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -6,36 +6,53 @@ import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Optional;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.OptionalAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertContainsSame;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertHasValue;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertIsPresent;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptionalHasValueMatching;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptionalIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptionalIsPresent;
|
||||
|
||||
@TemplateCollection(AssertJOptionalTemplates.class)
|
||||
final class AssertJOptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AssertThatOptional.class)
|
||||
AbstractAssert<?, ?> testAssertThatOptional() {
|
||||
return assertThat(Optional.of(new Object()).orElseThrow());
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertIsPresent.class)
|
||||
ImmutableSet<OptionalAssert<Integer>> testAbstractOptionalAssertIsPresent() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).isNotEmpty(),
|
||||
assertThat(Optional.of(2)).isNotEqualTo(Optional.empty()));
|
||||
}
|
||||
|
||||
@Template(AssertThatOptionalIsPresent.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatOptionalIsPresent() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1).isPresent()).isTrue(),
|
||||
assertThat(Optional.of(2).isEmpty()).isFalse());
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertIsEmpty.class)
|
||||
ImmutableSet<OptionalAssert<Integer>> testAbstractOptionalAssertIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).isNotPresent(),
|
||||
assertThat(Optional.of(2)).isEqualTo(Optional.empty()));
|
||||
}
|
||||
|
||||
@Template(AssertThatOptionalIsEmpty.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatOptionalIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1).isEmpty()).isTrue(),
|
||||
assertThat(Optional.of(2).isPresent()).isFalse());
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertHasValue.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAbstractOptionalAssertHasValue() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).get().isEqualTo(1),
|
||||
@@ -44,12 +61,14 @@ final class AssertJOptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(Optional.of(4)).isPresent().hasValue(4));
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertContainsSame.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAbstractOptionalAssertContainsSame() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).get().isSameAs(1),
|
||||
assertThat(Optional.of(2)).isPresent().isSameAs(2));
|
||||
}
|
||||
|
||||
@Template(AssertThatOptionalHasValueMatching.class)
|
||||
AbstractAssert<?, ?> testAssertThatOptionalHasValueMatching() {
|
||||
return assertThat(Optional.of("foo").filter(String::isEmpty)).isPresent();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -6,32 +6,49 @@ import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Optional;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.OptionalAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertContainsSame;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertHasValue;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AbstractOptionalAssertIsPresent;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptionalHasValueMatching;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptionalIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJOptionalTemplates.AssertThatOptionalIsPresent;
|
||||
|
||||
@TemplateCollection(AssertJOptionalTemplates.class)
|
||||
final class AssertJOptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AssertThatOptional.class)
|
||||
AbstractAssert<?, ?> testAssertThatOptional() {
|
||||
return assertThat(Optional.of(new Object())).get();
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertIsPresent.class)
|
||||
ImmutableSet<OptionalAssert<Integer>> testAbstractOptionalAssertIsPresent() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).isPresent(), assertThat(Optional.of(2)).isPresent());
|
||||
}
|
||||
|
||||
@Template(AssertThatOptionalIsPresent.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatOptionalIsPresent() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).isPresent(), assertThat(Optional.of(2)).isPresent());
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertIsEmpty.class)
|
||||
ImmutableSet<OptionalAssert<Integer>> testAbstractOptionalAssertIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).isEmpty(), assertThat(Optional.of(2)).isEmpty());
|
||||
}
|
||||
|
||||
@Template(AssertThatOptionalIsEmpty.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAssertThatOptionalIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).isEmpty(), assertThat(Optional.of(2)).isEmpty());
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertHasValue.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAbstractOptionalAssertHasValue() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).hasValue(1),
|
||||
@@ -40,11 +57,13 @@ final class AssertJOptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat(Optional.of(4)).hasValue(4));
|
||||
}
|
||||
|
||||
@Template(AbstractOptionalAssertContainsSame.class)
|
||||
ImmutableSet<AbstractAssert<?, ?>> testAbstractOptionalAssertContainsSame() {
|
||||
return ImmutableSet.of(
|
||||
assertThat(Optional.of(1)).containsSame(1), assertThat(Optional.of(2)).containsSame(2));
|
||||
}
|
||||
|
||||
@Template(AssertThatOptionalHasValueMatching.class)
|
||||
AbstractAssert<?, ?> testAssertThatOptionalHasValueMatching() {
|
||||
return assertThat(Optional.of("foo")).get().matches(String::isEmpty);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractShortAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJShortTemplates.class)
|
||||
final class AssertJShortTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractShortAssert<?>> testAbstractShortAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((short) 0).isCloseTo((short) 1, offset((short) 0)),
|
||||
@@ -22,6 +31,7 @@ final class AssertJShortTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((short) 0).isEqualTo(Short.valueOf((short) 1)));
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractShortAssert<?>> testAbstractShortAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((short) 0).isNotCloseTo((short) 1, offset((short) 0)),
|
||||
@@ -31,14 +41,17 @@ final class AssertJShortTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((short) 0).isNotEqualTo(Short.valueOf((short) 1)));
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsZero.class)
|
||||
AbstractShortAssert<?> testAbstractShortAssertIsZero() {
|
||||
return assertThat((short) 0).isZero();
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsNotZero.class)
|
||||
AbstractShortAssert<?> testAbstractShortAssertIsNotZero() {
|
||||
return assertThat((short) 0).isNotZero();
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsOne.class)
|
||||
AbstractShortAssert<?> testAbstractShortAssertIsOne() {
|
||||
return assertThat((short) 0).isOne();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
@@ -6,13 +6,22 @@ import static org.assertj.core.data.Percentage.withPercentage;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.assertj.core.api.AbstractShortAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsNotEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsNotZero;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsOne;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJShortTemplates.AbstractShortAssertIsZero;
|
||||
|
||||
@TemplateCollection(AssertJShortTemplates.class)
|
||||
final class AssertJShortTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(offset(0), withPercentage(0));
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsEqualTo.class)
|
||||
ImmutableSet<AbstractShortAssert<?>> testAbstractShortAssertIsEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((short) 0).isEqualTo((short) 1),
|
||||
@@ -22,6 +31,7 @@ final class AssertJShortTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((short) 0).isEqualTo((short) 1));
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsNotEqualTo.class)
|
||||
ImmutableSet<AbstractShortAssert<?>> testAbstractShortAssertIsNotEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
assertThat((short) 0).isNotEqualTo((short) 1),
|
||||
@@ -31,14 +41,17 @@ final class AssertJShortTemplatesTest implements RefasterTemplateTestCase {
|
||||
assertThat((short) 0).isNotEqualTo((short) 1));
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsZero.class)
|
||||
AbstractShortAssert<?> testAbstractShortAssertIsZero() {
|
||||
return assertThat((short) 0).isEqualTo((short) 0);
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsNotZero.class)
|
||||
AbstractShortAssert<?> testAbstractShortAssertIsNotZero() {
|
||||
return assertThat((short) 0).isNotEqualTo((short) 0);
|
||||
}
|
||||
|
||||
@Template(AbstractShortAssertIsOne.class)
|
||||
AbstractShortAssert<?> testAbstractShortAssertIsOne() {
|
||||
return assertThat((short) 0).isEqualTo((short) 1);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AbstractStringAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AbstractStringAssertStringIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AbstractStringAssertStringIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AssertThatStringIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AssertThatStringIsNotEmpty;
|
||||
|
||||
@TemplateCollection(AssertJStringTemplates.class)
|
||||
final class AssertJStringTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AbstractStringAssertStringIsEmpty.class)
|
||||
void testAbstractStringAssertStringIsEmpty() {
|
||||
assertThat("foo").isEqualTo("");
|
||||
}
|
||||
|
||||
@Template(AssertThatStringIsEmpty.class)
|
||||
void testAssertThatStringIsEmpty() {
|
||||
assertThat("foo".isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Template(AbstractStringAssertStringIsNotEmpty.class)
|
||||
AbstractStringAssert<?> testAbstractStringAssertStringIsNotEmpty() {
|
||||
return assertThat("foo").isNotEqualTo("");
|
||||
}
|
||||
|
||||
@Template(AssertThatStringIsNotEmpty.class)
|
||||
AbstractAssert<?, ?> testAssertThatStringIsNotEmpty() {
|
||||
return assertThat("foo".isEmpty()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AbstractStringAssert;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AbstractStringAssertStringIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AbstractStringAssertStringIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AssertThatStringIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssertJStringTemplates.AssertThatStringIsNotEmpty;
|
||||
|
||||
@TemplateCollection(AssertJStringTemplates.class)
|
||||
final class AssertJStringTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(AbstractStringAssertStringIsEmpty.class)
|
||||
void testAbstractStringAssertStringIsEmpty() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
@Template(AssertThatStringIsEmpty.class)
|
||||
void testAssertThatStringIsEmpty() {
|
||||
assertThat("foo").isEmpty();
|
||||
}
|
||||
|
||||
@Template(AbstractStringAssertStringIsNotEmpty.class)
|
||||
AbstractStringAssert<?> testAbstractStringAssertStringIsNotEmpty() {
|
||||
return assertThat("foo").isNotEmpty();
|
||||
}
|
||||
|
||||
@Template(AssertThatStringIsNotEmpty.class)
|
||||
AbstractAssert<?, ?> testAssertThatStringIsNotEmpty() {
|
||||
return assertThat("foo").isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
|
||||
@@ -17,7 +17,23 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.CheckIndex;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.CreateEnumMap;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.DisjointCollections;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.DisjointSets;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.IterableIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.IteratorGetNextOrDefault;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.LogicalImplication;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.MapGetOrNull;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.MapKeyStream;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.MapValueStream;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.SplitToStream;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.StreamToImmutableEnumSet;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.UnboundedSingleElementStream;
|
||||
|
||||
@TemplateCollection(AssortedTemplates.class)
|
||||
final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -32,22 +48,27 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
toImmutableSet());
|
||||
}
|
||||
|
||||
@Template(CheckIndex.class)
|
||||
int testCheckIndex() {
|
||||
return Preconditions.checkElementIndex(0, 1);
|
||||
}
|
||||
|
||||
@Template(CreateEnumMap.class)
|
||||
Map<RoundingMode, String> testCreateEnumMap() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
@Template(MapGetOrNull.class)
|
||||
String testMapGetOrNull() {
|
||||
return ImmutableMap.of(1, "foo").getOrDefault("bar", null);
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableEnumSet.class)
|
||||
ImmutableSet<BoundType> testStreamToImmutableEnumSet() {
|
||||
return Stream.of(BoundType.OPEN).collect(toImmutableSet());
|
||||
}
|
||||
|
||||
@Template(IteratorGetNextOrDefault.class)
|
||||
ImmutableSet<String> testIteratorGetNextOrDefault() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.of("a").iterator().hasNext()
|
||||
@@ -58,6 +79,7 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
}
|
||||
|
||||
// XXX: Only the first statement is rewritten. Make smarter.
|
||||
@Template(LogicalImplication.class)
|
||||
ImmutableSet<Boolean> testLogicalImplication() {
|
||||
return ImmutableSet.of(
|
||||
toString().isEmpty() || (!toString().isEmpty() && true),
|
||||
@@ -66,16 +88,19 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
3 >= 4 || (3 < 4 && true));
|
||||
}
|
||||
|
||||
@Template(UnboundedSingleElementStream.class)
|
||||
Stream<String> testUnboundedSingleElementStream() {
|
||||
return Streams.stream(Iterables.cycle("foo"));
|
||||
}
|
||||
|
||||
@Template(DisjointSets.class)
|
||||
ImmutableSet<Boolean> testDisjointSets() {
|
||||
return ImmutableSet.of(
|
||||
Sets.intersection(ImmutableSet.of(1), ImmutableSet.of(2)).isEmpty(),
|
||||
ImmutableSet.of(3).stream().noneMatch(ImmutableSet.of(4)::contains));
|
||||
}
|
||||
|
||||
@Template(DisjointCollections.class)
|
||||
ImmutableSet<Boolean> testDisjointCollections() {
|
||||
return ImmutableSet.of(
|
||||
Collections.disjoint(ImmutableSet.copyOf(ImmutableList.of(1)), ImmutableList.of(2)),
|
||||
@@ -84,18 +109,22 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
Collections.disjoint(ImmutableList.of(7), new HashSet<>(ImmutableList.of(8))));
|
||||
}
|
||||
|
||||
@Template(IterableIsEmpty.class)
|
||||
boolean testIterableIsEmpty() {
|
||||
return !ImmutableList.of().iterator().hasNext();
|
||||
}
|
||||
|
||||
@Template(MapKeyStream.class)
|
||||
Stream<String> testMapKeyStream() {
|
||||
return ImmutableMap.of("foo", 1).entrySet().stream().map(Map.Entry::getKey);
|
||||
}
|
||||
|
||||
@Template(MapValueStream.class)
|
||||
Stream<Integer> testMapValueStream() {
|
||||
return ImmutableMap.of("foo", 1).entrySet().stream().map(Map.Entry::getValue);
|
||||
}
|
||||
|
||||
@Template(SplitToStream.class)
|
||||
ImmutableSet<Stream<String>> testSplitToStream() {
|
||||
return ImmutableSet.of(
|
||||
Streams.stream(Splitter.on(':').split("foo")),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.toImmutableEnumSet;
|
||||
@@ -21,7 +21,23 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.CheckIndex;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.CreateEnumMap;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.DisjointCollections;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.DisjointSets;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.IterableIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.IteratorGetNextOrDefault;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.LogicalImplication;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.MapGetOrNull;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.MapKeyStream;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.MapValueStream;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.SplitToStream;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.StreamToImmutableEnumSet;
|
||||
import tech.picnic.errorprone.refastertemplates.AssortedTemplates.UnboundedSingleElementStream;
|
||||
|
||||
@TemplateCollection(AssortedTemplates.class)
|
||||
final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -36,22 +52,27 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
toImmutableSet());
|
||||
}
|
||||
|
||||
@Template(CheckIndex.class)
|
||||
int testCheckIndex() {
|
||||
return Objects.checkIndex(0, 1);
|
||||
}
|
||||
|
||||
@Template(CreateEnumMap.class)
|
||||
Map<RoundingMode, String> testCreateEnumMap() {
|
||||
return new EnumMap<>(RoundingMode.class);
|
||||
}
|
||||
|
||||
@Template(MapGetOrNull.class)
|
||||
String testMapGetOrNull() {
|
||||
return ImmutableMap.of(1, "foo").get("bar");
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableEnumSet.class)
|
||||
ImmutableSet<BoundType> testStreamToImmutableEnumSet() {
|
||||
return Stream.of(BoundType.OPEN).collect(toImmutableEnumSet());
|
||||
}
|
||||
|
||||
@Template(IteratorGetNextOrDefault.class)
|
||||
ImmutableSet<String> testIteratorGetNextOrDefault() {
|
||||
return ImmutableSet.of(
|
||||
Iterators.getNext(ImmutableList.of("a").iterator(), "foo"),
|
||||
@@ -60,6 +81,7 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
}
|
||||
|
||||
// XXX: Only the first statement is rewritten. Make smarter.
|
||||
@Template(LogicalImplication.class)
|
||||
ImmutableSet<Boolean> testLogicalImplication() {
|
||||
return ImmutableSet.of(
|
||||
toString().isEmpty() || true,
|
||||
@@ -68,16 +90,19 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
3 >= 4 || (3 < 4 && true));
|
||||
}
|
||||
|
||||
@Template(UnboundedSingleElementStream.class)
|
||||
Stream<String> testUnboundedSingleElementStream() {
|
||||
return Stream.generate(() -> "foo");
|
||||
}
|
||||
|
||||
@Template(DisjointSets.class)
|
||||
ImmutableSet<Boolean> testDisjointSets() {
|
||||
return ImmutableSet.of(
|
||||
Collections.disjoint(ImmutableSet.of(1), ImmutableSet.of(2)),
|
||||
Collections.disjoint(ImmutableSet.of(3), ImmutableSet.of(4)));
|
||||
}
|
||||
|
||||
@Template(DisjointCollections.class)
|
||||
ImmutableSet<Boolean> testDisjointCollections() {
|
||||
return ImmutableSet.of(
|
||||
Collections.disjoint(ImmutableList.of(1), ImmutableList.of(2)),
|
||||
@@ -86,18 +111,22 @@ final class AssortedTemplatesTest implements RefasterTemplateTestCase {
|
||||
Collections.disjoint(ImmutableList.of(7), ImmutableList.of(8)));
|
||||
}
|
||||
|
||||
@Template(IterableIsEmpty.class)
|
||||
boolean testIterableIsEmpty() {
|
||||
return Iterables.isEmpty(ImmutableList.of());
|
||||
}
|
||||
|
||||
@Template(MapKeyStream.class)
|
||||
Stream<String> testMapKeyStream() {
|
||||
return ImmutableMap.of("foo", 1).keySet().stream();
|
||||
}
|
||||
|
||||
@Template(MapValueStream.class)
|
||||
Stream<Integer> testMapValueStream() {
|
||||
return ImmutableMap.of("foo", 1).values().stream();
|
||||
}
|
||||
|
||||
@Template(SplitToStream.class)
|
||||
ImmutableSet<Stream<String>> testSplitToStream() {
|
||||
return ImmutableSet.of(
|
||||
Splitter.on(':').splitToStream("foo"),
|
||||
@@ -1,21 +1,32 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalFactoryMethod;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalOne;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalTen;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalZero;
|
||||
|
||||
@TemplateCollection(BigDecimalTemplates.class)
|
||||
final class BigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(BigDecimalZero.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalZero() {
|
||||
return ImmutableSet.of(BigDecimal.valueOf(0), BigDecimal.valueOf(0L), new BigDecimal("0"));
|
||||
}
|
||||
|
||||
@Template(BigDecimalOne.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalOne() {
|
||||
return ImmutableSet.of(BigDecimal.valueOf(1), BigDecimal.valueOf(1L), new BigDecimal("1"));
|
||||
}
|
||||
|
||||
@Template(BigDecimalTen.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalTen() {
|
||||
return ImmutableSet.of(BigDecimal.valueOf(10), BigDecimal.valueOf(10L), new BigDecimal("10"));
|
||||
}
|
||||
|
||||
@Template(BigDecimalFactoryMethod.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalFactoryMethod() {
|
||||
return ImmutableSet.of(new BigDecimal(0), new BigDecimal(0L));
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.BigDecimal;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalFactoryMethod;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalOne;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalTen;
|
||||
import tech.picnic.errorprone.refastertemplates.BigDecimalTemplates.BigDecimalZero;
|
||||
|
||||
@TemplateCollection(BigDecimalTemplates.class)
|
||||
final class BigDecimalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(BigDecimalZero.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalZero() {
|
||||
return ImmutableSet.of(BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Template(BigDecimalOne.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalOne() {
|
||||
return ImmutableSet.of(BigDecimal.ONE, BigDecimal.ONE, BigDecimal.ONE);
|
||||
}
|
||||
|
||||
@Template(BigDecimalTen.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalTen() {
|
||||
return ImmutableSet.of(BigDecimal.TEN, BigDecimal.TEN, BigDecimal.TEN);
|
||||
}
|
||||
|
||||
@Template(BigDecimalFactoryMethod.class)
|
||||
ImmutableSet<BigDecimal> testBigDecimalFactoryMethod() {
|
||||
return ImmutableSet.of(BigDecimal.valueOf(0), BigDecimal.valueOf(0L));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -11,13 +11,37 @@ import java.util.LinkedList;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionAddAllToCollectionBlock;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionAddAllToCollectionExpression;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionRemoveAllFromCollectionBlock;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionRemoveAllFromCollectionExpression;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionSize;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionToArray;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionAsList;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionContains;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionIterator;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionParallelStream;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionStream;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionToArrayWithArray;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionToArrayWithGenerator;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionToString;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.NewArrayListFromCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.OptionalFirstCollectionElement;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.OptionalFirstQueueElement;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.RemoveOptionalFirstNavigableSetElement;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.RemoveOptionalFirstQueueElement;
|
||||
|
||||
@TemplateCollection(CollectionTemplates.class)
|
||||
final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Iterables.class, Lists.class);
|
||||
}
|
||||
|
||||
@Template(CollectionIsEmpty.class)
|
||||
ImmutableSet<Boolean> testCollectionIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of(1).size() == 0,
|
||||
@@ -30,14 +54,17 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet.of(8).asList().isEmpty());
|
||||
}
|
||||
|
||||
@Template(CollectionSize.class)
|
||||
ImmutableSet<Integer> testCollectionSize() {
|
||||
return ImmutableSet.of(Iterables.size(ImmutableSet.of(1)), ImmutableSet.of(2).asList().size());
|
||||
}
|
||||
|
||||
@Template(CollectionAddAllToCollectionExpression.class)
|
||||
boolean testCollectionAddAllToCollectionExpression() {
|
||||
return Iterables.addAll(new ArrayList<>(), ImmutableSet.of("foo"));
|
||||
}
|
||||
|
||||
@Template(CollectionAddAllToCollectionBlock.class)
|
||||
void testCollectionAddAllToCollectionBlock() {
|
||||
ImmutableSet.of("foo").forEach(new ArrayList<>()::add);
|
||||
for (Number element : ImmutableSet.of(1)) {
|
||||
@@ -48,10 +75,12 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Template(CollectionRemoveAllFromCollectionExpression.class)
|
||||
boolean testCollectionRemoveAllFromCollectionExpression() {
|
||||
return Iterables.removeAll(new ArrayList<>(), ImmutableSet.of("foo"));
|
||||
}
|
||||
|
||||
@Template(CollectionRemoveAllFromCollectionBlock.class)
|
||||
void testCollectionRemoveAllFromCollectionBlock() {
|
||||
ImmutableSet.of("foo").forEach(new ArrayList<>()::remove);
|
||||
for (Number element : ImmutableSet.of(1)) {
|
||||
@@ -62,30 +91,37 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Template(NewArrayListFromCollection.class)
|
||||
ArrayList<String> testNewArrayListFromCollection() {
|
||||
return Lists.newArrayList(ImmutableList.of("foo"));
|
||||
}
|
||||
|
||||
Stream<Integer> testImmutableCollectionStream() {
|
||||
return ImmutableSet.of(1).asList().stream();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionAsList.class)
|
||||
ImmutableList<Integer> testImmutableCollectionAsList() {
|
||||
return ImmutableList.copyOf(ImmutableSet.of(1));
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionStream.class)
|
||||
Stream<Integer> testImmutableCollectionStream() {
|
||||
return ImmutableSet.of(1).asList().stream();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionContains.class)
|
||||
boolean testImmutableCollectionContains() {
|
||||
return ImmutableSet.of(1).asList().contains("foo");
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionParallelStream.class)
|
||||
Stream<Integer> testImmutableCollectionParallelStream() {
|
||||
return ImmutableSet.of(1).asList().parallelStream();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionToString.class)
|
||||
String testImmutableCollectionToString() {
|
||||
return ImmutableSet.of(1).asList().toString();
|
||||
}
|
||||
|
||||
@Template(CollectionToArray.class)
|
||||
ImmutableSet<Object[]> testCollectionToArray() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of(1).toArray(new Object[1]),
|
||||
@@ -93,18 +129,22 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet.of(3).asList().toArray());
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionToArrayWithArray.class)
|
||||
Integer[] testImmutableCollectionToArrayWithArray() {
|
||||
return ImmutableSet.of(1).asList().toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionToArrayWithGenerator.class)
|
||||
Integer[] testImmutableCollectionToArrayWithGenerator() {
|
||||
return ImmutableSet.of(1).asList().toArray(Integer[]::new);
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionIterator.class)
|
||||
Iterator<Integer> testImmutableCollectionIterator() {
|
||||
return ImmutableSet.of(1).asList().iterator();
|
||||
}
|
||||
|
||||
@Template(OptionalFirstCollectionElement.class)
|
||||
ImmutableSet<Optional<Integer>> testOptionalFirstCollectionElement() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of(0).stream().findAny(),
|
||||
@@ -124,6 +164,7 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
: Optional.empty());
|
||||
}
|
||||
|
||||
@Template(OptionalFirstQueueElement.class)
|
||||
ImmutableSet<Optional<String>> testOptionalFirstQueueElement() {
|
||||
return ImmutableSet.of(
|
||||
new LinkedList<String>().stream().findAny(),
|
||||
@@ -141,6 +182,7 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
: Optional.empty());
|
||||
}
|
||||
|
||||
@Template(RemoveOptionalFirstNavigableSetElement.class)
|
||||
ImmutableSet<Optional<String>> testRemoveOptionalFirstNavigableSetElement() {
|
||||
return ImmutableSet.of(
|
||||
new TreeSet<String>().isEmpty()
|
||||
@@ -157,6 +199,7 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
: Optional.empty());
|
||||
}
|
||||
|
||||
@Template(RemoveOptionalFirstQueueElement.class)
|
||||
ImmutableSet<Optional<String>> testRemoveOptionalFirstQueueElement() {
|
||||
return ImmutableSet.of(
|
||||
new LinkedList<String>().isEmpty()
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -11,13 +11,37 @@ import java.util.LinkedList;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionAddAllToCollectionBlock;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionAddAllToCollectionExpression;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionRemoveAllFromCollectionBlock;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionRemoveAllFromCollectionExpression;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionSize;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.CollectionToArray;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionAsList;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionContains;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionIterator;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionParallelStream;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionStream;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionToArrayWithArray;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionToArrayWithGenerator;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.ImmutableCollectionToString;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.NewArrayListFromCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.OptionalFirstCollectionElement;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.OptionalFirstQueueElement;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.RemoveOptionalFirstNavigableSetElement;
|
||||
import tech.picnic.errorprone.refastertemplates.CollectionTemplates.RemoveOptionalFirstQueueElement;
|
||||
|
||||
@TemplateCollection(CollectionTemplates.class)
|
||||
final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Iterables.class, Lists.class);
|
||||
}
|
||||
|
||||
@Template(CollectionIsEmpty.class)
|
||||
ImmutableSet<Boolean> testCollectionIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of(1).isEmpty(),
|
||||
@@ -30,71 +54,87 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet.of(8).isEmpty());
|
||||
}
|
||||
|
||||
@Template(CollectionSize.class)
|
||||
ImmutableSet<Integer> testCollectionSize() {
|
||||
return ImmutableSet.of(ImmutableSet.of(1).size(), ImmutableSet.of(2).size());
|
||||
}
|
||||
|
||||
@Template(CollectionAddAllToCollectionExpression.class)
|
||||
boolean testCollectionAddAllToCollectionExpression() {
|
||||
return new ArrayList<>().addAll(ImmutableSet.of("foo"));
|
||||
}
|
||||
|
||||
@Template(CollectionAddAllToCollectionBlock.class)
|
||||
void testCollectionAddAllToCollectionBlock() {
|
||||
new ArrayList<>().addAll(ImmutableSet.of("foo"));
|
||||
new ArrayList<Number>().addAll(ImmutableSet.of(1));
|
||||
new ArrayList<Number>().addAll(ImmutableSet.of(2));
|
||||
}
|
||||
|
||||
@Template(CollectionRemoveAllFromCollectionExpression.class)
|
||||
boolean testCollectionRemoveAllFromCollectionExpression() {
|
||||
return new ArrayList<>().removeAll(ImmutableSet.of("foo"));
|
||||
}
|
||||
|
||||
@Template(CollectionRemoveAllFromCollectionBlock.class)
|
||||
void testCollectionRemoveAllFromCollectionBlock() {
|
||||
new ArrayList<>().removeAll(ImmutableSet.of("foo"));
|
||||
new ArrayList<Number>().removeAll(ImmutableSet.of(1));
|
||||
new ArrayList<Number>().removeAll(ImmutableSet.of(2));
|
||||
}
|
||||
|
||||
@Template(NewArrayListFromCollection.class)
|
||||
ArrayList<String> testNewArrayListFromCollection() {
|
||||
return new ArrayList<>(ImmutableList.of("foo"));
|
||||
}
|
||||
|
||||
Stream<Integer> testImmutableCollectionStream() {
|
||||
return ImmutableSet.of(1).stream();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionAsList.class)
|
||||
ImmutableList<Integer> testImmutableCollectionAsList() {
|
||||
return ImmutableSet.of(1).asList();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionStream.class)
|
||||
Stream<Integer> testImmutableCollectionStream() {
|
||||
return ImmutableSet.of(1).stream();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionContains.class)
|
||||
boolean testImmutableCollectionContains() {
|
||||
return ImmutableSet.of(1).contains("foo");
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionParallelStream.class)
|
||||
Stream<Integer> testImmutableCollectionParallelStream() {
|
||||
return ImmutableSet.of(1).parallelStream();
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionToString.class)
|
||||
String testImmutableCollectionToString() {
|
||||
return ImmutableSet.of(1).toString();
|
||||
}
|
||||
|
||||
@Template(CollectionToArray.class)
|
||||
ImmutableSet<Object[]> testCollectionToArray() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of(1).toArray(), ImmutableSet.of(2).toArray(), ImmutableSet.of(3).toArray());
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionToArrayWithArray.class)
|
||||
Integer[] testImmutableCollectionToArrayWithArray() {
|
||||
return ImmutableSet.of(1).toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionToArrayWithGenerator.class)
|
||||
Integer[] testImmutableCollectionToArrayWithGenerator() {
|
||||
return ImmutableSet.of(1).toArray(Integer[]::new);
|
||||
}
|
||||
|
||||
@Template(ImmutableCollectionIterator.class)
|
||||
Iterator<Integer> testImmutableCollectionIterator() {
|
||||
return ImmutableSet.of(1).iterator();
|
||||
}
|
||||
|
||||
@Template(OptionalFirstCollectionElement.class)
|
||||
ImmutableSet<Optional<Integer>> testOptionalFirstCollectionElement() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of(0).stream().findFirst(),
|
||||
@@ -106,6 +146,7 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSortedSet.of(3).stream().findFirst());
|
||||
}
|
||||
|
||||
@Template(OptionalFirstQueueElement.class)
|
||||
ImmutableSet<Optional<String>> testOptionalFirstQueueElement() {
|
||||
return ImmutableSet.of(
|
||||
new LinkedList<String>().stream().findFirst(),
|
||||
@@ -115,6 +156,7 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
Optional.ofNullable(new LinkedList<String>().peek()));
|
||||
}
|
||||
|
||||
@Template(RemoveOptionalFirstNavigableSetElement.class)
|
||||
ImmutableSet<Optional<String>> testRemoveOptionalFirstNavigableSetElement() {
|
||||
return ImmutableSet.of(
|
||||
Optional.ofNullable(new TreeSet<String>().pollFirst()),
|
||||
@@ -123,6 +165,7 @@ final class CollectionTemplatesTest implements RefasterTemplateTestCase {
|
||||
Optional.ofNullable(new TreeSet<String>().pollFirst()));
|
||||
}
|
||||
|
||||
@Template(RemoveOptionalFirstQueueElement.class)
|
||||
ImmutableSet<Optional<String>> testRemoveOptionalFirstQueueElement() {
|
||||
return ImmutableSet.of(
|
||||
Optional.ofNullable(new LinkedList<String>().poll()),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static java.util.Comparator.reverseOrder;
|
||||
import static java.util.function.Function.identity;
|
||||
@@ -8,7 +8,25 @@ import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.CustomComparator;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MaxOfPairCustomOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MaxOfPairNaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MinOfPairCustomOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MinOfPairNaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.NaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ReverseOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparing;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingCustom;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingCustomReversed;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingDouble;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingInt;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingLong;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingNaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingReversed;
|
||||
|
||||
@TemplateCollection(ComparatorTemplates.class)
|
||||
final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -16,6 +34,7 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Arrays.class, Collections.class, ImmutableList.class, ImmutableSet.class, identity());
|
||||
}
|
||||
|
||||
@Template(NaturalOrder.class)
|
||||
ImmutableSet<Comparator<String>> testNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.comparing(identity()),
|
||||
@@ -23,57 +42,68 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Comparator.<String>reverseOrder().reversed());
|
||||
}
|
||||
|
||||
@Template(ReverseOrder.class)
|
||||
Comparator<String> testReverseOrder() {
|
||||
return Comparator.<String>naturalOrder().reversed();
|
||||
}
|
||||
|
||||
@Template(CustomComparator.class)
|
||||
ImmutableSet<Comparator<String>> testCustomComparator() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.comparing(identity(), Comparator.comparingInt(String::length)),
|
||||
Comparator.comparing(s -> s, Comparator.comparingInt(String::length)));
|
||||
}
|
||||
|
||||
@Template(ThenComparing.class)
|
||||
Comparator<String> testThenComparing() {
|
||||
return Comparator.<String>naturalOrder().thenComparing(Comparator.comparing(String::isEmpty));
|
||||
}
|
||||
|
||||
@Template(ThenComparingReversed.class)
|
||||
Comparator<String> testThenComparingReversed() {
|
||||
return Comparator.<String>naturalOrder()
|
||||
.thenComparing(Comparator.comparing(String::isEmpty).reversed());
|
||||
}
|
||||
|
||||
@Template(ThenComparingCustom.class)
|
||||
Comparator<String> testThenComparingCustom() {
|
||||
return Comparator.<String>naturalOrder()
|
||||
.thenComparing(Comparator.comparing(String::isEmpty, reverseOrder()));
|
||||
}
|
||||
|
||||
@Template(ThenComparingCustomReversed.class)
|
||||
Comparator<String> testThenComparingCustomReversed() {
|
||||
return Comparator.<String>naturalOrder()
|
||||
.thenComparing(
|
||||
Comparator.comparing(String::isEmpty, Comparator.<Boolean>reverseOrder()).reversed());
|
||||
}
|
||||
|
||||
@Template(ThenComparingDouble.class)
|
||||
Comparator<Integer> testThenComparingDouble() {
|
||||
return Comparator.<Integer>naturalOrder()
|
||||
.thenComparing(Comparator.comparingDouble(Integer::doubleValue));
|
||||
}
|
||||
|
||||
@Template(ThenComparingInt.class)
|
||||
Comparator<Integer> testThenComparingInt() {
|
||||
return Comparator.<Integer>naturalOrder()
|
||||
.thenComparing(Comparator.comparingInt(Integer::intValue));
|
||||
}
|
||||
|
||||
@Template(ThenComparingLong.class)
|
||||
Comparator<Integer> testThenComparingLong() {
|
||||
return Comparator.<Integer>naturalOrder()
|
||||
.thenComparing(Comparator.comparingLong(Integer::longValue));
|
||||
}
|
||||
|
||||
@Template(ThenComparingNaturalOrder.class)
|
||||
ImmutableSet<Comparator<String>> testThenComparingNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.<String>naturalOrder().thenComparing(identity()),
|
||||
Comparator.<String>naturalOrder().thenComparing(s -> s));
|
||||
}
|
||||
|
||||
@Template(MinOfPairNaturalOrder.class)
|
||||
ImmutableSet<String> testMinOfPairNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Collections.min(Arrays.asList("a", "b")),
|
||||
@@ -81,6 +111,7 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Collections.min(ImmutableSet.of("a", "b")));
|
||||
}
|
||||
|
||||
@Template(MinOfPairCustomOrder.class)
|
||||
ImmutableSet<Object> testMinOfPairCustomOrder() {
|
||||
return ImmutableSet.of(
|
||||
Collections.min(Arrays.asList(new Object(), new Object()), (a, b) -> -1),
|
||||
@@ -88,6 +119,7 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Collections.min(ImmutableSet.of(new Object(), new Object()), (a, b) -> 1));
|
||||
}
|
||||
|
||||
@Template(MaxOfPairNaturalOrder.class)
|
||||
ImmutableSet<String> testMaxOfPairNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Collections.max(Arrays.asList("a", "b")),
|
||||
@@ -95,6 +127,7 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Collections.max(ImmutableSet.of("a", "b")));
|
||||
}
|
||||
|
||||
@Template(MaxOfPairCustomOrder.class)
|
||||
ImmutableSet<Object> testMaxOfPairCustomOrder() {
|
||||
return ImmutableSet.of(
|
||||
Collections.max(Arrays.asList(new Object(), new Object()), (a, b) -> -1),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
import static java.util.Comparator.reverseOrder;
|
||||
@@ -10,7 +10,25 @@ import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.CustomComparator;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MaxOfPairCustomOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MaxOfPairNaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MinOfPairCustomOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.MinOfPairNaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.NaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ReverseOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparing;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingCustom;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingCustomReversed;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingDouble;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingInt;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingLong;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingNaturalOrder;
|
||||
import tech.picnic.errorprone.refastertemplates.ComparatorTemplates.ThenComparingReversed;
|
||||
|
||||
@TemplateCollection(ComparatorTemplates.class)
|
||||
final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -18,59 +36,72 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Arrays.class, Collections.class, ImmutableList.class, ImmutableSet.class, identity());
|
||||
}
|
||||
|
||||
@Template(NaturalOrder.class)
|
||||
ImmutableSet<Comparator<String>> testNaturalOrder() {
|
||||
return ImmutableSet.of(naturalOrder(), naturalOrder(), naturalOrder());
|
||||
}
|
||||
|
||||
@Template(ReverseOrder.class)
|
||||
Comparator<String> testReverseOrder() {
|
||||
return reverseOrder();
|
||||
}
|
||||
|
||||
@Template(CustomComparator.class)
|
||||
ImmutableSet<Comparator<String>> testCustomComparator() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.comparingInt(String::length), Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ThenComparing.class)
|
||||
Comparator<String> testThenComparing() {
|
||||
return Comparator.<String>naturalOrder().thenComparing(String::isEmpty);
|
||||
}
|
||||
|
||||
@Template(ThenComparingReversed.class)
|
||||
Comparator<String> testThenComparingReversed() {
|
||||
return Comparator.<String>naturalOrder().thenComparing(String::isEmpty, reverseOrder());
|
||||
}
|
||||
|
||||
@Template(ThenComparingCustom.class)
|
||||
Comparator<String> testThenComparingCustom() {
|
||||
return Comparator.<String>naturalOrder().thenComparing(String::isEmpty, reverseOrder());
|
||||
}
|
||||
|
||||
@Template(ThenComparingCustomReversed.class)
|
||||
Comparator<String> testThenComparingCustomReversed() {
|
||||
return Comparator.<String>naturalOrder()
|
||||
.thenComparing(String::isEmpty, Comparator.<Boolean>reverseOrder().reversed());
|
||||
}
|
||||
|
||||
@Template(ThenComparingDouble.class)
|
||||
Comparator<Integer> testThenComparingDouble() {
|
||||
return Comparator.<Integer>naturalOrder().thenComparingDouble(Integer::doubleValue);
|
||||
}
|
||||
|
||||
@Template(ThenComparingInt.class)
|
||||
Comparator<Integer> testThenComparingInt() {
|
||||
return Comparator.<Integer>naturalOrder().thenComparingInt(Integer::intValue);
|
||||
}
|
||||
|
||||
@Template(ThenComparingLong.class)
|
||||
Comparator<Integer> testThenComparingLong() {
|
||||
return Comparator.<Integer>naturalOrder().thenComparingLong(Integer::longValue);
|
||||
}
|
||||
|
||||
@Template(ThenComparingNaturalOrder.class)
|
||||
ImmutableSet<Comparator<String>> testThenComparingNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.<String>naturalOrder().thenComparing(naturalOrder()),
|
||||
Comparator.<String>naturalOrder().thenComparing(naturalOrder()));
|
||||
}
|
||||
|
||||
@Template(MinOfPairNaturalOrder.class)
|
||||
ImmutableSet<String> testMinOfPairNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparators.min("a", "b"), Comparators.min("a", "b"), Comparators.min("a", "b"));
|
||||
}
|
||||
|
||||
@Template(MinOfPairCustomOrder.class)
|
||||
ImmutableSet<Object> testMinOfPairCustomOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparators.min(new Object(), new Object(), (a, b) -> -1),
|
||||
@@ -78,11 +109,13 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
|
||||
Comparators.min(new Object(), new Object(), (a, b) -> 1));
|
||||
}
|
||||
|
||||
@Template(MaxOfPairNaturalOrder.class)
|
||||
ImmutableSet<String> testMaxOfPairNaturalOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparators.max("a", "b"), Comparators.max("a", "b"), Comparators.max("a", "b"));
|
||||
}
|
||||
|
||||
@Template(MaxOfPairCustomOrder.class)
|
||||
ImmutableSet<Object> testMaxOfPairCustomOrder() {
|
||||
return ImmutableSet.of(
|
||||
Comparators.max(new Object(), new Object(), (a, b) -> -1),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -6,45 +6,73 @@ import java.util.OptionalDouble;
|
||||
import java.util.function.DoublePredicate;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.ConcatOneDoubleStream;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.ConcatTwoDoubleStreams;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamAllMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamAllMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamAnyMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamMin;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamNoneMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamNoneMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FilterOuterDoubleStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FilterOuterStreamAfterFlatMapToDouble;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FlatMapOuterDoubleStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FlatMapOuterStreamAfterFlatMapToDouble;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.MapOuterDoubleStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.MapOuterStreamAfterFlatMapToDouble;
|
||||
|
||||
@TemplateCollection(DoubleStreamTemplates.class)
|
||||
final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(ConcatOneDoubleStream.class)
|
||||
DoubleStream testConcatOneDoubleStream() {
|
||||
return Streams.concat(DoubleStream.of(1));
|
||||
}
|
||||
|
||||
@Template(ConcatTwoDoubleStreams.class)
|
||||
DoubleStream testConcatTwoDoubleStreams() {
|
||||
return Streams.concat(DoubleStream.of(1), DoubleStream.of(2));
|
||||
}
|
||||
|
||||
@Template(FilterOuterDoubleStreamAfterFlatMap.class)
|
||||
DoubleStream testFilterOuterDoubleStreamAfterFlatMap() {
|
||||
return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v).filter(n -> n > 1));
|
||||
}
|
||||
|
||||
@Template(FilterOuterStreamAfterFlatMapToDouble.class)
|
||||
DoubleStream testFilterOuterStreamAfterFlatMapToDouble() {
|
||||
return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v).filter(n -> n > 1));
|
||||
}
|
||||
|
||||
@Template(MapOuterDoubleStreamAfterFlatMap.class)
|
||||
DoubleStream testMapOuterDoubleStreamAfterFlatMap() {
|
||||
return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v).map(n -> n * 1));
|
||||
}
|
||||
|
||||
@Template(MapOuterStreamAfterFlatMapToDouble.class)
|
||||
DoubleStream testMapOuterStreamAfterFlatMapToDouble() {
|
||||
return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v).map(n -> n * 1));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterDoubleStreamAfterFlatMap.class)
|
||||
DoubleStream testFlatMapOuterDoubleStreamAfterFlatMap() {
|
||||
return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v).flatMap(DoubleStream::of));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterStreamAfterFlatMapToDouble.class)
|
||||
DoubleStream testFlatMapOuterStreamAfterFlatMapToDouble() {
|
||||
return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v).flatMap(DoubleStream::of));
|
||||
}
|
||||
|
||||
@Template(DoubleStreamIsEmpty.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).count() == 0,
|
||||
@@ -53,6 +81,7 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(4).findFirst().isEmpty());
|
||||
}
|
||||
|
||||
@Template(DoubleStreamIsNotEmpty.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).count() != 0,
|
||||
@@ -61,11 +90,18 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(4).findFirst().isPresent());
|
||||
}
|
||||
|
||||
@Template(DoubleStreamMin.class)
|
||||
OptionalDouble testDoubleStreamMin() {
|
||||
return DoubleStream.of(1).sorted().findFirst();
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testDoubleStreamNoneMatch() {
|
||||
@Template(DoubleStreamNoneMatch.class)
|
||||
boolean testDoubleStreamNoneMatch() {
|
||||
return DoubleStream.of(1).allMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(DoubleStreamNoneMatchPredicate.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamNoneMatchPredicate() {
|
||||
DoublePredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
!DoubleStream.of(1).anyMatch(n -> n > 1),
|
||||
@@ -73,22 +109,21 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(3).filter(pred).findAny().isEmpty());
|
||||
}
|
||||
|
||||
boolean testDoubleStreamNoneMatch2() {
|
||||
return DoubleStream.of(1).allMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(DoubleStreamAnyMatch.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamAnyMatch() {
|
||||
return ImmutableSet.of(
|
||||
!DoubleStream.of(1).noneMatch(n -> n > 1),
|
||||
DoubleStream.of(2).filter(n -> n > 2).findAny().isPresent());
|
||||
}
|
||||
|
||||
@Template(DoubleStreamAllMatch.class)
|
||||
boolean testDoubleStreamAllMatch() {
|
||||
return DoubleStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(DoubleStreamAllMatchPredicate.class)
|
||||
boolean testDoubleStreamAllMatchPredicate() {
|
||||
DoublePredicate pred = i -> i > 0;
|
||||
return DoubleStream.of(1).noneMatch(pred.negate());
|
||||
}
|
||||
|
||||
boolean testDoubleStreamAllMatch2() {
|
||||
return DoubleStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -6,45 +6,73 @@ import java.util.OptionalDouble;
|
||||
import java.util.function.DoublePredicate;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.ConcatOneDoubleStream;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.ConcatTwoDoubleStreams;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamAllMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamAllMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamAnyMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamMin;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamNoneMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.DoubleStreamNoneMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FilterOuterDoubleStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FilterOuterStreamAfterFlatMapToDouble;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FlatMapOuterDoubleStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.FlatMapOuterStreamAfterFlatMapToDouble;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.MapOuterDoubleStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.DoubleStreamTemplates.MapOuterStreamAfterFlatMapToDouble;
|
||||
|
||||
@TemplateCollection(DoubleStreamTemplates.class)
|
||||
final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(ConcatOneDoubleStream.class)
|
||||
DoubleStream testConcatOneDoubleStream() {
|
||||
return DoubleStream.of(1);
|
||||
}
|
||||
|
||||
@Template(ConcatTwoDoubleStreams.class)
|
||||
DoubleStream testConcatTwoDoubleStreams() {
|
||||
return DoubleStream.concat(DoubleStream.of(1), DoubleStream.of(2));
|
||||
}
|
||||
|
||||
@Template(FilterOuterDoubleStreamAfterFlatMap.class)
|
||||
DoubleStream testFilterOuterDoubleStreamAfterFlatMap() {
|
||||
return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v)).filter(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(FilterOuterStreamAfterFlatMapToDouble.class)
|
||||
DoubleStream testFilterOuterStreamAfterFlatMapToDouble() {
|
||||
return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v)).filter(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(MapOuterDoubleStreamAfterFlatMap.class)
|
||||
DoubleStream testMapOuterDoubleStreamAfterFlatMap() {
|
||||
return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v)).map(n -> n * 1);
|
||||
}
|
||||
|
||||
@Template(MapOuterStreamAfterFlatMapToDouble.class)
|
||||
DoubleStream testMapOuterStreamAfterFlatMapToDouble() {
|
||||
return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v)).map(n -> n * 1);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterDoubleStreamAfterFlatMap.class)
|
||||
DoubleStream testFlatMapOuterDoubleStreamAfterFlatMap() {
|
||||
return DoubleStream.of(1).flatMap(v -> DoubleStream.of(v * v)).flatMap(DoubleStream::of);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterStreamAfterFlatMapToDouble.class)
|
||||
DoubleStream testFlatMapOuterStreamAfterFlatMapToDouble() {
|
||||
return Stream.of(1).flatMapToDouble(v -> DoubleStream.of(v * v)).flatMap(DoubleStream::of);
|
||||
}
|
||||
|
||||
@Template(DoubleStreamIsEmpty.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).findAny().isEmpty(),
|
||||
@@ -53,6 +81,7 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(4).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@Template(DoubleStreamIsNotEmpty.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).findAny().isPresent(),
|
||||
@@ -61,11 +90,18 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(4).findAny().isPresent());
|
||||
}
|
||||
|
||||
@Template(DoubleStreamMin.class)
|
||||
OptionalDouble testDoubleStreamMin() {
|
||||
return DoubleStream.of(1).min();
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testDoubleStreamNoneMatch() {
|
||||
@Template(DoubleStreamNoneMatch.class)
|
||||
boolean testDoubleStreamNoneMatch() {
|
||||
return DoubleStream.of(1).noneMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(DoubleStreamNoneMatchPredicate.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamNoneMatchPredicate() {
|
||||
DoublePredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).noneMatch(n -> n > 1),
|
||||
@@ -73,21 +109,20 @@ final class DoubleStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
DoubleStream.of(3).noneMatch(pred));
|
||||
}
|
||||
|
||||
boolean testDoubleStreamNoneMatch2() {
|
||||
return DoubleStream.of(1).noneMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(DoubleStreamAnyMatch.class)
|
||||
ImmutableSet<Boolean> testDoubleStreamAnyMatch() {
|
||||
return ImmutableSet.of(
|
||||
DoubleStream.of(1).anyMatch(n -> n > 1), DoubleStream.of(2).anyMatch(n -> n > 2));
|
||||
}
|
||||
|
||||
@Template(DoubleStreamAllMatch.class)
|
||||
boolean testDoubleStreamAllMatch() {
|
||||
return DoubleStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(DoubleStreamAllMatchPredicate.class)
|
||||
boolean testDoubleStreamAllMatchPredicate() {
|
||||
DoublePredicate pred = i -> i > 0;
|
||||
return DoubleStream.of(1).allMatch(pred);
|
||||
}
|
||||
|
||||
boolean testDoubleStreamAllMatch2() {
|
||||
return DoubleStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,26 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.BoundType;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.DoubleNegation;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.EqualsPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.IndirectDoubleNegation;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.Negation;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.PrimitiveOrReferenceEquality;
|
||||
|
||||
@TemplateCollection(EqualityTemplates.class)
|
||||
final class EqualityTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Objects.class);
|
||||
}
|
||||
|
||||
@Template(PrimitiveOrReferenceEquality.class)
|
||||
ImmutableSet<Boolean> testPrimitiveOrReferenceEquality() {
|
||||
return ImmutableSet.of(
|
||||
RoundingMode.UP.equals(RoundingMode.DOWN),
|
||||
@@ -20,16 +29,19 @@ final class EqualityTemplatesTest implements RefasterTemplateTestCase {
|
||||
!Objects.equals(RoundingMode.UP, RoundingMode.DOWN));
|
||||
}
|
||||
|
||||
@Template(EqualsPredicate.class)
|
||||
boolean testEqualsPredicate() {
|
||||
// XXX: When boxing is involved this rule seems to break. Example:
|
||||
// Stream.of(1).anyMatch(e -> Integer.MIN_VALUE.equals(e));
|
||||
return Stream.of("foo").anyMatch(s -> "bar".equals(s));
|
||||
}
|
||||
|
||||
@Template(DoubleNegation.class)
|
||||
boolean testDoubleNegation() {
|
||||
return !!true;
|
||||
}
|
||||
|
||||
@Template(Negation.class)
|
||||
ImmutableSet<Boolean> testNegation() {
|
||||
return ImmutableSet.of(
|
||||
true ? !false : false,
|
||||
@@ -43,6 +55,7 @@ final class EqualityTemplatesTest implements RefasterTemplateTestCase {
|
||||
!(BoundType.OPEN == BoundType.CLOSED));
|
||||
}
|
||||
|
||||
@Template(IndirectDoubleNegation.class)
|
||||
ImmutableSet<Boolean> testIndirectDoubleNegation() {
|
||||
return ImmutableSet.of(
|
||||
true ? false : !false,
|
||||
@@ -1,17 +1,26 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.BoundType;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.DoubleNegation;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.EqualsPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.IndirectDoubleNegation;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.Negation;
|
||||
import tech.picnic.errorprone.refastertemplates.EqualityTemplates.PrimitiveOrReferenceEquality;
|
||||
|
||||
@TemplateCollection(EqualityTemplates.class)
|
||||
final class EqualityTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Objects.class);
|
||||
}
|
||||
|
||||
@Template(PrimitiveOrReferenceEquality.class)
|
||||
ImmutableSet<Boolean> testPrimitiveOrReferenceEquality() {
|
||||
return ImmutableSet.of(
|
||||
RoundingMode.UP == RoundingMode.DOWN,
|
||||
@@ -20,16 +29,19 @@ final class EqualityTemplatesTest implements RefasterTemplateTestCase {
|
||||
RoundingMode.UP != RoundingMode.DOWN);
|
||||
}
|
||||
|
||||
@Template(EqualsPredicate.class)
|
||||
boolean testEqualsPredicate() {
|
||||
// XXX: When boxing is involved this rule seems to break. Example:
|
||||
// Stream.of(1).anyMatch(e -> Integer.MIN_VALUE.equals(e));
|
||||
return Stream.of("foo").anyMatch("bar"::equals);
|
||||
}
|
||||
|
||||
@Template(DoubleNegation.class)
|
||||
boolean testDoubleNegation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Template(Negation.class)
|
||||
ImmutableSet<Boolean> testNegation() {
|
||||
return ImmutableSet.of(
|
||||
true != false,
|
||||
@@ -43,6 +55,7 @@ final class EqualityTemplatesTest implements RefasterTemplateTestCase {
|
||||
BoundType.OPEN != BoundType.CLOSED);
|
||||
}
|
||||
|
||||
@Template(IndirectDoubleNegation.class)
|
||||
ImmutableSet<Boolean> testIndirectDoubleNegation() {
|
||||
return ImmutableSet.of(
|
||||
true == false,
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableListMultimap.flatteningToImmutableListMultimap;
|
||||
import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
|
||||
@@ -16,7 +16,20 @@ import com.google.common.collect.Streams;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.EmptyImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.EntryToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapCopyOfImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapCopyOfMultimapsTransformValues;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapCopyOfMultimapsTransformValuesTransformation;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.IndexIterableToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.IterableToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.PairToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.StreamOfMapEntriesToImmutableListMultimap;
|
||||
|
||||
@TemplateCollection(ImmutableListMultimapTemplates.class)
|
||||
final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -24,6 +37,7 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
Streams.class, flatteningToImmutableListMultimap(null, null), identity());
|
||||
}
|
||||
|
||||
@Template(ImmutableListMultimapBuilder.class)
|
||||
ImmutableSet<ImmutableMultimap.Builder<String, Integer>> testImmutableListMultimapBuilder() {
|
||||
return ImmutableSet.of(
|
||||
new ImmutableListMultimap.Builder<>(),
|
||||
@@ -31,17 +45,20 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
ImmutableMultimap.builder());
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableListMultimap.class)
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testEmptyImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.<String, Integer>builder().build(), ImmutableMultimap.of());
|
||||
}
|
||||
|
||||
@Template(PairToImmutableListMultimap.class)
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testPairToImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.<String, Integer>builder().put("foo", 1).build(),
|
||||
ImmutableMultimap.of("bar", 2));
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableListMultimap.class)
|
||||
ImmutableList<ImmutableMultimap<String, Integer>> testEntryToImmutableListMultimap() {
|
||||
return ImmutableList.of(
|
||||
ImmutableListMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
|
||||
@@ -49,6 +66,7 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableListMultimap.class)
|
||||
ImmutableList<ImmutableMultimap<String, Integer>> testIterableToImmutableListMultimap() {
|
||||
return ImmutableList.of(
|
||||
ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1).entries()),
|
||||
@@ -67,12 +85,14 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
ImmutableMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
|
||||
}
|
||||
|
||||
@Template(StreamOfMapEntriesToImmutableListMultimap.class)
|
||||
ImmutableListMultimap<Integer, String> testStreamOfMapEntriesToImmutableListMultimap() {
|
||||
return Stream.of(1, 2, 3)
|
||||
.map(n -> Map.entry(n, n.toString()))
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
|
||||
@Template(IndexIterableToImmutableListMultimap.class)
|
||||
ImmutableSet<ImmutableListMultimap<Integer, Integer>> testIndexIterableToImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.of(1).stream().collect(toImmutableListMultimap(n -> n * 2, identity())),
|
||||
@@ -82,13 +102,15 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
.collect(toImmutableListMultimap(n -> n.intValue(), identity())));
|
||||
}
|
||||
|
||||
ImmutableListMultimap<String, Integer> testTransformMultimapValuesToImmutableListMultimap() {
|
||||
@Template(ImmutableListMultimapCopyOfMultimapsTransformValues.class)
|
||||
ImmutableListMultimap<String, Integer> testImmutableListMultimapCopyOfMultimapsTransformValues() {
|
||||
return ImmutableListMultimap.of("foo", 1L).entries().stream()
|
||||
.collect(toImmutableListMultimap(Map.Entry::getKey, e -> Math.toIntExact(e.getValue())));
|
||||
}
|
||||
|
||||
@Template(ImmutableListMultimapCopyOfMultimapsTransformValuesTransformation.class)
|
||||
ImmutableSet<ImmutableListMultimap<String, Integer>>
|
||||
testTransformMultimapValuesToImmutableListMultimap2() {
|
||||
testImmutableListMultimapCopyOfMultimapsTransformValuesTransformation() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.of("foo", 1L).asMap().entrySet().stream()
|
||||
.collect(
|
||||
@@ -114,6 +136,7 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))));
|
||||
}
|
||||
|
||||
@Template(ImmutableListMultimapCopyOfImmutableListMultimap.class)
|
||||
ImmutableListMultimap<String, Integer> testImmutableListMultimapCopyOfImmutableListMultimap() {
|
||||
return ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableListMultimap.flatteningToImmutableListMultimap;
|
||||
import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
|
||||
@@ -16,7 +16,20 @@ import com.google.common.collect.Streams;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.EmptyImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.EntryToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapCopyOfImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapCopyOfMultimapsTransformValues;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.ImmutableListMultimapCopyOfMultimapsTransformValuesTransformation;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.IndexIterableToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.IterableToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.PairToImmutableListMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListMultimapTemplates.StreamOfMapEntriesToImmutableListMultimap;
|
||||
|
||||
@TemplateCollection(ImmutableListMultimapTemplates.class)
|
||||
final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -24,6 +37,7 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
Streams.class, flatteningToImmutableListMultimap(null, null), identity());
|
||||
}
|
||||
|
||||
@Template(ImmutableListMultimapBuilder.class)
|
||||
ImmutableSet<ImmutableMultimap.Builder<String, Integer>> testImmutableListMultimapBuilder() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.builder(),
|
||||
@@ -31,20 +45,24 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
ImmutableListMultimap.builder());
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableListMultimap.class)
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testEmptyImmutableListMultimap() {
|
||||
return ImmutableSet.of(ImmutableListMultimap.of(), ImmutableListMultimap.of());
|
||||
}
|
||||
|
||||
@Template(PairToImmutableListMultimap.class)
|
||||
ImmutableSet<ImmutableMultimap<String, Integer>> testPairToImmutableListMultimap() {
|
||||
return ImmutableSet.of(ImmutableListMultimap.of("foo", 1), ImmutableListMultimap.of("bar", 2));
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableListMultimap.class)
|
||||
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()));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableListMultimap.class)
|
||||
ImmutableList<ImmutableMultimap<String, Integer>> testIterableToImmutableListMultimap() {
|
||||
return ImmutableList.of(
|
||||
ImmutableListMultimap.copyOf(ImmutableListMultimap.of("foo", 1)),
|
||||
@@ -57,10 +75,12 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
ImmutableListMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
|
||||
}
|
||||
|
||||
@Template(StreamOfMapEntriesToImmutableListMultimap.class)
|
||||
ImmutableListMultimap<Integer, String> testStreamOfMapEntriesToImmutableListMultimap() {
|
||||
return Stream.of(1, 2, 3).collect(toImmutableListMultimap(n -> n, n -> n.toString()));
|
||||
}
|
||||
|
||||
@Template(IndexIterableToImmutableListMultimap.class)
|
||||
ImmutableSet<ImmutableListMultimap<Integer, Integer>> testIndexIterableToImmutableListMultimap() {
|
||||
return ImmutableSet.of(
|
||||
Multimaps.index(ImmutableList.of(1), n -> n * 2),
|
||||
@@ -68,13 +88,15 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
Multimaps.index(ImmutableList.of(3).iterator(), n -> n.intValue()));
|
||||
}
|
||||
|
||||
ImmutableListMultimap<String, Integer> testTransformMultimapValuesToImmutableListMultimap() {
|
||||
@Template(ImmutableListMultimapCopyOfMultimapsTransformValues.class)
|
||||
ImmutableListMultimap<String, Integer> testImmutableListMultimapCopyOfMultimapsTransformValues() {
|
||||
return ImmutableListMultimap.copyOf(
|
||||
Multimaps.transformValues(ImmutableListMultimap.of("foo", 1L), v -> Math.toIntExact(v)));
|
||||
}
|
||||
|
||||
@Template(ImmutableListMultimapCopyOfMultimapsTransformValuesTransformation.class)
|
||||
ImmutableSet<ImmutableListMultimap<String, Integer>>
|
||||
testTransformMultimapValuesToImmutableListMultimap2() {
|
||||
testImmutableListMultimapCopyOfMultimapsTransformValuesTransformation() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableListMultimap.copyOf(
|
||||
Multimaps.transformValues(ImmutableSetMultimap.of("foo", 1L), Math::toIntExact)),
|
||||
@@ -90,6 +112,7 @@ final class ImmutableListMultimapTemplatesTest implements RefasterTemplateTestCa
|
||||
Multimaps.transformValues(TreeMultimap.<String, Long>create(), Math::toIntExact)));
|
||||
}
|
||||
|
||||
@Template(ImmutableListMultimapCopyOfImmutableListMultimap.class)
|
||||
ImmutableListMultimap<String, Integer> testImmutableListMultimapCopyOfImmutableListMultimap() {
|
||||
return ImmutableListMultimap.of("foo", 1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -13,7 +13,18 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.EmptyImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.ImmutableListBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.ImmutableListSortedCopyOf;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.ImmutableListSortedCopyOfWithCustomComparator;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.IterableToImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.SingletonImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.StreamToDistinctImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.StreamToImmutableList;
|
||||
|
||||
@TemplateCollection(ImmutableListTemplates.class)
|
||||
final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -27,20 +38,24 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableListBuilder.class)
|
||||
ImmutableList.Builder<String> testImmutableListBuilder() {
|
||||
return new ImmutableList.Builder<>();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableList.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testEmptyImmutableList() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.<Integer>builder().build(),
|
||||
Stream.<Integer>empty().collect(toImmutableList()));
|
||||
}
|
||||
|
||||
@Template(SingletonImmutableList.class)
|
||||
List<String> testSingletonImmutableList() {
|
||||
return Collections.singletonList("foo");
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableList.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testIterableToImmutableList() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.of(1).stream().collect(toImmutableList()),
|
||||
@@ -53,12 +68,14 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
Arrays.stream(new Integer[] {8}).collect(toImmutableList()));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableList.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testStreamToImmutableList() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.copyOf(Stream.of(1).iterator()),
|
||||
Stream.of(2).collect(collectingAndThen(toList(), ImmutableList::copyOf)));
|
||||
}
|
||||
|
||||
@Template(ImmutableListSortedCopyOf.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testImmutableListSortedCopyOf() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.sortedCopyOf(naturalOrder(), ImmutableSet.of(1)),
|
||||
@@ -66,6 +83,7 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
Streams.stream(ImmutableSet.of(3)::iterator).sorted().collect(toImmutableList()));
|
||||
}
|
||||
|
||||
@Template(ImmutableListSortedCopyOfWithCustomComparator.class)
|
||||
ImmutableSet<ImmutableList<String>> testImmutableListSortedCopyOfWithCustomComparator() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of("foo").stream()
|
||||
@@ -76,6 +94,7 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
.collect(toImmutableList()));
|
||||
}
|
||||
|
||||
@Template(StreamToDistinctImmutableList.class)
|
||||
ImmutableList<Integer> testStreamToDistinctImmutableList() {
|
||||
return Stream.of(1).distinct().collect(toImmutableList());
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
@@ -14,7 +14,18 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.EmptyImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.ImmutableListBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.ImmutableListSortedCopyOf;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.ImmutableListSortedCopyOfWithCustomComparator;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.IterableToImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.SingletonImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.StreamToDistinctImmutableList;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableListTemplates.StreamToImmutableList;
|
||||
|
||||
@TemplateCollection(ImmutableListTemplates.class)
|
||||
final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -28,18 +39,22 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableListBuilder.class)
|
||||
ImmutableList.Builder<String> testImmutableListBuilder() {
|
||||
return ImmutableList.builder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableList.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testEmptyImmutableList() {
|
||||
return ImmutableSet.of(ImmutableList.of(), ImmutableList.of());
|
||||
}
|
||||
|
||||
@Template(SingletonImmutableList.class)
|
||||
List<String> testSingletonImmutableList() {
|
||||
return ImmutableList.of("foo");
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableList.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testIterableToImmutableList() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.copyOf(ImmutableList.of(1)),
|
||||
@@ -52,11 +67,13 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableList.copyOf(new Integer[] {8}));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableList.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testStreamToImmutableList() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(1).collect(toImmutableList()), Stream.of(2).collect(toImmutableList()));
|
||||
}
|
||||
|
||||
@Template(ImmutableListSortedCopyOf.class)
|
||||
ImmutableSet<ImmutableList<Integer>> testImmutableListSortedCopyOf() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.sortedCopyOf(ImmutableSet.of(1)),
|
||||
@@ -64,6 +81,7 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableList.sortedCopyOf(ImmutableSet.of(3)::iterator));
|
||||
}
|
||||
|
||||
@Template(ImmutableListSortedCopyOfWithCustomComparator.class)
|
||||
ImmutableSet<ImmutableList<String>> testImmutableListSortedCopyOfWithCustomComparator() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.sortedCopyOf(Comparator.comparing(String::length), ImmutableSet.of("foo")),
|
||||
@@ -71,6 +89,7 @@ final class ImmutableListTemplatesTest implements RefasterTemplateTestCase {
|
||||
Comparator.comparing(String::isEmpty), ImmutableSet.of("bar")::iterator));
|
||||
}
|
||||
|
||||
@Template(StreamToDistinctImmutableList.class)
|
||||
ImmutableList<Integer> testStreamToDistinctImmutableList() {
|
||||
return Stream.of(1).collect(toImmutableSet()).asList();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static java.util.function.Function.identity;
|
||||
@@ -12,27 +12,44 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.EmptyImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.EntryIterableToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.EntryToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.ImmutableMapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.ImmutableMapCopyOfImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.IndexIterableToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.IterableToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.PairToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.StreamOfMapEntriesToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.TransformMapValuesToImmutableMap;
|
||||
|
||||
@TemplateCollection(ImmutableMapTemplates.class)
|
||||
final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Collections.class, Streams.class, identity());
|
||||
}
|
||||
|
||||
@Template(ImmutableMapBuilder.class)
|
||||
ImmutableMap.Builder<String, Integer> testImmutableMapBuilder() {
|
||||
return new ImmutableMap.Builder<>();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableMap.class)
|
||||
ImmutableMap<String, Integer> testEmptyImmutableMap() {
|
||||
return ImmutableMap.<String, Integer>builder().build();
|
||||
}
|
||||
|
||||
@Template(PairToImmutableMap.class)
|
||||
ImmutableSet<Map<String, Integer>> testPairToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.<String, Integer>builder().put("foo", 1).build(),
|
||||
Collections.singletonMap("bar", 2));
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<String, Integer>> testEntryToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
|
||||
@@ -40,6 +57,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
.collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<Integer, Integer>> testIterableToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.of(1).stream().collect(toImmutableMap(identity(), n -> n * 2)),
|
||||
@@ -50,6 +68,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableMap.copyOf(Maps.asMap(ImmutableSet.of(4), Integer::valueOf)));
|
||||
}
|
||||
|
||||
@Template(EntryIterableToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<String, Integer>> testEntryIterableToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.copyOf(ImmutableMap.of("foo", 1).entrySet()),
|
||||
@@ -63,12 +82,14 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
.collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
@Template(StreamOfMapEntriesToImmutableMap.class)
|
||||
ImmutableMap<Integer, String> testStreamOfMapEntriesToImmutableMap() {
|
||||
return Stream.of(1, 2, 3)
|
||||
.map(n -> Map.entry(n, n.toString()))
|
||||
.collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
|
||||
@Template(IndexIterableToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<Integer, Integer>> testIndexIterableToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.of(1).stream().collect(toImmutableMap(n -> n * 2, identity())),
|
||||
@@ -78,6 +99,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
.collect(toImmutableMap(n -> n.intValue(), identity())));
|
||||
}
|
||||
|
||||
@Template(TransformMapValuesToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<String, Integer>> testTransformMapValuesToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.of("foo", 1L).entrySet().stream()
|
||||
@@ -87,6 +109,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
k -> Math.toIntExact(ImmutableMap.of("bar", 2L).get(k))));
|
||||
}
|
||||
|
||||
@Template(ImmutableMapCopyOfImmutableMap.class)
|
||||
ImmutableMap<String, Integer> testImmutableMapCopyOfImmutableMap() {
|
||||
return ImmutableMap.copyOf(ImmutableMap.of("foo", 1));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static java.util.function.Function.identity;
|
||||
@@ -12,31 +12,49 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.EmptyImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.EntryIterableToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.EntryToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.ImmutableMapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.ImmutableMapCopyOfImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.IndexIterableToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.IterableToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.PairToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.StreamOfMapEntriesToImmutableMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMapTemplates.TransformMapValuesToImmutableMap;
|
||||
|
||||
@TemplateCollection(ImmutableMapTemplates.class)
|
||||
final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Collections.class, Streams.class, identity());
|
||||
}
|
||||
|
||||
@Template(ImmutableMapBuilder.class)
|
||||
ImmutableMap.Builder<String, Integer> testImmutableMapBuilder() {
|
||||
return ImmutableMap.builder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableMap.class)
|
||||
ImmutableMap<String, Integer> testEmptyImmutableMap() {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
|
||||
@Template(PairToImmutableMap.class)
|
||||
ImmutableSet<Map<String, Integer>> testPairToImmutableMap() {
|
||||
return ImmutableSet.of(ImmutableMap.of("foo", 1), ImmutableMap.of("bar", 2));
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<String, Integer>> testEntryToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
|
||||
ImmutableMap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<Integer, Integer>> testIterableToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
Maps.toMap(ImmutableList.of(1), n -> n * 2),
|
||||
@@ -45,6 +63,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
Maps.toMap(ImmutableSet.of(4), Integer::valueOf));
|
||||
}
|
||||
|
||||
@Template(EntryIterableToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<String, Integer>> testEntryIterableToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.copyOf(ImmutableMap.of("foo", 1)),
|
||||
@@ -54,10 +73,12 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableMap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
|
||||
}
|
||||
|
||||
@Template(StreamOfMapEntriesToImmutableMap.class)
|
||||
ImmutableMap<Integer, String> testStreamOfMapEntriesToImmutableMap() {
|
||||
return Stream.of(1, 2, 3).collect(toImmutableMap(n -> n, n -> n.toString()));
|
||||
}
|
||||
|
||||
@Template(IndexIterableToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<Integer, Integer>> testIndexIterableToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
Maps.uniqueIndex(ImmutableList.of(1), n -> n * 2),
|
||||
@@ -65,6 +86,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
Maps.uniqueIndex(ImmutableList.of(3).iterator(), n -> n.intValue()));
|
||||
}
|
||||
|
||||
@Template(TransformMapValuesToImmutableMap.class)
|
||||
ImmutableSet<ImmutableMap<String, Integer>> testTransformMapValuesToImmutableMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMap.copyOf(
|
||||
@@ -73,6 +95,7 @@ final class ImmutableMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
Maps.transformValues(ImmutableMap.of("bar", 2L), v -> Math.toIntExact(v))));
|
||||
}
|
||||
|
||||
@Template(ImmutableMapCopyOfImmutableMap.class)
|
||||
ImmutableMap<String, Integer> testImmutableMapCopyOfImmutableMap() {
|
||||
return ImmutableMap.of("foo", 1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableMultiset.toImmutableMultiset;
|
||||
import static java.util.stream.Collectors.collectingAndThen;
|
||||
@@ -10,23 +10,34 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.EmptyImmutableMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.ImmutableMultisetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.ImmutableMultisetCopyOfImmutableMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.IterableToImmutableMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.StreamToImmutableMultiset;
|
||||
|
||||
@TemplateCollection(ImmutableMultisetTemplates.class)
|
||||
final class ImmutableMultisetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Arrays.class, Streams.class, collectingAndThen(null, null), toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableMultisetBuilder.class)
|
||||
ImmutableMultiset.Builder<String> testImmutableMultisetBuilder() {
|
||||
return new ImmutableMultiset.Builder<>();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableMultiset.class)
|
||||
ImmutableMultiset<ImmutableMultiset<Integer>> testEmptyImmutableMultiset() {
|
||||
return ImmutableMultiset.of(
|
||||
ImmutableMultiset.<Integer>builder().build(),
|
||||
Stream.<Integer>empty().collect(toImmutableMultiset()));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableMultiset.class)
|
||||
ImmutableMultiset<ImmutableMultiset<Integer>> testIterableToImmutableMultiset() {
|
||||
return ImmutableMultiset.of(
|
||||
ImmutableList.of(1).stream().collect(toImmutableMultiset()),
|
||||
@@ -39,12 +50,14 @@ final class ImmutableMultisetTemplatesTest implements RefasterTemplateTestCase {
|
||||
Arrays.stream(new Integer[] {8}).collect(toImmutableMultiset()));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableMultiset.class)
|
||||
ImmutableSet<ImmutableMultiset<Integer>> testStreamToImmutableMultiset() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableMultiset.copyOf(Stream.of(1).iterator()),
|
||||
Stream.of(2).collect(collectingAndThen(toList(), ImmutableMultiset::copyOf)));
|
||||
}
|
||||
|
||||
@Template(ImmutableMultisetCopyOfImmutableMultiset.class)
|
||||
ImmutableMultiset<Integer> testImmutableMultisetCopyOfImmutableMultiset() {
|
||||
return ImmutableMultiset.copyOf(ImmutableMultiset.of(1, 2));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableMultiset.toImmutableMultiset;
|
||||
import static java.util.stream.Collectors.collectingAndThen;
|
||||
@@ -10,21 +10,32 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.EmptyImmutableMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.ImmutableMultisetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.ImmutableMultisetCopyOfImmutableMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.IterableToImmutableMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableMultisetTemplates.StreamToImmutableMultiset;
|
||||
|
||||
@TemplateCollection(ImmutableMultisetTemplates.class)
|
||||
final class ImmutableMultisetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Arrays.class, Streams.class, collectingAndThen(null, null), toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableMultisetBuilder.class)
|
||||
ImmutableMultiset.Builder<String> testImmutableMultisetBuilder() {
|
||||
return ImmutableMultiset.builder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableMultiset.class)
|
||||
ImmutableMultiset<ImmutableMultiset<Integer>> testEmptyImmutableMultiset() {
|
||||
return ImmutableMultiset.of(ImmutableMultiset.of(), ImmutableMultiset.of());
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableMultiset.class)
|
||||
ImmutableMultiset<ImmutableMultiset<Integer>> testIterableToImmutableMultiset() {
|
||||
return ImmutableMultiset.of(
|
||||
ImmutableMultiset.copyOf(ImmutableList.of(1)),
|
||||
@@ -37,11 +48,13 @@ final class ImmutableMultisetTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableMultiset.copyOf(new Integer[] {8}));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableMultiset.class)
|
||||
ImmutableSet<ImmutableMultiset<Integer>> testStreamToImmutableMultiset() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(1).collect(toImmutableMultiset()), Stream.of(2).collect(toImmutableMultiset()));
|
||||
}
|
||||
|
||||
@Template(ImmutableMultisetCopyOfImmutableMultiset.class)
|
||||
ImmutableMultiset<Integer> testImmutableMultisetCopyOfImmutableMultiset() {
|
||||
return ImmutableMultiset.of(1, 2);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSetMultimap.flatteningToImmutableSetMultimap;
|
||||
import static com.google.common.collect.ImmutableSetMultimap.toImmutableSetMultimap;
|
||||
@@ -13,25 +13,41 @@ import com.google.common.collect.Streams;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.EmptyImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.EntryToImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapCopyOfImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapCopyOfMultimapsTransformValues;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.IterableToImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.PairToImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.StreamCollectToImmutableSetMultimap;
|
||||
|
||||
@TemplateCollection(ImmutableSetMultimapTemplates.class)
|
||||
final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class, flatteningToImmutableSetMultimap(null, null));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetMultimapBuilder.class)
|
||||
ImmutableSetMultimap.Builder<String, Integer> testImmutableSetMultimapBuilder() {
|
||||
return new ImmutableSetMultimap.Builder<>();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<String, Integer> testEmptyImmutableSetMultimap() {
|
||||
return ImmutableSetMultimap.<String, Integer>builder().build();
|
||||
}
|
||||
|
||||
@Template(PairToImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<String, Integer> testPairToImmutableSetMultimap() {
|
||||
return ImmutableSetMultimap.<String, Integer>builder().put("foo", 1).build();
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableSetMultimap.class)
|
||||
ImmutableSet<ImmutableSetMultimap<String, Integer>> testEntryToImmutableSetMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.<String, Integer>builder().put(Map.entry("foo", 1)).build(),
|
||||
@@ -39,6 +55,7 @@ final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCas
|
||||
.collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSetMultimap.class)
|
||||
ImmutableSet<ImmutableSetMultimap<String, Integer>> testIterableToImmutableSetMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1).entries()),
|
||||
@@ -54,19 +71,22 @@ final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCas
|
||||
.collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
ImmutableSetMultimap<Integer, String> testStreamOfMapEntriesToImmutableSetMultimap() {
|
||||
@Template(StreamCollectToImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<Integer, String> testStreamCollectToImmutableSetMultimap() {
|
||||
return Stream.of(1, 2, 3)
|
||||
.map(n -> Map.entry(n, n.toString()))
|
||||
.collect(toImmutableSetMultimap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
|
||||
ImmutableSetMultimap<String, Integer> testTransformMultimapValuesToImmutableSetMultimap() {
|
||||
@Template(ImmutableSetMultimapCopyOfMultimapsTransformValues.class)
|
||||
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapCopyOfMultimapsTransformValues() {
|
||||
return ImmutableSetMultimap.of("foo", 1L).entries().stream()
|
||||
.collect(toImmutableSetMultimap(Map.Entry::getKey, e -> Math.toIntExact(e.getValue())));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation.class)
|
||||
ImmutableSet<ImmutableSetMultimap<String, Integer>>
|
||||
testTransformMultimapValuesToImmutableSetMultimap2() {
|
||||
testImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.of("foo", 1L).asMap().entrySet().stream()
|
||||
.collect(
|
||||
@@ -92,6 +112,7 @@ final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCas
|
||||
Map.Entry::getKey, e -> e.getValue().stream().map(Math::toIntExact))));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetMultimapCopyOfImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapCopyOfImmutableSetMultimap() {
|
||||
return ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSetMultimap.flatteningToImmutableSetMultimap;
|
||||
import static com.google.common.collect.ImmutableSetMultimap.toImmutableSetMultimap;
|
||||
@@ -13,31 +13,48 @@ import com.google.common.collect.Streams;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.EmptyImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.EntryToImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapCopyOfImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapCopyOfMultimapsTransformValues;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.ImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.IterableToImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.PairToImmutableSetMultimap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetMultimapTemplates.StreamCollectToImmutableSetMultimap;
|
||||
|
||||
@TemplateCollection(ImmutableSetMultimapTemplates.class)
|
||||
final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class, flatteningToImmutableSetMultimap(null, null));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetMultimapBuilder.class)
|
||||
ImmutableSetMultimap.Builder<String, Integer> testImmutableSetMultimapBuilder() {
|
||||
return ImmutableSetMultimap.builder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<String, Integer> testEmptyImmutableSetMultimap() {
|
||||
return ImmutableSetMultimap.of();
|
||||
}
|
||||
|
||||
@Template(PairToImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<String, Integer> testPairToImmutableSetMultimap() {
|
||||
return ImmutableSetMultimap.of("foo", 1);
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableSetMultimap.class)
|
||||
ImmutableSet<ImmutableSetMultimap<String, Integer>> testEntryToImmutableSetMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
|
||||
ImmutableSetMultimap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSetMultimap.class)
|
||||
ImmutableSet<ImmutableSetMultimap<String, Integer>> testIterableToImmutableSetMultimap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.copyOf(ImmutableSetMultimap.of("foo", 1)),
|
||||
@@ -47,17 +64,20 @@ final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCas
|
||||
ImmutableSetMultimap.copyOf(Iterables.cycle(Map.entry("foo", 1))));
|
||||
}
|
||||
|
||||
ImmutableSetMultimap<Integer, String> testStreamOfMapEntriesToImmutableSetMultimap() {
|
||||
@Template(StreamCollectToImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<Integer, String> testStreamCollectToImmutableSetMultimap() {
|
||||
return Stream.of(1, 2, 3).collect(toImmutableSetMultimap(n -> n, n -> n.toString()));
|
||||
}
|
||||
|
||||
ImmutableSetMultimap<String, Integer> testTransformMultimapValuesToImmutableSetMultimap() {
|
||||
@Template(ImmutableSetMultimapCopyOfMultimapsTransformValues.class)
|
||||
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapCopyOfMultimapsTransformValues() {
|
||||
return ImmutableSetMultimap.copyOf(
|
||||
Multimaps.transformValues(ImmutableSetMultimap.of("foo", 1L), v -> Math.toIntExact(v)));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation.class)
|
||||
ImmutableSet<ImmutableSetMultimap<String, Integer>>
|
||||
testTransformMultimapValuesToImmutableSetMultimap2() {
|
||||
testImmutableSetMultimapCopyOfMultimapsTransformValuesTransformation() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.copyOf(
|
||||
Multimaps.transformValues(ImmutableSetMultimap.of("foo", 1L), Math::toIntExact)),
|
||||
@@ -73,6 +93,7 @@ final class ImmutableSetMultimapTemplatesTest implements RefasterTemplateTestCas
|
||||
Multimaps.transformValues(TreeMultimap.<String, Long>create(), Math::toIntExact)));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetMultimapCopyOfImmutableSetMultimap.class)
|
||||
ImmutableSetMultimap<String, Integer> testImmutableSetMultimapCopyOfImmutableSetMultimap() {
|
||||
return ImmutableSetMultimap.of("foo", 1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static java.util.stream.Collectors.collectingAndThen;
|
||||
@@ -13,7 +13,17 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.EmptyImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.ImmutableSetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.ImmutableSetCopyOfImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.ImmutableSetCopyOfSetView;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.IterableToImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.SingletonImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.StreamToImmutableSet;
|
||||
|
||||
@TemplateCollection(ImmutableSetTemplates.class)
|
||||
final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -26,19 +36,23 @@ final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
toSet());
|
||||
}
|
||||
|
||||
@Template(ImmutableSetBuilder.class)
|
||||
ImmutableSet.Builder<String> testImmutableSetBuilder() {
|
||||
return new ImmutableSet.Builder<>();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSet.class)
|
||||
ImmutableSet<ImmutableSet<Integer>> testEmptyImmutableSet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.<Integer>builder().build(), Stream.<Integer>empty().collect(toImmutableSet()));
|
||||
}
|
||||
|
||||
@Template(SingletonImmutableSet.class)
|
||||
Set<String> testSingletonImmutableSet() {
|
||||
return Collections.singleton("foo");
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSet.class)
|
||||
ImmutableSet<ImmutableSet<Integer>> testIterableToImmutableSet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableList.of(1).stream().collect(toImmutableSet()),
|
||||
@@ -51,6 +65,7 @@ final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
Arrays.stream(new Integer[] {8}).collect(toImmutableSet()));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableSet.class)
|
||||
ImmutableSet<ImmutableSet<Integer>> testStreamToImmutableSet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.copyOf(Stream.of(1).iterator()),
|
||||
@@ -59,10 +74,12 @@ final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
Stream.of(4).collect(collectingAndThen(toSet(), ImmutableSet::copyOf)));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetCopyOfImmutableSet.class)
|
||||
ImmutableSet<Integer> testImmutableSetCopyOfImmutableSet() {
|
||||
return ImmutableSet.copyOf(ImmutableSet.of(1, 2));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetCopyOfSetView.class)
|
||||
ImmutableSet<Integer> testImmutableSetCopyOfSetView() {
|
||||
return ImmutableSet.copyOf(Sets.difference(ImmutableSet.of(1), ImmutableSet.of(2)));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static java.util.stream.Collectors.collectingAndThen;
|
||||
@@ -13,7 +13,17 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.EmptyImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.ImmutableSetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.ImmutableSetCopyOfImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.ImmutableSetCopyOfSetView;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.IterableToImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.SingletonImmutableSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSetTemplates.StreamToImmutableSet;
|
||||
|
||||
@TemplateCollection(ImmutableSetTemplates.class)
|
||||
final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -26,18 +36,22 @@ final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
toSet());
|
||||
}
|
||||
|
||||
@Template(ImmutableSetBuilder.class)
|
||||
ImmutableSet.Builder<String> testImmutableSetBuilder() {
|
||||
return ImmutableSet.builder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSet.class)
|
||||
ImmutableSet<ImmutableSet<Integer>> testEmptyImmutableSet() {
|
||||
return ImmutableSet.of(ImmutableSet.of(), ImmutableSet.of());
|
||||
}
|
||||
|
||||
@Template(SingletonImmutableSet.class)
|
||||
Set<String> testSingletonImmutableSet() {
|
||||
return ImmutableSet.of("foo");
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSet.class)
|
||||
ImmutableSet<ImmutableSet<Integer>> testIterableToImmutableSet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.copyOf(ImmutableList.of(1)),
|
||||
@@ -50,6 +64,7 @@ final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
ImmutableSet.copyOf(new Integer[] {8}));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableSet.class)
|
||||
ImmutableSet<ImmutableSet<Integer>> testStreamToImmutableSet() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(1).collect(toImmutableSet()),
|
||||
@@ -58,10 +73,12 @@ final class ImmutableSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
Stream.of(4).collect(toImmutableSet()));
|
||||
}
|
||||
|
||||
@Template(ImmutableSetCopyOfImmutableSet.class)
|
||||
ImmutableSet<Integer> testImmutableSetCopyOfImmutableSet() {
|
||||
return ImmutableSet.of(1, 2);
|
||||
}
|
||||
|
||||
@Template(ImmutableSetCopyOfSetView.class)
|
||||
ImmutableSet<Integer> testImmutableSetCopyOfSetView() {
|
||||
return Sets.difference(ImmutableSet.of(1), ImmutableSet.of(2)).immutableCopy();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -10,7 +10,17 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.EmptyImmutableSortedMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.EntryToImmutableSortedMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.ImmutableSortedMapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.ImmutableSortedMapNaturalOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.ImmutableSortedMapReverseOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.IterableToImmutableSortedMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.PairToImmutableSortedMap;
|
||||
|
||||
@TemplateCollection(ImmutableSortedMapTemplates.class)
|
||||
final class ImmutableSortedMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -18,26 +28,32 @@ final class ImmutableSortedMapTemplatesTest implements RefasterTemplateTestCase
|
||||
Stream.class, Streams.class, naturalOrder(), toImmutableSortedMap(null, null, null));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMapBuilder.class)
|
||||
ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapBuilder() {
|
||||
return new ImmutableSortedMap.Builder<>(Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMapNaturalOrderBuilder.class)
|
||||
ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapNaturalOrderBuilder() {
|
||||
return ImmutableSortedMap.orderedBy(Comparator.<String>naturalOrder());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMapReverseOrderBuilder.class)
|
||||
ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapReverseOrderBuilder() {
|
||||
return ImmutableSortedMap.orderedBy(Comparator.<String>reverseOrder());
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSortedMap.class)
|
||||
ImmutableSortedMap<String, Integer> testEmptyImmutableSortedMap() {
|
||||
return ImmutableSortedMap.<String, Integer>naturalOrder().build();
|
||||
}
|
||||
|
||||
@Template(PairToImmutableSortedMap.class)
|
||||
ImmutableSortedMap<String, Integer> testPairToImmutableSortedMap() {
|
||||
return ImmutableSortedMap.<String, Integer>naturalOrder().put("foo", 1).build();
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableSortedMap.class)
|
||||
ImmutableSet<ImmutableSortedMap<String, Integer>> testEntryToImmutableSortedMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedMap.<String, Integer>naturalOrder().put(Map.entry("foo", 1)).build(),
|
||||
@@ -45,6 +61,7 @@ final class ImmutableSortedMapTemplatesTest implements RefasterTemplateTestCase
|
||||
.collect(toImmutableSortedMap(naturalOrder(), Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSortedMap.class)
|
||||
ImmutableSet<ImmutableSortedMap<String, Integer>> testIterableToImmutableSortedMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1), naturalOrder()),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -10,7 +10,17 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.EmptyImmutableSortedMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.EntryToImmutableSortedMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.ImmutableSortedMapBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.ImmutableSortedMapNaturalOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.ImmutableSortedMapReverseOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.IterableToImmutableSortedMap;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMapTemplates.PairToImmutableSortedMap;
|
||||
|
||||
@TemplateCollection(ImmutableSortedMapTemplates.class)
|
||||
final class ImmutableSortedMapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
@@ -18,32 +28,39 @@ final class ImmutableSortedMapTemplatesTest implements RefasterTemplateTestCase
|
||||
Stream.class, Streams.class, naturalOrder(), toImmutableSortedMap(null, null, null));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMapBuilder.class)
|
||||
ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapBuilder() {
|
||||
return ImmutableSortedMap.orderedBy(Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMapNaturalOrderBuilder.class)
|
||||
ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapNaturalOrderBuilder() {
|
||||
return ImmutableSortedMap.naturalOrder();
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMapReverseOrderBuilder.class)
|
||||
ImmutableSortedMap.Builder<String, Integer> testImmutableSortedMapReverseOrderBuilder() {
|
||||
return ImmutableSortedMap.reverseOrder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSortedMap.class)
|
||||
ImmutableSortedMap<String, Integer> testEmptyImmutableSortedMap() {
|
||||
return ImmutableSortedMap.of();
|
||||
}
|
||||
|
||||
@Template(PairToImmutableSortedMap.class)
|
||||
ImmutableSortedMap<String, Integer> testPairToImmutableSortedMap() {
|
||||
return ImmutableSortedMap.of("foo", 1);
|
||||
}
|
||||
|
||||
@Template(EntryToImmutableSortedMap.class)
|
||||
ImmutableSet<ImmutableSortedMap<String, Integer>> testEntryToImmutableSortedMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedMap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()),
|
||||
ImmutableSortedMap.of(Map.entry("foo", 1).getKey(), Map.entry("foo", 1).getValue()));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSortedMap.class)
|
||||
ImmutableSet<ImmutableSortedMap<String, Integer>> testIterableToImmutableSortedMap() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedMap.copyOf(ImmutableSortedMap.of("foo", 1)),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedMultiset.toImmutableSortedMultiset;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -13,31 +13,45 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.EmptyImmutableSortedMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.ImmutableSortedMultisetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.ImmutableSortedMultisetNaturalOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.ImmutableSortedMultisetReverseOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.IterableToImmutableSortedMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.StreamToImmutableSortedMultiset;
|
||||
|
||||
@TemplateCollection(ImmutableSortedMultisetTemplates.class)
|
||||
final class ImmutableSortedMultisetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Arrays.class, Streams.class, collectingAndThen(null, null), toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMultisetBuilder.class)
|
||||
ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetBuilder() {
|
||||
return new ImmutableSortedMultiset.Builder<>(Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMultisetNaturalOrderBuilder.class)
|
||||
ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetNaturalOrderBuilder() {
|
||||
return ImmutableSortedMultiset.orderedBy(Comparator.<String>naturalOrder());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMultisetReverseOrderBuilder.class)
|
||||
ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetReverseOrderBuilder() {
|
||||
return ImmutableSortedMultiset.orderedBy(Comparator.<String>reverseOrder());
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSortedMultiset.class)
|
||||
ImmutableMultiset<ImmutableSortedMultiset<Integer>> testEmptyImmutableSortedMultiset() {
|
||||
return ImmutableMultiset.of(
|
||||
ImmutableSortedMultiset.<Integer>naturalOrder().build(),
|
||||
Stream.<Integer>empty().collect(toImmutableSortedMultiset(naturalOrder())));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSortedMultiset.class)
|
||||
ImmutableMultiset<ImmutableSortedMultiset<Integer>> testIterableToImmutableSortedMultiset() {
|
||||
return ImmutableMultiset.of(
|
||||
ImmutableSortedMultiset.copyOf(naturalOrder(), ImmutableList.of(1)),
|
||||
@@ -58,6 +72,7 @@ final class ImmutableSortedMultisetTemplatesTest implements RefasterTemplateTest
|
||||
Arrays.stream(new Integer[] {10}).collect(toImmutableSortedMultiset(naturalOrder())));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableSortedMultiset.class)
|
||||
ImmutableSet<ImmutableSortedMultiset<Integer>> testStreamToImmutableSortedMultiset() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedMultiset.copyOf(Stream.of(1).iterator()),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedMultiset.toImmutableSortedMultiset;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -13,29 +13,43 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.EmptyImmutableSortedMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.ImmutableSortedMultisetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.ImmutableSortedMultisetNaturalOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.ImmutableSortedMultisetReverseOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.IterableToImmutableSortedMultiset;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedMultisetTemplates.StreamToImmutableSortedMultiset;
|
||||
|
||||
@TemplateCollection(ImmutableSortedMultisetTemplates.class)
|
||||
final class ImmutableSortedMultisetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Arrays.class, Streams.class, collectingAndThen(null, null), toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMultisetBuilder.class)
|
||||
ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetBuilder() {
|
||||
return ImmutableSortedMultiset.orderedBy(Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMultisetNaturalOrderBuilder.class)
|
||||
ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetNaturalOrderBuilder() {
|
||||
return ImmutableSortedMultiset.naturalOrder();
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedMultisetReverseOrderBuilder.class)
|
||||
ImmutableSortedMultiset.Builder<String> testImmutableSortedMultisetReverseOrderBuilder() {
|
||||
return ImmutableSortedMultiset.reverseOrder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSortedMultiset.class)
|
||||
ImmutableMultiset<ImmutableSortedMultiset<Integer>> testEmptyImmutableSortedMultiset() {
|
||||
return ImmutableMultiset.of(ImmutableSortedMultiset.of(), ImmutableSortedMultiset.of());
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSortedMultiset.class)
|
||||
ImmutableMultiset<ImmutableSortedMultiset<Integer>> testIterableToImmutableSortedMultiset() {
|
||||
return ImmutableMultiset.of(
|
||||
ImmutableSortedMultiset.copyOf(ImmutableList.of(1)),
|
||||
@@ -50,6 +64,7 @@ final class ImmutableSortedMultisetTemplatesTest implements RefasterTemplateTest
|
||||
ImmutableSortedMultiset.copyOf(new Integer[] {10}));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableSortedMultiset.class)
|
||||
ImmutableSet<ImmutableSortedMultiset<Integer>> testStreamToImmutableSortedMultiset() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(1).collect(toImmutableSortedMultiset(naturalOrder())),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -12,31 +12,45 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.EmptyImmutableSortedSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.ImmutableSortedSetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.ImmutableSortedSetNaturalOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.ImmutableSortedSetReverseOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.IterableToImmutableSortedSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.StreamToImmutableSortedSet;
|
||||
|
||||
@TemplateCollection(ImmutableSortedSetTemplates.class)
|
||||
final class ImmutableSortedSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Arrays.class, Streams.class, collectingAndThen(null, null), toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedSetBuilder.class)
|
||||
ImmutableSortedSet.Builder<String> testImmutableSortedSetBuilder() {
|
||||
return new ImmutableSortedSet.Builder<>(Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedSetNaturalOrderBuilder.class)
|
||||
ImmutableSortedSet.Builder<String> testImmutableSortedSetNaturalOrderBuilder() {
|
||||
return ImmutableSortedSet.orderedBy(Comparator.<String>naturalOrder());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedSetReverseOrderBuilder.class)
|
||||
ImmutableSortedSet.Builder<String> testImmutableSortedSetReverseOrderBuilder() {
|
||||
return ImmutableSortedSet.orderedBy(Comparator.<String>reverseOrder());
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSortedSet.class)
|
||||
ImmutableSet<ImmutableSortedSet<Integer>> testEmptyImmutableSortedSet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedSet.<Integer>naturalOrder().build(),
|
||||
Stream.<Integer>empty().collect(toImmutableSortedSet(naturalOrder())));
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSortedSet.class)
|
||||
ImmutableSet<ImmutableSortedSet<Integer>> testIterableToImmutableSortedSet() {
|
||||
// XXX: The first subexpression is not rewritten (`naturalOrder()` isn't dropped). WHY!?
|
||||
return ImmutableSet.of(
|
||||
@@ -53,6 +67,7 @@ final class ImmutableSortedSetTemplatesTest implements RefasterTemplateTestCase
|
||||
Arrays.stream(new Integer[] {10}).collect(toImmutableSortedSet(naturalOrder())));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableSortedSet.class)
|
||||
ImmutableSet<ImmutableSortedSet<Integer>> testStreamToImmutableSortedSet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSortedSet.copyOf(Stream.of(1).iterator()),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
@@ -12,29 +12,43 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.EmptyImmutableSortedSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.ImmutableSortedSetBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.ImmutableSortedSetNaturalOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.ImmutableSortedSetReverseOrderBuilder;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.IterableToImmutableSortedSet;
|
||||
import tech.picnic.errorprone.refastertemplates.ImmutableSortedSetTemplates.StreamToImmutableSortedSet;
|
||||
|
||||
@TemplateCollection(ImmutableSortedSetTemplates.class)
|
||||
final class ImmutableSortedSetTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Arrays.class, Streams.class, collectingAndThen(null, null), toList());
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedSetBuilder.class)
|
||||
ImmutableSortedSet.Builder<String> testImmutableSortedSetBuilder() {
|
||||
return ImmutableSortedSet.orderedBy(Comparator.comparingInt(String::length));
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedSetNaturalOrderBuilder.class)
|
||||
ImmutableSortedSet.Builder<String> testImmutableSortedSetNaturalOrderBuilder() {
|
||||
return ImmutableSortedSet.naturalOrder();
|
||||
}
|
||||
|
||||
@Template(ImmutableSortedSetReverseOrderBuilder.class)
|
||||
ImmutableSortedSet.Builder<String> testImmutableSortedSetReverseOrderBuilder() {
|
||||
return ImmutableSortedSet.reverseOrder();
|
||||
}
|
||||
|
||||
@Template(EmptyImmutableSortedSet.class)
|
||||
ImmutableSet<ImmutableSortedSet<Integer>> testEmptyImmutableSortedSet() {
|
||||
return ImmutableSet.of(ImmutableSortedSet.of(), ImmutableSortedSet.of());
|
||||
}
|
||||
|
||||
@Template(IterableToImmutableSortedSet.class)
|
||||
ImmutableSet<ImmutableSortedSet<Integer>> testIterableToImmutableSortedSet() {
|
||||
// XXX: The first subexpression is not rewritten (`naturalOrder()` isn't dropped). WHY!?
|
||||
return ImmutableSet.of(
|
||||
@@ -50,6 +64,7 @@ final class ImmutableSortedSetTemplatesTest implements RefasterTemplateTestCase
|
||||
ImmutableSortedSet.copyOf(new Integer[] {10}));
|
||||
}
|
||||
|
||||
@Template(StreamToImmutableSortedSet.class)
|
||||
ImmutableSet<ImmutableSortedSet<Integer>> testStreamToImmutableSortedSet() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(1).collect(toImmutableSortedSet(naturalOrder())),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -6,49 +6,79 @@ import java.util.OptionalInt;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.ConcatOneIntStream;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.ConcatTwoIntStreams;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FilterOuterIntStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FilterOuterStreamAfterFlatMapToInt;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FlatMapOuterIntStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FlatMapOuterStreamAfterFlatMapToInt;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamAllMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamAllMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamAnyMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamClosedOpenRange;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamMin;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamNoneMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamNoneMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.MapOuterIntStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.MapOuterStreamAfterFlatMapToInt;
|
||||
|
||||
@TemplateCollection(IntStreamTemplates.class)
|
||||
final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(IntStreamClosedOpenRange.class)
|
||||
IntStream testIntStreamClosedOpenRange() {
|
||||
return IntStream.rangeClosed(0, 42 - 1);
|
||||
}
|
||||
|
||||
@Template(ConcatOneIntStream.class)
|
||||
IntStream testConcatOneIntStream() {
|
||||
return Streams.concat(IntStream.of(1));
|
||||
}
|
||||
|
||||
@Template(ConcatTwoIntStreams.class)
|
||||
IntStream testConcatTwoIntStreams() {
|
||||
return Streams.concat(IntStream.of(1), IntStream.of(2));
|
||||
}
|
||||
|
||||
@Template(FilterOuterIntStreamAfterFlatMap.class)
|
||||
IntStream testFilterOuterIntStreamAfterFlatMap() {
|
||||
return IntStream.of(1).flatMap(v -> IntStream.of(v * v).filter(n -> n > 1));
|
||||
}
|
||||
|
||||
@Template(FilterOuterStreamAfterFlatMapToInt.class)
|
||||
IntStream testFilterOuterStreamAfterFlatMapToInt() {
|
||||
return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).filter(n -> n > 1));
|
||||
}
|
||||
|
||||
@Template(MapOuterIntStreamAfterFlatMap.class)
|
||||
IntStream testMapOuterIntStreamAfterFlatMap() {
|
||||
return IntStream.of(1).flatMap(v -> IntStream.of(v * v).map(n -> n * 1));
|
||||
}
|
||||
|
||||
@Template(MapOuterStreamAfterFlatMapToInt.class)
|
||||
IntStream testMapOuterStreamAfterFlatMapToInt() {
|
||||
return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).map(n -> n * 1));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterIntStreamAfterFlatMap.class)
|
||||
IntStream testFlatMapOuterIntStreamAfterFlatMap() {
|
||||
return IntStream.of(1).flatMap(v -> IntStream.of(v * v).flatMap(IntStream::of));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterStreamAfterFlatMapToInt.class)
|
||||
IntStream testFlatMapOuterStreamAfterFlatMapToInt() {
|
||||
return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).flatMap(IntStream::of));
|
||||
}
|
||||
|
||||
@Template(IntStreamIsEmpty.class)
|
||||
ImmutableSet<Boolean> testIntStreamIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).count() == 0,
|
||||
@@ -57,6 +87,7 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(4).findFirst().isEmpty());
|
||||
}
|
||||
|
||||
@Template(IntStreamIsNotEmpty.class)
|
||||
ImmutableSet<Boolean> testIntStreamIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).count() != 0,
|
||||
@@ -65,11 +96,18 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(4).findFirst().isPresent());
|
||||
}
|
||||
|
||||
@Template(IntStreamMin.class)
|
||||
OptionalInt testIntStreamMin() {
|
||||
return IntStream.of(1).sorted().findFirst();
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testIntStreamNoneMatch() {
|
||||
@Template(IntStreamNoneMatch.class)
|
||||
boolean testIntStreamNoneMatch() {
|
||||
return IntStream.of(1).allMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(IntStreamNoneMatchPredicate.class)
|
||||
ImmutableSet<Boolean> testIntStreamNoneMatchPredicate() {
|
||||
IntPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
!IntStream.of(1).anyMatch(n -> n > 1),
|
||||
@@ -77,22 +115,21 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(3).filter(pred).findAny().isEmpty());
|
||||
}
|
||||
|
||||
boolean testIntStreamNoneMatch2() {
|
||||
return IntStream.of(1).allMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(IntStreamAnyMatch.class)
|
||||
ImmutableSet<Boolean> testIntStreamAnyMatch() {
|
||||
return ImmutableSet.of(
|
||||
!IntStream.of(1).noneMatch(n -> n > 1),
|
||||
IntStream.of(2).filter(n -> n > 2).findAny().isPresent());
|
||||
}
|
||||
|
||||
@Template(IntStreamAllMatch.class)
|
||||
boolean testIntStreamAllMatch() {
|
||||
return IntStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(IntStreamAllMatchPredicate.class)
|
||||
boolean testIntStreamAllMatchPredicate() {
|
||||
IntPredicate pred = i -> i > 0;
|
||||
return IntStream.of(1).noneMatch(pred.negate());
|
||||
}
|
||||
|
||||
boolean testIntStreamAllMatch2() {
|
||||
return IntStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -6,49 +6,79 @@ import java.util.OptionalInt;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.ConcatOneIntStream;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.ConcatTwoIntStreams;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FilterOuterIntStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FilterOuterStreamAfterFlatMapToInt;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FlatMapOuterIntStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.FlatMapOuterStreamAfterFlatMapToInt;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamAllMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamAllMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamAnyMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamClosedOpenRange;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamMin;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamNoneMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.IntStreamNoneMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.MapOuterIntStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.IntStreamTemplates.MapOuterStreamAfterFlatMapToInt;
|
||||
|
||||
@TemplateCollection(IntStreamTemplates.class)
|
||||
final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(IntStreamClosedOpenRange.class)
|
||||
IntStream testIntStreamClosedOpenRange() {
|
||||
return IntStream.range(0, 42);
|
||||
}
|
||||
|
||||
@Template(ConcatOneIntStream.class)
|
||||
IntStream testConcatOneIntStream() {
|
||||
return IntStream.of(1);
|
||||
}
|
||||
|
||||
@Template(ConcatTwoIntStreams.class)
|
||||
IntStream testConcatTwoIntStreams() {
|
||||
return IntStream.concat(IntStream.of(1), IntStream.of(2));
|
||||
}
|
||||
|
||||
@Template(FilterOuterIntStreamAfterFlatMap.class)
|
||||
IntStream testFilterOuterIntStreamAfterFlatMap() {
|
||||
return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).filter(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(FilterOuterStreamAfterFlatMapToInt.class)
|
||||
IntStream testFilterOuterStreamAfterFlatMapToInt() {
|
||||
return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).filter(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(MapOuterIntStreamAfterFlatMap.class)
|
||||
IntStream testMapOuterIntStreamAfterFlatMap() {
|
||||
return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).map(n -> n * 1);
|
||||
}
|
||||
|
||||
@Template(MapOuterStreamAfterFlatMapToInt.class)
|
||||
IntStream testMapOuterStreamAfterFlatMapToInt() {
|
||||
return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).map(n -> n * 1);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterIntStreamAfterFlatMap.class)
|
||||
IntStream testFlatMapOuterIntStreamAfterFlatMap() {
|
||||
return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).flatMap(IntStream::of);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterStreamAfterFlatMapToInt.class)
|
||||
IntStream testFlatMapOuterStreamAfterFlatMapToInt() {
|
||||
return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).flatMap(IntStream::of);
|
||||
}
|
||||
|
||||
@Template(IntStreamIsEmpty.class)
|
||||
ImmutableSet<Boolean> testIntStreamIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).findAny().isEmpty(),
|
||||
@@ -57,6 +87,7 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(4).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@Template(IntStreamIsNotEmpty.class)
|
||||
ImmutableSet<Boolean> testIntStreamIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).findAny().isPresent(),
|
||||
@@ -65,11 +96,18 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(4).findAny().isPresent());
|
||||
}
|
||||
|
||||
@Template(IntStreamMin.class)
|
||||
OptionalInt testIntStreamMin() {
|
||||
return IntStream.of(1).min();
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testIntStreamNoneMatch() {
|
||||
@Template(IntStreamNoneMatch.class)
|
||||
boolean testIntStreamNoneMatch() {
|
||||
return IntStream.of(1).noneMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(IntStreamNoneMatchPredicate.class)
|
||||
ImmutableSet<Boolean> testIntStreamNoneMatchPredicate() {
|
||||
IntPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).noneMatch(n -> n > 1),
|
||||
@@ -77,21 +115,20 @@ final class IntStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
IntStream.of(3).noneMatch(pred));
|
||||
}
|
||||
|
||||
boolean testIntStreamNoneMatch2() {
|
||||
return IntStream.of(1).noneMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(IntStreamAnyMatch.class)
|
||||
ImmutableSet<Boolean> testIntStreamAnyMatch() {
|
||||
return ImmutableSet.of(
|
||||
IntStream.of(1).anyMatch(n -> n > 1), IntStream.of(2).anyMatch(n -> n > 2));
|
||||
}
|
||||
|
||||
@Template(IntStreamAllMatch.class)
|
||||
boolean testIntStreamAllMatch() {
|
||||
return IntStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(IntStreamAllMatchPredicate.class)
|
||||
boolean testIntStreamAllMatchPredicate() {
|
||||
IntPredicate pred = i -> i > 0;
|
||||
return IntStream.of(1).allMatch(pred);
|
||||
}
|
||||
|
||||
boolean testIntStreamAllMatch2() {
|
||||
return IntStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.JUnitTemplates.ArgumentsEnumeration;
|
||||
|
||||
@TemplateCollection(JUnitTemplates.class)
|
||||
final class JUnitTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(ArgumentsEnumeration.class)
|
||||
ImmutableSet<Arguments> testArgumentsEnumeration() {
|
||||
return ImmutableSet.of(
|
||||
Arguments.of("foo"), Arguments.of(1, "foo", 2, "bar"), Arguments.of(new Object()));
|
||||
@@ -1,11 +1,16 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.JUnitTemplates.ArgumentsEnumeration;
|
||||
|
||||
@TemplateCollection(JUnitTemplates.class)
|
||||
final class JUnitTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(ArgumentsEnumeration.class)
|
||||
ImmutableSet<Arguments> testArgumentsEnumeration() {
|
||||
return ImmutableSet.of(
|
||||
arguments("foo"), arguments(1, "foo", 2, "bar"), arguments(new Object()));
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -6,49 +6,79 @@ import java.util.OptionalLong;
|
||||
import java.util.function.LongPredicate;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.ConcatOneLongStream;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.ConcatTwoLongStreams;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FilterOuterLongStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FilterOuterStreamAfterFlatMapToLong;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FlatMapOuterLongStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FlatMapOuterStreamAfterFlatMapToLong;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamAllMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamAllMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamAnyMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamClosedOpenRange;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamMin;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamNoneMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamNoneMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.MapOuterLongStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.MapOuterStreamAfterFlatMapToLong;
|
||||
|
||||
@TemplateCollection(LongStreamTemplates.class)
|
||||
final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(LongStreamClosedOpenRange.class)
|
||||
LongStream testLongStreamClosedOpenRange() {
|
||||
return LongStream.rangeClosed(0, 42 - 1);
|
||||
}
|
||||
|
||||
@Template(ConcatOneLongStream.class)
|
||||
LongStream testConcatOneLongStream() {
|
||||
return Streams.concat(LongStream.of(1));
|
||||
}
|
||||
|
||||
@Template(ConcatTwoLongStreams.class)
|
||||
LongStream testConcatTwoLongStreams() {
|
||||
return Streams.concat(LongStream.of(1), LongStream.of(2));
|
||||
}
|
||||
|
||||
@Template(FilterOuterLongStreamAfterFlatMap.class)
|
||||
LongStream testFilterOuterLongStreamAfterFlatMap() {
|
||||
return LongStream.of(1).flatMap(v -> LongStream.of(v * v).filter(n -> n > 1));
|
||||
}
|
||||
|
||||
@Template(FilterOuterStreamAfterFlatMapToLong.class)
|
||||
LongStream testFilterOuterStreamAfterFlatMapToLong() {
|
||||
return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v).filter(n -> n > 1));
|
||||
}
|
||||
|
||||
@Template(MapOuterLongStreamAfterFlatMap.class)
|
||||
LongStream testMapOuterLongStreamAfterFlatMap() {
|
||||
return LongStream.of(1).flatMap(v -> LongStream.of(v * v).map(n -> n * 1));
|
||||
}
|
||||
|
||||
@Template(MapOuterStreamAfterFlatMapToLong.class)
|
||||
LongStream testMapOuterStreamAfterFlatMapToLong() {
|
||||
return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v).map(n -> n * 1));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterLongStreamAfterFlatMap.class)
|
||||
LongStream testFlatMapOuterLongStreamAfterFlatMap() {
|
||||
return LongStream.of(1).flatMap(v -> LongStream.of(v * v).flatMap(LongStream::of));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterStreamAfterFlatMapToLong.class)
|
||||
LongStream testFlatMapOuterStreamAfterFlatMapToLong() {
|
||||
return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v).flatMap(LongStream::of));
|
||||
}
|
||||
|
||||
@Template(LongStreamIsEmpty.class)
|
||||
ImmutableSet<Boolean> testLongStreamIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).count() == 0,
|
||||
@@ -57,6 +87,7 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(4).findFirst().isEmpty());
|
||||
}
|
||||
|
||||
@Template(LongStreamIsNotEmpty.class)
|
||||
ImmutableSet<Boolean> testLongStreamIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).count() != 0,
|
||||
@@ -65,11 +96,18 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(4).findFirst().isPresent());
|
||||
}
|
||||
|
||||
@Template(LongStreamMin.class)
|
||||
OptionalLong testLongStreamMin() {
|
||||
return LongStream.of(1).sorted().findFirst();
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testLongStreamNoneMatch() {
|
||||
@Template(LongStreamNoneMatch.class)
|
||||
boolean testLongStreamNoneMatch() {
|
||||
return LongStream.of(1).allMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(LongStreamNoneMatchPredicate.class)
|
||||
ImmutableSet<Boolean> testLongStreamNoneMatchPredicate() {
|
||||
LongPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
!LongStream.of(1).anyMatch(n -> n > 1),
|
||||
@@ -77,22 +115,21 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(3).filter(pred).findAny().isEmpty());
|
||||
}
|
||||
|
||||
boolean testLongStreamNoneMatch2() {
|
||||
return LongStream.of(1).allMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(LongStreamAnyMatch.class)
|
||||
ImmutableSet<Boolean> testLongStreamAnyMatch() {
|
||||
return ImmutableSet.of(
|
||||
!LongStream.of(1).noneMatch(n -> n > 1),
|
||||
LongStream.of(2).filter(n -> n > 2).findAny().isPresent());
|
||||
}
|
||||
|
||||
@Template(LongStreamAllMatch.class)
|
||||
boolean testLongStreamAllMatch() {
|
||||
return LongStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
|
||||
@Template(LongStreamAllMatchPredicate.class)
|
||||
boolean testLongStreamAllMatchPredicate() {
|
||||
LongPredicate pred = i -> i > 0;
|
||||
return LongStream.of(1).noneMatch(pred.negate());
|
||||
}
|
||||
|
||||
boolean testLongStreamAllMatch2() {
|
||||
return LongStream.of(1).noneMatch(n -> !(n > 1));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -6,49 +6,79 @@ import java.util.OptionalLong;
|
||||
import java.util.function.LongPredicate;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.ConcatOneLongStream;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.ConcatTwoLongStreams;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FilterOuterLongStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FilterOuterStreamAfterFlatMapToLong;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FlatMapOuterLongStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.FlatMapOuterStreamAfterFlatMapToLong;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamAllMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamAllMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamAnyMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamClosedOpenRange;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamIsNotEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamMin;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamNoneMatch;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.LongStreamNoneMatchPredicate;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.MapOuterLongStreamAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.LongStreamTemplates.MapOuterStreamAfterFlatMapToLong;
|
||||
|
||||
@TemplateCollection(LongStreamTemplates.class)
|
||||
final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(LongStreamClosedOpenRange.class)
|
||||
LongStream testLongStreamClosedOpenRange() {
|
||||
return LongStream.range(0, 42);
|
||||
}
|
||||
|
||||
@Template(ConcatOneLongStream.class)
|
||||
LongStream testConcatOneLongStream() {
|
||||
return LongStream.of(1);
|
||||
}
|
||||
|
||||
@Template(ConcatTwoLongStreams.class)
|
||||
LongStream testConcatTwoLongStreams() {
|
||||
return LongStream.concat(LongStream.of(1), LongStream.of(2));
|
||||
}
|
||||
|
||||
@Template(FilterOuterLongStreamAfterFlatMap.class)
|
||||
LongStream testFilterOuterLongStreamAfterFlatMap() {
|
||||
return LongStream.of(1).flatMap(v -> LongStream.of(v * v)).filter(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(FilterOuterStreamAfterFlatMapToLong.class)
|
||||
LongStream testFilterOuterStreamAfterFlatMapToLong() {
|
||||
return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v)).filter(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(MapOuterLongStreamAfterFlatMap.class)
|
||||
LongStream testMapOuterLongStreamAfterFlatMap() {
|
||||
return LongStream.of(1).flatMap(v -> LongStream.of(v * v)).map(n -> n * 1);
|
||||
}
|
||||
|
||||
@Template(MapOuterStreamAfterFlatMapToLong.class)
|
||||
LongStream testMapOuterStreamAfterFlatMapToLong() {
|
||||
return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v)).map(n -> n * 1);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterLongStreamAfterFlatMap.class)
|
||||
LongStream testFlatMapOuterLongStreamAfterFlatMap() {
|
||||
return LongStream.of(1).flatMap(v -> LongStream.of(v * v)).flatMap(LongStream::of);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterStreamAfterFlatMapToLong.class)
|
||||
LongStream testFlatMapOuterStreamAfterFlatMapToLong() {
|
||||
return Stream.of(1).flatMapToLong(v -> LongStream.of(v * v)).flatMap(LongStream::of);
|
||||
}
|
||||
|
||||
@Template(LongStreamIsEmpty.class)
|
||||
ImmutableSet<Boolean> testLongStreamIsEmpty() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).findAny().isEmpty(),
|
||||
@@ -57,6 +87,7 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(4).findAny().isEmpty());
|
||||
}
|
||||
|
||||
@Template(LongStreamIsNotEmpty.class)
|
||||
ImmutableSet<Boolean> testLongStreamIsNotEmpty() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).findAny().isPresent(),
|
||||
@@ -65,11 +96,18 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(4).findAny().isPresent());
|
||||
}
|
||||
|
||||
@Template(LongStreamMin.class)
|
||||
OptionalLong testLongStreamMin() {
|
||||
return LongStream.of(1).min();
|
||||
}
|
||||
|
||||
ImmutableSet<Boolean> testLongStreamNoneMatch() {
|
||||
@Template(LongStreamNoneMatch.class)
|
||||
boolean testLongStreamNoneMatch() {
|
||||
return LongStream.of(1).noneMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(LongStreamNoneMatchPredicate.class)
|
||||
ImmutableSet<Boolean> testLongStreamNoneMatchPredicate() {
|
||||
LongPredicate pred = i -> i > 0;
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).noneMatch(n -> n > 1),
|
||||
@@ -77,21 +115,20 @@ final class LongStreamTemplatesTest implements RefasterTemplateTestCase {
|
||||
LongStream.of(3).noneMatch(pred));
|
||||
}
|
||||
|
||||
boolean testLongStreamNoneMatch2() {
|
||||
return LongStream.of(1).noneMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(LongStreamAnyMatch.class)
|
||||
ImmutableSet<Boolean> testLongStreamAnyMatch() {
|
||||
return ImmutableSet.of(
|
||||
LongStream.of(1).anyMatch(n -> n > 1), LongStream.of(2).anyMatch(n -> n > 2));
|
||||
}
|
||||
|
||||
@Template(LongStreamAllMatch.class)
|
||||
boolean testLongStreamAllMatch() {
|
||||
return LongStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
|
||||
@Template(LongStreamAllMatchPredicate.class)
|
||||
boolean testLongStreamAllMatchPredicate() {
|
||||
LongPredicate pred = i -> i > 0;
|
||||
return LongStream.of(1).allMatch(pred);
|
||||
}
|
||||
|
||||
boolean testLongStreamAllMatch2() {
|
||||
return LongStream.of(1).allMatch(n -> n > 1);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,51 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntry;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByKey;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByKeyWithCustomComparator;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByValue;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByValueWithCustomComparator;
|
||||
|
||||
@TemplateCollection(MapEntryTemplates.class)
|
||||
final class MapEntryTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(AbstractMap.class, Maps.class);
|
||||
}
|
||||
|
||||
@Template(MapEntry.class)
|
||||
ImmutableSet<Map.Entry<String, Integer>> testMapEntry() {
|
||||
return ImmutableSet.of(
|
||||
Maps.immutableEntry("foo", 1), new AbstractMap.SimpleImmutableEntry<>("bar", 2));
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByKey.class)
|
||||
ImmutableSet<Comparator<Map.Entry<Integer, String>>> testMapEntryComparingByKey() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.comparing(Map.Entry::getKey),
|
||||
Map.Entry.comparingByKey(Comparator.naturalOrder()));
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByKeyWithCustomComparator.class)
|
||||
Comparator<Map.Entry<Integer, String>> testMapEntryComparingByKeyWithCustomComparator() {
|
||||
return Comparator.comparing(Map.Entry::getKey, Comparator.comparingInt(i -> i * 2));
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByValue.class)
|
||||
ImmutableSet<Comparator<Map.Entry<Integer, String>>> testMapEntryComparingByValue() {
|
||||
return ImmutableSet.of(
|
||||
Comparator.comparing(Map.Entry::getValue),
|
||||
Map.Entry.comparingByValue(Comparator.naturalOrder()));
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByValueWithCustomComparator.class)
|
||||
Comparator<Map.Entry<Integer, String>> testMapEntryComparingByValueWithCustomComparator() {
|
||||
return Comparator.comparing(Map.Entry::getValue, Comparator.comparingInt(String::length));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static java.util.Map.Entry.comparingByKey;
|
||||
import static java.util.Map.Entry.comparingByValue;
|
||||
@@ -8,29 +8,42 @@ import com.google.common.collect.Maps;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntry;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByKey;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByKeyWithCustomComparator;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByValue;
|
||||
import tech.picnic.errorprone.refastertemplates.MapEntryTemplates.MapEntryComparingByValueWithCustomComparator;
|
||||
|
||||
@TemplateCollection(MapEntryTemplates.class)
|
||||
final class MapEntryTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(AbstractMap.class, Maps.class);
|
||||
}
|
||||
|
||||
@Template(MapEntry.class)
|
||||
ImmutableSet<Map.Entry<String, Integer>> testMapEntry() {
|
||||
return ImmutableSet.of(Map.entry("foo", 1), Map.entry("bar", 2));
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByKey.class)
|
||||
ImmutableSet<Comparator<Map.Entry<Integer, String>>> testMapEntryComparingByKey() {
|
||||
return ImmutableSet.of(comparingByKey(), comparingByKey());
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByKeyWithCustomComparator.class)
|
||||
Comparator<Map.Entry<Integer, String>> testMapEntryComparingByKeyWithCustomComparator() {
|
||||
return comparingByKey(Comparator.comparingInt(i -> i * 2));
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByValue.class)
|
||||
ImmutableSet<Comparator<Map.Entry<Integer, String>>> testMapEntryComparingByValue() {
|
||||
return ImmutableSet.of(comparingByValue(), comparingByValue());
|
||||
}
|
||||
|
||||
@Template(MapEntryComparingByValueWithCustomComparator.class)
|
||||
Comparator<Map.Entry<Integer, String>> testMapEntryComparingByValueWithCustomComparator() {
|
||||
return comparingByValue(Comparator.comparingInt(String::length));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -6,17 +6,24 @@ import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.mockito.verification.VerificationMode;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.MockitoTemplates.Never;
|
||||
import tech.picnic.errorprone.refastertemplates.MockitoTemplates.VerifyOnce;
|
||||
|
||||
@TemplateCollection(MockitoTemplates.class)
|
||||
final class MockitoTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(times(1));
|
||||
}
|
||||
|
||||
@Template(Never.class)
|
||||
VerificationMode testNever() {
|
||||
return times(0);
|
||||
}
|
||||
|
||||
@Template(VerifyOnce.class)
|
||||
Object testVerifyOnce() {
|
||||
return verify(mock(Object.class), times(1));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -7,17 +7,24 @@ import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.mockito.verification.VerificationMode;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.MockitoTemplates.Never;
|
||||
import tech.picnic.errorprone.refastertemplates.MockitoTemplates.VerifyOnce;
|
||||
|
||||
@TemplateCollection(MockitoTemplates.class)
|
||||
final class MockitoTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(times(1));
|
||||
}
|
||||
|
||||
@Template(Never.class)
|
||||
VerificationMode testNever() {
|
||||
return never();
|
||||
}
|
||||
|
||||
@Template(VerifyOnce.class)
|
||||
Object testVerifyOnce() {
|
||||
return verify(mock(Object.class));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
@@ -6,21 +6,30 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.MultimapTemplates.MultimapGet;
|
||||
import tech.picnic.errorprone.refastertemplates.MultimapTemplates.MultimapKeySet;
|
||||
import tech.picnic.errorprone.refastertemplates.MultimapTemplates.MultimapSize;
|
||||
|
||||
@TemplateCollection(MultimapTemplates.class)
|
||||
final class MultimapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Multimaps.class);
|
||||
}
|
||||
|
||||
@Template(MultimapKeySet.class)
|
||||
Set<String> testMultimapKeySet() {
|
||||
return ImmutableSetMultimap.of("foo", "bar").asMap().keySet();
|
||||
}
|
||||
|
||||
@Template(MultimapSize.class)
|
||||
int testMultimapSize() {
|
||||
return ImmutableSetMultimap.of().values().size();
|
||||
}
|
||||
|
||||
@Template(MultimapGet.class)
|
||||
ImmutableSet<Collection<Integer>> testMultimapGet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.of(1, 2).asMap().get(1),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
@@ -6,21 +6,30 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.MultimapTemplates.MultimapGet;
|
||||
import tech.picnic.errorprone.refastertemplates.MultimapTemplates.MultimapKeySet;
|
||||
import tech.picnic.errorprone.refastertemplates.MultimapTemplates.MultimapSize;
|
||||
|
||||
@TemplateCollection(MultimapTemplates.class)
|
||||
final class MultimapTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Multimaps.class);
|
||||
}
|
||||
|
||||
@Template(MultimapKeySet.class)
|
||||
Set<String> testMultimapKeySet() {
|
||||
return ImmutableSetMultimap.of("foo", "bar").keySet();
|
||||
}
|
||||
|
||||
@Template(MultimapSize.class)
|
||||
int testMultimapSize() {
|
||||
return ImmutableSetMultimap.of().size();
|
||||
}
|
||||
|
||||
@Template(MultimapGet.class)
|
||||
ImmutableSet<Collection<Integer>> testMultimapGet() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSetMultimap.of(1, 2).get(1),
|
||||
@@ -1,23 +1,32 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.NullTemplates.IsNullFunction;
|
||||
import tech.picnic.errorprone.refastertemplates.NullTemplates.NonNullFunction;
|
||||
import tech.picnic.errorprone.refastertemplates.NullTemplates.RequireNonNullElse;
|
||||
|
||||
@TemplateCollection(NullTemplates.class)
|
||||
final class NullTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(MoreObjects.class);
|
||||
}
|
||||
|
||||
@Template(RequireNonNullElse.class)
|
||||
String testRequireNonNullElse() {
|
||||
return MoreObjects.firstNonNull("foo", "bar");
|
||||
}
|
||||
|
||||
@Template(IsNullFunction.class)
|
||||
long testIsNullFunction() {
|
||||
return Stream.of("foo").filter(s -> s == null).count();
|
||||
}
|
||||
|
||||
@Template(NonNullFunction.class)
|
||||
long testNonNullFunction() {
|
||||
return Stream.of("foo").filter(s -> s != null).count();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static java.util.Objects.requireNonNullElse;
|
||||
|
||||
@@ -6,21 +6,30 @@ import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.NullTemplates.IsNullFunction;
|
||||
import tech.picnic.errorprone.refastertemplates.NullTemplates.NonNullFunction;
|
||||
import tech.picnic.errorprone.refastertemplates.NullTemplates.RequireNonNullElse;
|
||||
|
||||
@TemplateCollection(NullTemplates.class)
|
||||
final class NullTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(MoreObjects.class);
|
||||
}
|
||||
|
||||
@Template(RequireNonNullElse.class)
|
||||
String testRequireNonNullElse() {
|
||||
return requireNonNullElse("foo", "bar");
|
||||
}
|
||||
|
||||
@Template(IsNullFunction.class)
|
||||
long testIsNullFunction() {
|
||||
return Stream.of("foo").filter(Objects::isNull).count();
|
||||
}
|
||||
|
||||
@Template(NonNullFunction.class)
|
||||
long testNonNullFunction() {
|
||||
return Stream.of("foo").filter(Objects::nonNull).count();
|
||||
}
|
||||
@@ -1,39 +1,66 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.FilterOuterOptionalAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.FlatMapOuterOptionalAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.FlatMapToOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.MapOptionalToBoolean;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.MapOuterOptionalAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.MapToNullable;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalFirstIteratorElement;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalIsPresent;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOfNullable;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOrElseThrow;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOrElseThrowMethodReference;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOrOtherOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OrOrElseThrow;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.StreamFlatMapOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.StreamMapToOptionalGet;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.TernaryOperatorOptionalNegativeFiltering;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.TernaryOperatorOptionalPositiveFiltering;
|
||||
|
||||
@TemplateCollection(OptionalTemplates.class)
|
||||
final class OptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(OptionalOfNullable.class)
|
||||
ImmutableSet<Optional<String>> testOptionalOfNullable() {
|
||||
return ImmutableSet.of(
|
||||
toString() == null ? Optional.empty() : Optional.of(toString()),
|
||||
toString() != null ? Optional.of(toString()) : Optional.empty());
|
||||
}
|
||||
|
||||
@Template(OptionalIsEmpty.class)
|
||||
ImmutableSet<Boolean> testOptionalIsEmpty() {
|
||||
return ImmutableSet.of(!Optional.empty().isPresent(), !Optional.of("foo").isPresent());
|
||||
}
|
||||
|
||||
@Template(OptionalIsPresent.class)
|
||||
ImmutableSet<Boolean> testOptionalIsPresent() {
|
||||
return ImmutableSet.of(!Optional.empty().isEmpty(), !Optional.of("foo").isEmpty());
|
||||
}
|
||||
|
||||
@Template(OptionalOrElseThrow.class)
|
||||
String testOptionalOrElseThrow() {
|
||||
return Optional.of("foo").get();
|
||||
}
|
||||
|
||||
@Template(OptionalOrElseThrowMethodReference.class)
|
||||
Function<Optional<Integer>, Integer> testOptionalOrElseThrowMethodReference() {
|
||||
return Optional::get;
|
||||
}
|
||||
|
||||
@Template(OptionalFirstIteratorElement.class)
|
||||
ImmutableSet<Optional<String>> testOptionalFirstIteratorElement() {
|
||||
return ImmutableSet.of(
|
||||
ImmutableSet.of("foo").iterator().hasNext()
|
||||
@@ -44,60 +71,72 @@ final class OptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
: Optional.of(ImmutableSet.of("foo").iterator().next()));
|
||||
}
|
||||
|
||||
@Template(TernaryOperatorOptionalPositiveFiltering.class)
|
||||
ImmutableSet<Optional<String>> testTernaryOperatorOptionalPositiveFiltering() {
|
||||
return ImmutableSet.of(
|
||||
"foo".length() > 5 ? Optional.of("foo") : Optional.empty(),
|
||||
!"bar".contains("baz") ? Optional.of("bar") : Optional.empty());
|
||||
}
|
||||
|
||||
@Template(TernaryOperatorOptionalNegativeFiltering.class)
|
||||
ImmutableSet<Optional<String>> testTernaryOperatorOptionalNegativeFiltering() {
|
||||
return ImmutableSet.of(
|
||||
"foo".length() > 5 ? Optional.empty() : Optional.of("foo"),
|
||||
!"bar".contains("baz") ? Optional.empty() : Optional.of("bar"));
|
||||
}
|
||||
|
||||
@Template(MapOptionalToBoolean.class)
|
||||
ImmutableSet<Boolean> testMapOptionalToBoolean() {
|
||||
return ImmutableSet.of(
|
||||
Optional.of("foo").map(String::isEmpty).orElse(false),
|
||||
Optional.of("bar").map(s -> s.isEmpty()).orElse(Boolean.FALSE));
|
||||
}
|
||||
|
||||
@Template(MapToNullable.class)
|
||||
ImmutableSet<Optional<String>> testMapToNullable() {
|
||||
return ImmutableSet.of(
|
||||
Optional.of(1).flatMap(n -> Optional.of(String.valueOf(n))),
|
||||
Optional.of(2).flatMap(n -> Optional.ofNullable(String.valueOf(n))));
|
||||
}
|
||||
|
||||
@Template(FlatMapToOptional.class)
|
||||
Optional<String> testFlatMapToOptional() {
|
||||
return Optional.of(1).map(n -> Optional.of(String.valueOf(n)).orElseThrow());
|
||||
}
|
||||
|
||||
@Template(OrOrElseThrow.class)
|
||||
String testOrOrElseThrow() {
|
||||
return Optional.of("foo").orElseGet(() -> Optional.of("bar").orElseThrow());
|
||||
}
|
||||
|
||||
@Template(StreamFlatMapOptional.class)
|
||||
ImmutableSet<Object> testStreamFlatMapOptional() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(Optional.empty()).filter(Optional::isPresent).map(Optional::orElseThrow),
|
||||
Stream.of(Optional.of("foo")).flatMap(Streams::stream));
|
||||
}
|
||||
|
||||
@Template(StreamMapToOptionalGet.class)
|
||||
Stream<String> testStreamMapToOptionalGet() {
|
||||
return Stream.of(1).map(n -> Optional.of(String.valueOf(n)).orElseThrow());
|
||||
}
|
||||
|
||||
@Template(FilterOuterOptionalAfterFlatMap.class)
|
||||
Optional<Integer> testFilterOuterOptionalAfterFlatMap() {
|
||||
return Optional.of("foo").flatMap(v -> Optional.of(v.length()).filter(len -> len > 0));
|
||||
}
|
||||
|
||||
@Template(MapOuterOptionalAfterFlatMap.class)
|
||||
Optional<Integer> testMapOuterOptionalAfterFlatMap() {
|
||||
return Optional.of("foo").flatMap(v -> Optional.of(v.length()).map(len -> len * 0));
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterOptionalAfterFlatMap.class)
|
||||
Optional<Integer> testFlatMapOuterOptionalAfterFlatMap() {
|
||||
return Optional.of("foo").flatMap(v -> Optional.of(v.length()).flatMap(Optional::of));
|
||||
}
|
||||
|
||||
@Template(OptionalOrOtherOptional.class)
|
||||
ImmutableSet<Optional<String>> testOptionalOrOtherOptional() {
|
||||
return ImmutableSet.of(
|
||||
Optional.of("foo").map(Optional::of).orElse(Optional.of("bar")),
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.Streams.stream;
|
||||
|
||||
@@ -7,39 +7,67 @@ import com.google.common.collect.Streams;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.FilterOuterOptionalAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.FlatMapOuterOptionalAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.FlatMapToOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.MapOptionalToBoolean;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.MapOuterOptionalAfterFlatMap;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.MapToNullable;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalFirstIteratorElement;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalIsEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalIsPresent;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOfNullable;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOrElseThrow;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOrElseThrowMethodReference;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OptionalOrOtherOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.OrOrElseThrow;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.StreamFlatMapOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.StreamMapToOptionalGet;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.TernaryOperatorOptionalNegativeFiltering;
|
||||
import tech.picnic.errorprone.refastertemplates.OptionalTemplates.TernaryOperatorOptionalPositiveFiltering;
|
||||
|
||||
@TemplateCollection(OptionalTemplates.class)
|
||||
final class OptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Streams.class);
|
||||
}
|
||||
|
||||
@Template(OptionalOfNullable.class)
|
||||
ImmutableSet<Optional<String>> testOptionalOfNullable() {
|
||||
return ImmutableSet.of(Optional.ofNullable(toString()), Optional.ofNullable(toString()));
|
||||
}
|
||||
|
||||
@Template(OptionalIsEmpty.class)
|
||||
ImmutableSet<Boolean> testOptionalIsEmpty() {
|
||||
return ImmutableSet.of(Optional.empty().isEmpty(), Optional.of("foo").isEmpty());
|
||||
}
|
||||
|
||||
@Template(OptionalIsPresent.class)
|
||||
ImmutableSet<Boolean> testOptionalIsPresent() {
|
||||
return ImmutableSet.of(Optional.empty().isPresent(), Optional.of("foo").isPresent());
|
||||
}
|
||||
|
||||
@Template(OptionalOrElseThrow.class)
|
||||
String testOptionalOrElseThrow() {
|
||||
return Optional.of("foo").orElseThrow();
|
||||
}
|
||||
|
||||
@Template(OptionalOrElseThrowMethodReference.class)
|
||||
Function<Optional<Integer>, Integer> testOptionalOrElseThrowMethodReference() {
|
||||
return Optional::orElseThrow;
|
||||
}
|
||||
|
||||
@Template(OptionalFirstIteratorElement.class)
|
||||
ImmutableSet<Optional<String>> testOptionalFirstIteratorElement() {
|
||||
return ImmutableSet.of(
|
||||
stream(ImmutableSet.of("foo").iterator()).findFirst(),
|
||||
stream(ImmutableSet.of("foo").iterator()).findFirst());
|
||||
}
|
||||
|
||||
@Template(TernaryOperatorOptionalPositiveFiltering.class)
|
||||
ImmutableSet<Optional<String>> testTernaryOperatorOptionalPositiveFiltering() {
|
||||
return ImmutableSet.of(
|
||||
/* Or Optional.ofNullable (can't auto-infer). */ Optional.of("foo")
|
||||
@@ -48,6 +76,7 @@ final class OptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
.filter(v -> !v.contains("baz")));
|
||||
}
|
||||
|
||||
@Template(TernaryOperatorOptionalNegativeFiltering.class)
|
||||
ImmutableSet<Optional<String>> testTernaryOperatorOptionalNegativeFiltering() {
|
||||
return ImmutableSet.of(
|
||||
/* Or Optional.ofNullable (can't auto-infer). */ Optional.of("foo")
|
||||
@@ -56,47 +85,57 @@ final class OptionalTemplatesTest implements RefasterTemplateTestCase {
|
||||
.filter(v -> v.contains("baz")));
|
||||
}
|
||||
|
||||
@Template(MapOptionalToBoolean.class)
|
||||
ImmutableSet<Boolean> testMapOptionalToBoolean() {
|
||||
return ImmutableSet.of(
|
||||
Optional.of("foo").filter(String::isEmpty).isPresent(),
|
||||
Optional.of("bar").filter(s -> s.isEmpty()).isPresent());
|
||||
}
|
||||
|
||||
@Template(MapToNullable.class)
|
||||
ImmutableSet<Optional<String>> testMapToNullable() {
|
||||
return ImmutableSet.of(
|
||||
Optional.of(1).map(n -> String.valueOf(n)), Optional.of(2).map(n -> String.valueOf(n)));
|
||||
}
|
||||
|
||||
@Template(FlatMapToOptional.class)
|
||||
Optional<String> testFlatMapToOptional() {
|
||||
return Optional.of(1).flatMap(n -> Optional.of(String.valueOf(n)));
|
||||
}
|
||||
|
||||
@Template(OrOrElseThrow.class)
|
||||
String testOrOrElseThrow() {
|
||||
return Optional.of("foo").or(() -> Optional.of("bar")).orElseThrow();
|
||||
}
|
||||
|
||||
@Template(StreamFlatMapOptional.class)
|
||||
ImmutableSet<Object> testStreamFlatMapOptional() {
|
||||
return ImmutableSet.of(
|
||||
Stream.of(Optional.empty()).flatMap(Optional::stream),
|
||||
Stream.of(Optional.of("foo")).flatMap(Optional::stream));
|
||||
}
|
||||
|
||||
@Template(StreamMapToOptionalGet.class)
|
||||
Stream<String> testStreamMapToOptionalGet() {
|
||||
return Stream.of(1).flatMap(n -> Optional.of(String.valueOf(n)).stream());
|
||||
}
|
||||
|
||||
@Template(FilterOuterOptionalAfterFlatMap.class)
|
||||
Optional<Integer> testFilterOuterOptionalAfterFlatMap() {
|
||||
return Optional.of("foo").flatMap(v -> Optional.of(v.length())).filter(len -> len > 0);
|
||||
}
|
||||
|
||||
@Template(MapOuterOptionalAfterFlatMap.class)
|
||||
Optional<Integer> testMapOuterOptionalAfterFlatMap() {
|
||||
return Optional.of("foo").flatMap(v -> Optional.of(v.length())).map(len -> len * 0);
|
||||
}
|
||||
|
||||
@Template(FlatMapOuterOptionalAfterFlatMap.class)
|
||||
Optional<Integer> testFlatMapOuterOptionalAfterFlatMap() {
|
||||
return Optional.of("foo").flatMap(v -> Optional.of(v.length())).flatMap(Optional::of);
|
||||
}
|
||||
|
||||
@Template(OptionalOrOtherOptional.class)
|
||||
ImmutableSet<Optional<String>> testOptionalOrOtherOptional() {
|
||||
return ImmutableSet.of(
|
||||
Optional.of("foo").or(() -> Optional.of("bar")),
|
||||
@@ -1,14 +1,23 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.primitives.Ints;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.GreaterThan;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.GreaterThanOrEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.LessThan;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.LessThanOrEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.LongToIntExact;
|
||||
|
||||
@TemplateCollection(PrimitiveTemplates.class)
|
||||
final class PrimitiveTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Ints.class);
|
||||
}
|
||||
|
||||
@Template(LessThan.class)
|
||||
ImmutableSet<Boolean> testLessThan() {
|
||||
return ImmutableSet.of(
|
||||
!((byte) 3 >= (byte) 4),
|
||||
@@ -19,6 +28,7 @@ final class PrimitiveTemplatesTest implements RefasterTemplateTestCase {
|
||||
!(3.0 >= 4.0));
|
||||
}
|
||||
|
||||
@Template(LessThanOrEqualTo.class)
|
||||
ImmutableSet<Boolean> testLessThanOrEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
!((byte) 3 > (byte) 4),
|
||||
@@ -29,6 +39,7 @@ final class PrimitiveTemplatesTest implements RefasterTemplateTestCase {
|
||||
!(3.0 > 4.0));
|
||||
}
|
||||
|
||||
@Template(GreaterThan.class)
|
||||
ImmutableSet<Boolean> testGreaterThan() {
|
||||
return ImmutableSet.of(
|
||||
!((byte) 3 <= (byte) 4),
|
||||
@@ -39,6 +50,7 @@ final class PrimitiveTemplatesTest implements RefasterTemplateTestCase {
|
||||
!(3.0 <= 4.0));
|
||||
}
|
||||
|
||||
@Template(GreaterThanOrEqualTo.class)
|
||||
ImmutableSet<Boolean> testGreaterThanOrEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
!((byte) 3 < (byte) 4),
|
||||
@@ -49,6 +61,7 @@ final class PrimitiveTemplatesTest implements RefasterTemplateTestCase {
|
||||
!(3.0 < 4.0));
|
||||
}
|
||||
|
||||
@Template(LongToIntExact.class)
|
||||
int testLongToIntExact() {
|
||||
return Ints.checkedCast(Long.MAX_VALUE);
|
||||
}
|
||||
@@ -1,34 +1,47 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.primitives.Ints;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.GreaterThan;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.GreaterThanOrEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.LessThan;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.LessThanOrEqualTo;
|
||||
import tech.picnic.errorprone.refastertemplates.PrimitiveTemplates.LongToIntExact;
|
||||
|
||||
@TemplateCollection(PrimitiveTemplates.class)
|
||||
final class PrimitiveTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Override
|
||||
public ImmutableSet<?> elidedTypesAndStaticImports() {
|
||||
return ImmutableSet.of(Ints.class);
|
||||
}
|
||||
|
||||
@Template(LessThan.class)
|
||||
ImmutableSet<Boolean> testLessThan() {
|
||||
return ImmutableSet.of(
|
||||
(byte) 3 < (byte) 4, (short) 3 < (short) 4, 3 < 4, 3L < 4L, 3F < 4F, 3.0 < 4.0);
|
||||
}
|
||||
|
||||
@Template(LessThanOrEqualTo.class)
|
||||
ImmutableSet<Boolean> testLessThanOrEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
(byte) 3 <= (byte) 4, (short) 3 <= (short) 4, 3 <= 4, 3L <= 4L, 3F <= 4F, 3.0 <= 4.0);
|
||||
}
|
||||
|
||||
@Template(GreaterThan.class)
|
||||
ImmutableSet<Boolean> testGreaterThan() {
|
||||
return ImmutableSet.of(
|
||||
(byte) 3 > (byte) 4, (short) 3 > (short) 4, 3 > 4, 3L > 4L, 3F > 4F, 3.0 > 4.0);
|
||||
}
|
||||
|
||||
@Template(GreaterThanOrEqualTo.class)
|
||||
ImmutableSet<Boolean> testGreaterThanOrEqualTo() {
|
||||
return ImmutableSet.of(
|
||||
(byte) 3 >= (byte) 4, (short) 3 >= (short) 4, 3 >= 4, 3L >= 4L, 3F >= 4F, 3.0 >= 4.0);
|
||||
}
|
||||
|
||||
@Template(LongToIntExact.class)
|
||||
int testLongToIntExact() {
|
||||
return Math.toIntExact(Long.MAX_VALUE);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.time.Duration;
|
||||
@@ -8,109 +8,160 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import reactor.test.publisher.PublisherProbe;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxDeferredError;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxErrorSupplier;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxIdentity;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxSwitchIfEmptyOfEmptyPublisher;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoCollectToOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoDeferredError;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoErrorSupplier;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoFlatMapToFlux;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoFlux;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoFromOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoSwitchIfEmptyOfEmptyPublisher;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoThenReturn;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.PublisherProbeEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierFromFlux;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierFromMono;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyComplete;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyError;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorClass;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorMatches;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorMessage;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorSatisfies;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyTimeout;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierStepExpectNext;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierStepExpectNextEmpty;
|
||||
|
||||
@TemplateCollection(ReactorTemplates.class)
|
||||
final class ReactorTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(MonoFromOptional.class)
|
||||
ImmutableSet<Mono<Integer>> testMonoFromOptional() {
|
||||
return ImmutableSet.of(
|
||||
Mono.fromCallable(() -> Optional.of(1).orElse(null)),
|
||||
Mono.fromSupplier(() -> Optional.of(2).orElse(null)));
|
||||
}
|
||||
|
||||
@Template(MonoDeferredError.class)
|
||||
Mono<Void> testMonoDeferredError() {
|
||||
return Mono.defer(() -> Mono.error(new IllegalStateException()));
|
||||
}
|
||||
|
||||
@Template(FluxDeferredError.class)
|
||||
Flux<Void> testFluxDeferredError() {
|
||||
return Flux.defer(() -> Flux.error(new IllegalStateException()));
|
||||
}
|
||||
|
||||
@Template(MonoErrorSupplier.class)
|
||||
Mono<Void> testMonoErrorSupplier() {
|
||||
return Mono.error(() -> ((Supplier<RuntimeException>) null).get());
|
||||
}
|
||||
|
||||
@Template(FluxErrorSupplier.class)
|
||||
Flux<Void> testFluxErrorSupplier() {
|
||||
return Flux.error(() -> ((Supplier<RuntimeException>) null).get());
|
||||
}
|
||||
|
||||
@Template(MonoThenReturn.class)
|
||||
Mono<String> testMonoThenReturn() {
|
||||
return Mono.empty().then(Mono.just("foo"));
|
||||
}
|
||||
|
||||
@Template(MonoSwitchIfEmptyOfEmptyPublisher.class)
|
||||
Mono<Integer> testMonoSwitchIfEmptyOfEmptyPublisher() {
|
||||
return Mono.just(1).switchIfEmpty(Mono.empty());
|
||||
}
|
||||
|
||||
@Template(FluxSwitchIfEmptyOfEmptyPublisher.class)
|
||||
ImmutableSet<Flux<Integer>> testFluxSwitchIfEmptyOfEmptyPublisher() {
|
||||
return ImmutableSet.of(
|
||||
Flux.just(1).switchIfEmpty(Mono.empty()), Flux.just(2).switchIfEmpty(Flux.empty()));
|
||||
}
|
||||
|
||||
@Template(MonoFlatMapToFlux.class)
|
||||
Flux<String> testMonoFlatMapToFlux() {
|
||||
return Mono.just("foo").flatMapMany(s -> Mono.just(s + s));
|
||||
}
|
||||
|
||||
@Template(MonoFlux.class)
|
||||
Flux<String> testMonoFlux() {
|
||||
return Flux.concat(Mono.just("foo"));
|
||||
}
|
||||
|
||||
@Template(FluxIdentity.class)
|
||||
Flux<String> testFluxIdentity() {
|
||||
return Flux.concat(Flux.just("foo"));
|
||||
}
|
||||
|
||||
@Template(MonoCollectToOptional.class)
|
||||
ImmutableSet<Mono<Optional<String>>> testMonoCollectToOptional() {
|
||||
return ImmutableSet.of(
|
||||
Mono.just("foo").map(Optional::of).defaultIfEmpty(Optional.empty()),
|
||||
Mono.just("bar").map(Optional::of).switchIfEmpty(Mono.just(Optional.empty())));
|
||||
}
|
||||
|
||||
@Template(PublisherProbeEmpty.class)
|
||||
ImmutableSet<PublisherProbe<Void>> testPublisherProbeEmpty() {
|
||||
return ImmutableSet.of(PublisherProbe.of(Mono.empty()), PublisherProbe.of(Flux.empty()));
|
||||
}
|
||||
|
||||
@Template(StepVerifierFromMono.class)
|
||||
StepVerifier.FirstStep<Integer> testStepVerifierFromMono() {
|
||||
return StepVerifier.create(Mono.just(1));
|
||||
}
|
||||
|
||||
@Template(StepVerifierFromFlux.class)
|
||||
StepVerifier.FirstStep<Integer> testStepVerifierFromFlux() {
|
||||
return StepVerifier.create(Flux.just(1));
|
||||
}
|
||||
|
||||
@Template(StepVerifierStepExpectNextEmpty.class)
|
||||
StepVerifier.Step<Integer> testStepVerifierStepExpectNextEmpty() {
|
||||
return StepVerifier.create(Mono.just(0)).expectNext();
|
||||
}
|
||||
|
||||
@Template(StepVerifierStepExpectNext.class)
|
||||
ImmutableSet<StepVerifier.Step<String>> testStepVerifierStepExpectNext() {
|
||||
return ImmutableSet.of(
|
||||
StepVerifier.create(Mono.just("foo")).expectNextMatches(s -> s.equals("bar")),
|
||||
StepVerifier.create(Mono.just("baz")).expectNextMatches("qux"::equals));
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyComplete.class)
|
||||
Duration testStepVerifierLastStepVerifyComplete() {
|
||||
return StepVerifier.create(Mono.empty()).expectComplete().verify();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyError.class)
|
||||
Duration testStepVerifierLastStepVerifyError() {
|
||||
return StepVerifier.create(Mono.empty()).expectError().verify();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorClass.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorClass() {
|
||||
return StepVerifier.create(Mono.empty()).expectError(IllegalArgumentException.class).verify();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorMatches.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorMatches() {
|
||||
return StepVerifier.create(Mono.empty())
|
||||
.expectErrorMatches(IllegalArgumentException.class::equals)
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorSatisfies.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorSatisfies() {
|
||||
return StepVerifier.create(Mono.empty()).expectErrorSatisfies(t -> {}).verify();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorMessage.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorMessage() {
|
||||
return StepVerifier.create(Mono.empty()).expectErrorMessage("foo").verify();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyTimeout.class)
|
||||
Duration testStepVerifierLastStepVerifyTimeout() {
|
||||
return StepVerifier.create(Mono.empty()).expectTimeout(Duration.ZERO).verify();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package tech.picnic.errorprone.bugpatterns;
|
||||
package tech.picnic.errorprone.refastertemplates;
|
||||
|
||||
import static com.google.common.collect.MoreCollectors.toOptional;
|
||||
|
||||
@@ -10,107 +10,158 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import reactor.test.publisher.PublisherProbe;
|
||||
import tech.picnic.errorprone.annotations.Template;
|
||||
import tech.picnic.errorprone.annotations.TemplateCollection;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxDeferredError;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxErrorSupplier;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxIdentity;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.FluxSwitchIfEmptyOfEmptyPublisher;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoCollectToOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoDeferredError;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoErrorSupplier;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoFlatMapToFlux;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoFlux;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoFromOptional;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoSwitchIfEmptyOfEmptyPublisher;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.MonoThenReturn;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.PublisherProbeEmpty;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierFromFlux;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierFromMono;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyComplete;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyError;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorClass;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorMatches;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorMessage;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyErrorSatisfies;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierLastStepVerifyTimeout;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierStepExpectNext;
|
||||
import tech.picnic.errorprone.refastertemplates.ReactorTemplates.StepVerifierStepExpectNextEmpty;
|
||||
|
||||
@TemplateCollection(ReactorTemplates.class)
|
||||
final class ReactorTemplatesTest implements RefasterTemplateTestCase {
|
||||
@Template(MonoFromOptional.class)
|
||||
ImmutableSet<Mono<Integer>> testMonoFromOptional() {
|
||||
return ImmutableSet.of(
|
||||
Mono.defer(() -> Mono.justOrEmpty(Optional.of(1))),
|
||||
Mono.defer(() -> Mono.justOrEmpty(Optional.of(2))));
|
||||
}
|
||||
|
||||
@Template(MonoDeferredError.class)
|
||||
Mono<Void> testMonoDeferredError() {
|
||||
return Mono.error(() -> new IllegalStateException());
|
||||
}
|
||||
|
||||
@Template(FluxDeferredError.class)
|
||||
Flux<Void> testFluxDeferredError() {
|
||||
return Flux.error(() -> new IllegalStateException());
|
||||
}
|
||||
|
||||
@Template(MonoErrorSupplier.class)
|
||||
Mono<Void> testMonoErrorSupplier() {
|
||||
return Mono.error(((Supplier<RuntimeException>) null));
|
||||
}
|
||||
|
||||
@Template(FluxErrorSupplier.class)
|
||||
Flux<Void> testFluxErrorSupplier() {
|
||||
return Flux.error(((Supplier<RuntimeException>) null));
|
||||
}
|
||||
|
||||
@Template(MonoThenReturn.class)
|
||||
Mono<String> testMonoThenReturn() {
|
||||
return Mono.empty().thenReturn("foo");
|
||||
}
|
||||
|
||||
@Template(MonoSwitchIfEmptyOfEmptyPublisher.class)
|
||||
Mono<Integer> testMonoSwitchIfEmptyOfEmptyPublisher() {
|
||||
return Mono.just(1);
|
||||
}
|
||||
|
||||
@Template(FluxSwitchIfEmptyOfEmptyPublisher.class)
|
||||
ImmutableSet<Flux<Integer>> testFluxSwitchIfEmptyOfEmptyPublisher() {
|
||||
return ImmutableSet.of(Flux.just(1), Flux.just(2));
|
||||
}
|
||||
|
||||
@Template(MonoFlatMapToFlux.class)
|
||||
Flux<String> testMonoFlatMapToFlux() {
|
||||
return Mono.just("foo").flatMap(s -> Mono.just(s + s)).flux();
|
||||
}
|
||||
|
||||
@Template(MonoFlux.class)
|
||||
Flux<String> testMonoFlux() {
|
||||
return Mono.just("foo").flux();
|
||||
}
|
||||
|
||||
@Template(FluxIdentity.class)
|
||||
Flux<String> testFluxIdentity() {
|
||||
return Flux.just("foo");
|
||||
}
|
||||
|
||||
@Template(MonoCollectToOptional.class)
|
||||
ImmutableSet<Mono<Optional<String>>> testMonoCollectToOptional() {
|
||||
return ImmutableSet.of(
|
||||
Mono.just("foo").flux().collect(toOptional()),
|
||||
Mono.just("bar").flux().collect(toOptional()));
|
||||
}
|
||||
|
||||
@Template(PublisherProbeEmpty.class)
|
||||
ImmutableSet<PublisherProbe<Void>> testPublisherProbeEmpty() {
|
||||
return ImmutableSet.of(PublisherProbe.empty(), PublisherProbe.empty());
|
||||
}
|
||||
|
||||
@Template(StepVerifierFromMono.class)
|
||||
StepVerifier.FirstStep<Integer> testStepVerifierFromMono() {
|
||||
return Mono.just(1).as(StepVerifier::create);
|
||||
}
|
||||
|
||||
@Template(StepVerifierFromFlux.class)
|
||||
StepVerifier.FirstStep<Integer> testStepVerifierFromFlux() {
|
||||
return Flux.just(1).as(StepVerifier::create);
|
||||
}
|
||||
|
||||
@Template(StepVerifierStepExpectNextEmpty.class)
|
||||
StepVerifier.Step<Integer> testStepVerifierStepExpectNextEmpty() {
|
||||
return StepVerifier.create(Mono.just(0));
|
||||
}
|
||||
|
||||
@Template(StepVerifierStepExpectNext.class)
|
||||
ImmutableSet<StepVerifier.Step<String>> testStepVerifierStepExpectNext() {
|
||||
return ImmutableSet.of(
|
||||
StepVerifier.create(Mono.just("foo")).expectNext("bar"),
|
||||
StepVerifier.create(Mono.just("baz")).expectNext("qux"));
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyComplete.class)
|
||||
Duration testStepVerifierLastStepVerifyComplete() {
|
||||
return StepVerifier.create(Mono.empty()).verifyComplete();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyError.class)
|
||||
Duration testStepVerifierLastStepVerifyError() {
|
||||
return StepVerifier.create(Mono.empty()).verifyError();
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorClass.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorClass() {
|
||||
return StepVerifier.create(Mono.empty()).verifyError(IllegalArgumentException.class);
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorMatches.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorMatches() {
|
||||
return StepVerifier.create(Mono.empty())
|
||||
.verifyErrorMatches(IllegalArgumentException.class::equals);
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorSatisfies.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorSatisfies() {
|
||||
return StepVerifier.create(Mono.empty()).verifyErrorSatisfies(t -> {});
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyErrorMessage.class)
|
||||
Duration testStepVerifierLastStepVerifyErrorMessage() {
|
||||
return StepVerifier.create(Mono.empty()).verifyErrorMessage("foo");
|
||||
}
|
||||
|
||||
@Template(StepVerifierLastStepVerifyTimeout.class)
|
||||
Duration testStepVerifierLastStepVerifyTimeout() {
|
||||
return StepVerifier.create(Mono.empty()).verifyTimeout(Duration.ZERO);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user