Skip to content

Commit

Permalink
Improve naming of Refaster templates and associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Jan 6, 2022
1 parent c163806 commit 07a25cf
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class AssertJNumberTemplates {
private AssertJNumberTemplates() {}

static final class NumberIsPositive {
static final class NumberAssertIsPositive {
@BeforeTemplate
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
return Refaster.anyOf(
Expand Down Expand Up @@ -69,7 +69,7 @@ AbstractBigDecimalAssert<?> before(AbstractBigDecimalAssert<?> numberAssert) {
}
}

static final class NumberIsNotPositive {
static final class NumberAssertIsNotPositive {
@BeforeTemplate
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
return Refaster.anyOf(
Expand Down Expand Up @@ -120,7 +120,7 @@ AbstractBigDecimalAssert<?> before(AbstractBigDecimalAssert<?> numberAssert) {
}
}

static final class NumberIsNegative {
static final class NumberAssertIsNegative {
@BeforeTemplate
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
return Refaster.anyOf(
Expand Down Expand Up @@ -171,7 +171,7 @@ AbstractBigDecimalAssert<?> before(AbstractBigDecimalAssert<?> numberAssert) {
}
}

static final class NumberIsNotNegative {
static final class NumberAssertIsNotNegative {
@BeforeTemplate
AbstractByteAssert<?> before(AbstractByteAssert<?> numberAssert) {
return Refaster.anyOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static final class AssertThatMultisetsAreEqual<S, T extends S> {
// Map
//

static final class AssertThatMapIsEmpty<K, V> {
static final class AbstractMapAssertIsEmpty<K, V> {
@BeforeTemplate
@SuppressWarnings("unchecked")
void before(AbstractMapAssert<?, ?, K, V> mapAssert) {
Expand Down Expand Up @@ -615,8 +615,7 @@ void after(AbstractMapAssert<?, ?, K, V> mapAssert) {
}
}

// 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(
Expand All @@ -638,7 +637,7 @@ void after(Map<K, V> map) {
}
}

static final class AssertThatMapIsNotEmpty<K, V> {
static final class AbstractMapAssertIsNotEmpty<K, V> {
@BeforeTemplate
AbstractMapAssert<?, ?, K, V> before(AbstractMapAssert<?, ?, K, V> mapAssert) {
return mapAssert.isNotEqualTo(
Expand All @@ -657,8 +656,7 @@ static final class AssertThatMapIsNotEmpty<K, V> {
}
}

// 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ ImmutableList<T> after(ImmutableCollection<T> collection) {
* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ OptionalDouble after(DoubleStream stream) {
}

/** Prefer {@link DoubleStream#noneMatch(DoublePredicate)} over more contrived alternatives. */
static final class DoubleStreamNoneMatch {
static final class DoubleStreamNoneMatchDoublePredicate {
@BeforeTemplate
boolean before(DoubleStream stream, DoublePredicate predicate) {
return Refaster.anyOf(
Expand All @@ -201,7 +201,7 @@ boolean after(DoubleStream stream, DoublePredicate predicate) {
}
}

abstract static class DoubleStreamNoneMatch2 {
abstract static class DoubleStreamNoneMatch {
@Placeholder
abstract boolean test(@MayOptionallyUse double element);

Expand Down Expand Up @@ -230,7 +230,7 @@ boolean after(DoubleStream stream, DoublePredicate predicate) {
}
}

static final class DoubleStreamAllMatch {
static final class DoubleStreamAllMatchDoublePredicate {
@BeforeTemplate
boolean before(DoubleStream stream, DoublePredicate predicate) {
return stream.noneMatch(predicate.negate());
Expand All @@ -242,7 +242,7 @@ boolean after(DoubleStream stream, DoublePredicate predicate) {
}
}

abstract static class DoubleStreamAllMatch2 {
abstract static class DoubleStreamAllMatch {
@Placeholder
abstract boolean test(@MayOptionallyUse double element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ ImmutableListMultimap<K, V> after(
* 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);

Expand All @@ -227,7 +227,7 @@ ImmutableListMultimap<K, V2> after(Multimap<K, V1> multimap) {
* 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ImmutableSetMultimap<K, V> after(
* 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);

Expand All @@ -148,7 +148,7 @@ ImmutableSetMultimap<K, V> after(Stream<E> stream) {
* 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);

Expand All @@ -170,7 +170,7 @@ ImmutableSetMultimap<K, V2> after(Multimap<K, V1> multimap) {
* 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ OptionalInt after(IntStream stream) {
}

/** Prefer {@link IntStream#noneMatch(IntPredicate)} over more contrived alternatives. */
static final class IntStreamNoneMatch {
static final class IntStreamNoneMatchIntPredicate {
@BeforeTemplate
boolean before(IntStream stream, IntPredicate predicate) {
return Refaster.anyOf(
Expand All @@ -214,7 +214,7 @@ boolean after(IntStream stream, IntPredicate predicate) {
}
}

abstract static class IntStreamNoneMatch2 {
abstract static class IntStreamNoneMatch {
@Placeholder
abstract boolean test(@MayOptionallyUse int element);

Expand Down Expand Up @@ -243,7 +243,7 @@ boolean after(IntStream stream, IntPredicate predicate) {
}
}

static final class IntStreamAllMatch {
static final class IntStreamAllMatchIntPredicate {
@BeforeTemplate
boolean before(IntStream stream, IntPredicate predicate) {
return stream.noneMatch(predicate.negate());
Expand All @@ -255,7 +255,7 @@ boolean after(IntStream stream, IntPredicate predicate) {
}
}

abstract static class IntStreamAllMatch2 {
abstract static class IntStreamAllMatch {
@Placeholder
abstract boolean test(@MayOptionallyUse int element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ OptionalLong after(LongStream stream) {
}

/** Prefer {@link LongStream#noneMatch(LongPredicate)} over more contrived alternatives. */
static final class LongStreamNoneMatch {
static final class LongStreamNoneMatchLongPredicate {
@BeforeTemplate
boolean before(LongStream stream, LongPredicate predicate) {
return Refaster.anyOf(
Expand All @@ -214,7 +214,7 @@ boolean after(LongStream stream, LongPredicate predicate) {
}
}

abstract static class LongStreamNoneMatch2 {
abstract static class LongStreamNoneMatch {
@Placeholder
abstract boolean test(@MayOptionallyUse long element);

Expand Down Expand Up @@ -243,7 +243,7 @@ boolean after(LongStream stream, LongPredicate predicate) {
}
}

static final class LongStreamAllMatch {
static final class LongStreamAllMatchLongPredicate {
@BeforeTemplate
boolean before(LongStream stream, LongPredicate predicate) {
return stream.noneMatch(predicate.negate());
Expand All @@ -255,7 +255,7 @@ boolean after(LongStream stream, LongPredicate predicate) {
}
}

abstract static class LongStreamAllMatch2 {
abstract static class LongStreamAllMatch {
@Placeholder
abstract boolean test(@MayOptionallyUse long element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Optional<T> after(Stream<T> stream) {
}

/** Prefer {@link Stream#noneMatch(Predicate)} over more contrived alternatives. */
static final class StreamNoneMatch<T> {
static final class StreamNoneMatchPredicate<T> {
@BeforeTemplate
boolean before(Stream<T> stream, Predicate<? super T> predicate) {
return Refaster.anyOf(
Expand All @@ -264,7 +264,7 @@ boolean after(Stream<T> stream, Predicate<? super T> predicate) {
}
}

abstract static class StreamNoneMatch2<T> {
abstract static class StreamNoneMatch<T> {
@Placeholder(allowsIdentity = true)
abstract boolean test(@MayOptionallyUse T element);

Expand Down Expand Up @@ -293,7 +293,7 @@ boolean after(Stream<T> stream, Predicate<? super T> predicate) {
}
}

static final class StreamAllMatch<T> {
static final class StreamAllMatchPredicate<T> {
@BeforeTemplate
boolean before(Stream<T> stream, Predicate<? super T> predicate) {
return stream.noneMatch(Refaster.anyOf(not(predicate), predicate.negate()));
Expand All @@ -305,7 +305,7 @@ boolean after(Stream<T> stream, Predicate<? super T> predicate) {
}
}

abstract static class StreamAllMatch2<T> {
abstract static class StreamAllMatch<T> {
@Placeholder(allowsIdentity = true)
abstract boolean test(@MayOptionallyUse T element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.google.common.collect.Iterables;
import org.assertj.core.api.EnumerableAssert;

final class AssertJEnumableTemplatesTest implements RefasterTemplateTestCase {
final class AssertJEnumerableTemplatesTest implements RefasterTemplateTestCase {
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(Iterables.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.google.common.collect.Iterables;
import org.assertj.core.api.EnumerableAssert;

final class AssertJEnumableTemplatesTest implements RefasterTemplateTestCase {
final class AssertJEnumerableTemplatesTest implements RefasterTemplateTestCase {
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(Iterables.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.assertj.core.api.NumberAssert;

final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsPositive() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsPositive() {
return ImmutableSet.of(
assertThat((byte) 0).isGreaterThan((byte) 0),
assertThat((byte) 0).isGreaterThanOrEqualTo((byte) 1),
Expand All @@ -25,7 +25,7 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
assertThat(BigDecimal.ZERO).isGreaterThan(BigDecimal.ZERO));
}

ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotPositive() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotPositive() {
return ImmutableSet.of(
assertThat((byte) 0).isLessThanOrEqualTo((byte) 0),
assertThat((byte) 0).isLessThan((byte) 1),
Expand All @@ -42,7 +42,7 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
assertThat(BigDecimal.ZERO).isLessThanOrEqualTo(BigDecimal.ZERO));
}

ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNegative() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNegative() {
return ImmutableSet.of(
assertThat((byte) 0).isLessThan((byte) 0),
assertThat((byte) 0).isLessThanOrEqualTo((byte) -1),
Expand All @@ -59,7 +59,7 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
assertThat(BigDecimal.ZERO).isLessThan(BigDecimal.ZERO));
}

ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotNegative() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotNegative() {
return ImmutableSet.of(
assertThat((byte) 0).isGreaterThanOrEqualTo((byte) 0),
assertThat((byte) 0).isGreaterThan((byte) -1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.assertj.core.api.NumberAssert;

final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsPositive() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsPositive() {
return ImmutableSet.of(
assertThat((byte) 0).isPositive(),
assertThat((byte) 0).isPositive(),
Expand All @@ -25,7 +25,7 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
assertThat(BigDecimal.ZERO).isPositive());
}

ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotPositive() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotPositive() {
return ImmutableSet.of(
assertThat((byte) 0).isNotPositive(),
assertThat((byte) 0).isNotPositive(),
Expand All @@ -42,7 +42,7 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
assertThat(BigDecimal.ZERO).isNotPositive());
}

ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNegative() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNegative() {
return ImmutableSet.of(
assertThat((byte) 0).isNegative(),
assertThat((byte) 0).isNegative(),
Expand All @@ -59,7 +59,7 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
assertThat(BigDecimal.ZERO).isNegative());
}

ImmutableSet<NumberAssert<?, ?>> testAbstractIntegerAssertIsNotNegative() {
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotNegative() {
return ImmutableSet.of(
assertThat((byte) 0).isNotNegative(),
assertThat((byte) 0).isNotNegative(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ OptionalDouble testDoubleStreamMin() {
return DoubleStream.of(1).sorted().findFirst();
}

ImmutableSet<Boolean> testDoubleStreamNoneMatch() {
ImmutableSet<Boolean> testDoubleStreamNoneMatchDoublePredicate() {
DoublePredicate pred = i -> i > 0;
return ImmutableSet.of(
!DoubleStream.of(1).anyMatch(n -> n > 1),
DoubleStream.of(2).allMatch(pred.negate()),
DoubleStream.of(3).filter(pred).findAny().isEmpty());
}

boolean testDoubleStreamNoneMatch2() {
boolean testDoubleStreamNoneMatch() {
return DoubleStream.of(1).allMatch(n -> !(n > 1));
}

Expand All @@ -83,12 +83,12 @@ ImmutableSet<Boolean> testDoubleStreamAnyMatch() {
DoubleStream.of(2).filter(n -> n > 2).findAny().isPresent());
}

boolean testDoubleStreamAllMatch() {
boolean testDoubleStreamAllMatchDoublePredicate() {
DoublePredicate pred = i -> i > 0;
return DoubleStream.of(1).noneMatch(pred.negate());
}

boolean testDoubleStreamAllMatch2() {
boolean testDoubleStreamAllMatch() {
return DoubleStream.of(1).noneMatch(n -> !(n > 1));
}
}
Loading

0 comments on commit 07a25cf

Please sign in to comment.