Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend EnumerableAssertHasSize* Refaster rules #1512

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ AbstractIntegerAssert<?> before(AbstractIterableAssert<?, ?, E, ?> enumAssert) {
return Refaster.anyOf(enumAssert.size().isNotEqualTo(0), enumAssert.size().isPositive());
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(AbstractIterableAssert<?, ?, E, ?> enumAssert) {
return Refaster.anyOf(
enumAssert.size().isNotEqualTo(0).returnToIterable(),
enumAssert.size().isPositive().returnToIterable());
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert) {
return enumAssert.isNotEmpty();
Expand All @@ -60,6 +67,12 @@ static final class EnumerableAssertHasSize<E> {
return enumAssert.size().isEqualTo(size);
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(
AbstractIterableAssert<?, ?, E, ?> enumAssert, int size) {
return enumAssert.size().isEqualTo(size).returnToIterable();
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert, int size) {
return enumAssert.hasSize(size);
Expand All @@ -73,6 +86,12 @@ static final class EnumerableAssertHasSizeLessThan<E> {
return enumAssert.size().isLessThan(size);
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(
AbstractIterableAssert<?, ?, E, ?> enumAssert, int size) {
return enumAssert.size().isLessThan(size).returnToIterable();
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert, int size) {
return enumAssert.hasSizeLessThan(size);
Expand All @@ -86,6 +105,12 @@ static final class EnumerableAssertHasSizeLessThanOrEqualTo<E> {
return enumAssert.size().isLessThanOrEqualTo(size);
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(
AbstractIterableAssert<?, ?, E, ?> enumAssert, int size) {
return enumAssert.size().isLessThanOrEqualTo(size).returnToIterable();
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert, int size) {
return enumAssert.hasSizeLessThanOrEqualTo(size);
Expand All @@ -99,6 +124,12 @@ static final class EnumerableAssertHasSizeGreaterThan<E> {
return enumAssert.size().isGreaterThan(size);
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(
AbstractIterableAssert<?, ?, E, ?> enumAssert, int size) {
return enumAssert.size().isGreaterThan(size).returnToIterable();
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert, int size) {
return enumAssert.hasSizeGreaterThan(size);
Expand All @@ -112,6 +143,12 @@ static final class EnumerableAssertHasSizeGreaterThanOrEqualTo<E> {
return enumAssert.size().isGreaterThanOrEqualTo(size);
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(
AbstractIterableAssert<?, ?, E, ?> enumAssert, int size) {
return enumAssert.size().isGreaterThanOrEqualTo(size).returnToIterable();
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert, int size) {
return enumAssert.hasSizeGreaterThanOrEqualTo(size);
Expand All @@ -125,6 +162,12 @@ static final class EnumerableAssertHasSizeBetween<E> {
return enumAssert.size().isBetween(lower, upper);
}

@BeforeTemplate
AbstractIterableAssert<?, ?, E, ?> before2(
AbstractIterableAssert<?, ?, E, ?> enumAssert, int lower, int upper) {
return enumAssert.size().isBetween(lower, upper).returnToIterable();
}

@AfterTemplate
EnumerableAssert<?, E> after(EnumerableAssert<?, E> enumAssert, int lower, int upper) {
return enumAssert.hasSizeBetween(lower, upper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,45 @@ void testEnumerableAssertIsEmpty() {
assertThat(ImmutableSet.of(1)).hasSizeGreaterThan(0),
assertThat(ImmutableSet.of(2)).hasSizeGreaterThanOrEqualTo(1),
assertThat(ImmutableSet.of(3)).size().isNotEqualTo(0),
assertThat(ImmutableSet.of(4)).size().isPositive());
assertThat(ImmutableSet.of(4)).size().isPositive(),
assertThat(ImmutableSet.of(5)).size().isNotEqualTo(0).returnToIterable(),
assertThat(ImmutableSet.of(6)).size().isPositive().returnToIterable());
}

AbstractAssert<?, ?> testEnumerableAssertHasSize() {
return assertThat(ImmutableSet.of(1)).size().isEqualTo(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSize() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).size().isEqualTo(2),
assertThat(ImmutableSet.of(3)).size().isEqualTo(4).returnToIterable());
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeLessThan() {
return assertThat(ImmutableSet.of(1)).size().isLessThan(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeLessThan() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).size().isLessThan(2),
assertThat(ImmutableSet.of(3)).size().isLessThan(4).returnToIterable());
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeLessThanOrEqualTo() {
return assertThat(ImmutableSet.of(1)).size().isLessThanOrEqualTo(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeLessThanOrEqualTo() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).size().isLessThanOrEqualTo(2),
assertThat(ImmutableSet.of(3)).size().isLessThanOrEqualTo(4).returnToIterable());
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeGreaterThan() {
return assertThat(ImmutableSet.of(1)).size().isGreaterThan(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeGreaterThan() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).size().isGreaterThan(2),
assertThat(ImmutableSet.of(3)).size().isGreaterThan(4).returnToIterable());
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeGreaterThanOrEqualTo() {
return assertThat(ImmutableSet.of(1)).size().isGreaterThanOrEqualTo(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeGreaterThanOrEqualTo() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).size().isGreaterThanOrEqualTo(2),
assertThat(ImmutableSet.of(3)).size().isGreaterThanOrEqualTo(4).returnToIterable());
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeBetween() {
return assertThat(ImmutableSet.of(1)).size().isBetween(2, 3);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeBetween() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).size().isBetween(2, 3),
assertThat(ImmutableSet.of(4)).size().isBetween(5, 6).returnToIterable());
}

ImmutableSet<EnumerableAssert<?, Integer>> testEnumerableAssertHasSameSizeAs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,44 @@ void testEnumerableAssertIsEmpty() {
assertThat(ImmutableSet.of(1)).isNotEmpty(),
assertThat(ImmutableSet.of(2)).isNotEmpty(),
assertThat(ImmutableSet.of(3)).isNotEmpty(),
assertThat(ImmutableSet.of(4)).isNotEmpty());
assertThat(ImmutableSet.of(4)).isNotEmpty(),
assertThat(ImmutableSet.of(5)).isNotEmpty(),
assertThat(ImmutableSet.of(6)).isNotEmpty());
}

AbstractAssert<?, ?> testEnumerableAssertHasSize() {
return assertThat(ImmutableSet.of(1)).hasSize(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSize() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).hasSize(2), assertThat(ImmutableSet.of(3)).hasSize(4));
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeLessThan() {
return assertThat(ImmutableSet.of(1)).hasSizeLessThan(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeLessThan() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).hasSizeLessThan(2),
assertThat(ImmutableSet.of(3)).hasSizeLessThan(4));
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeLessThanOrEqualTo() {
return assertThat(ImmutableSet.of(1)).hasSizeLessThanOrEqualTo(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeLessThanOrEqualTo() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).hasSizeLessThanOrEqualTo(2),
assertThat(ImmutableSet.of(3)).hasSizeLessThanOrEqualTo(4));
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeGreaterThan() {
return assertThat(ImmutableSet.of(1)).hasSizeGreaterThan(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeGreaterThan() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).hasSizeGreaterThan(2),
assertThat(ImmutableSet.of(3)).hasSizeGreaterThan(4));
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeGreaterThanOrEqualTo() {
return assertThat(ImmutableSet.of(1)).hasSizeGreaterThanOrEqualTo(2);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeGreaterThanOrEqualTo() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).hasSizeGreaterThanOrEqualTo(2),
assertThat(ImmutableSet.of(3)).hasSizeGreaterThanOrEqualTo(4));
}

AbstractAssert<?, ?> testEnumerableAssertHasSizeBetween() {
return assertThat(ImmutableSet.of(1)).hasSizeBetween(2, 3);
ImmutableSet<AbstractAssert<?, ?>> testEnumerableAssertHasSizeBetween() {
return ImmutableSet.of(
assertThat(ImmutableSet.of(1)).hasSizeBetween(2, 3),
assertThat(ImmutableSet.of(4)).hasSizeBetween(5, 6));
}

ImmutableSet<EnumerableAssert<?, Integer>> testEnumerableAssertHasSameSizeAs() {
Expand Down