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

Refaster assertj migrations support descriptions with format args #926

Merged
merged 5 commits into from
Oct 2, 2019
Merged
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 @@ -21,24 +21,25 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Collection;

public final class AssertjCollectionHasSizeExactlyWithDescription<T> {

@BeforeTemplate
void bad1(Collection<T> things, int size, String description) {
assertThat(things.size() == size).describedAs(description).isTrue();
void bad1(Collection<T> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() == size).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void bad2(Collection<T> things, int size, String description) {
assertThat(things.size()).describedAs(description).isEqualTo(size);
void bad2(Collection<T> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isEqualTo(size);
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(Collection<T> things, int size, String description) {
assertThat(things).describedAs(description).hasSize(size);
void after(Collection<T> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).hasSize(size);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Collection;

public final class AssertjCollectionHasSizeGreaterThanWithDescription<T> {

@BeforeTemplate
void before1(Collection<T> things, int size, String description) {
assertThat(things.size() > size).describedAs(description).isTrue();
void before1(Collection<T> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() > size).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before2(Collection<T> things, int size, String description) {
assertThat(things.size()).describedAs(description).isGreaterThan(size);
void before2(Collection<T> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isGreaterThan(size);
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(Collection<T> things, int size, String description) {
assertThat(things).describedAs(description).hasSizeGreaterThan(size);
void after(Collection<T> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).hasSizeGreaterThan(size);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,35 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Collection;

public final class AssertjCollectionIsEmptyWithDescription<T> {

@BeforeTemplate
void bad1(Collection<T> things, String description) {
assertThat(things.size() == 0).describedAs(description).isTrue();
void bad1(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() == 0).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void bad2(Collection<T> things, String description) {
assertThat(things.isEmpty()).describedAs(description).isTrue();
void bad2(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.isEmpty()).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void bad3(Collection<T> things, String description) {
assertThat(things.size()).describedAs(description).isZero();
void bad3(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isZero();
}

@BeforeTemplate
void bad4(Collection<T> things, String description) {
assertThat(things.size()).describedAs(description).isEqualTo(0);
void bad4(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isEqualTo(0);
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(Iterable<T> things, String description) {
assertThat(things).describedAs(description).isEmpty();
void after(Iterable<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,60 +23,61 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Collection;
import java.util.Collections;

public final class AssertjCollectionIsNotEmptyWithDescription<T> {

@BeforeTemplate
void bad1(Collection<T> things, String description) {
assertThat(things.size() != 0).describedAs(description).isTrue();
void bad1(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() != 0).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void bad2(Collection<T> things, String description) {
assertThat(things.size() == 0).describedAs(description).isFalse();
void bad2(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() == 0).describedAs(description, descriptionArgs).isFalse();
}

@BeforeTemplate
void bad3(Collection<T> things, String description) {
assertThat(things.size()).describedAs(description).isNotEqualTo(0);
void bad3(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isNotEqualTo(0);
}

@BeforeTemplate
void bad4(Collection<T> things, String description) {
assertThat(things.isEmpty()).describedAs(description).isFalse();
void bad4(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.isEmpty()).describedAs(description, descriptionArgs).isFalse();
}

@BeforeTemplate
void bad5(Collection<T> things, String description) {
assertThat(!things.isEmpty()).describedAs(description).isTrue();
void bad5(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(!things.isEmpty()).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void bad6(Collection<T> things, String description) {
assertThat(things).describedAs(description).isNotEqualTo(Collections.emptyList());
void bad6(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(Collections.emptyList());
}

@BeforeTemplate
void bad7(Collection<T> things, String description) {
assertThat(things).describedAs(description).isNotEqualTo(Collections.emptySet());
void bad7(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(Collections.emptySet());
}

@BeforeTemplate
void bad8(Collection<T> things, String description) {
assertThat(things).describedAs(description).isNotEqualTo(ImmutableList.of());
void bad8(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(ImmutableList.of());
}

@BeforeTemplate
void bad9(Collection<T> things, String description) {
assertThat(things).describedAs(description).isNotEqualTo(ImmutableSet.of());
void bad9(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(ImmutableSet.of());
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(Collection<T> things, String description) {
assertThat(things).describedAs(description).isNotEmpty();
void after(Collection<T> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isNotEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Objects;

Expand All @@ -31,28 +32,28 @@
public final class AssertjEqualsWithDescription<T> {

@BeforeTemplate
void before1(T expected, T actual, String description) {
assertThat(actual.equals(expected)).describedAs(description).isTrue();
void before1(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(actual.equals(expected)).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before2(T expected, T actual, String description) {
assertThat(Objects.equals(actual, expected)).describedAs(description).isTrue();
void before2(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(Objects.equals(actual, expected)).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before3(T expected, T actual, String description) {
assertThat(!actual.equals(expected)).describedAs(description).isFalse();
void before3(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(!actual.equals(expected)).describedAs(description, descriptionArgs).isFalse();
}

@BeforeTemplate
void before4(T expected, T actual, String description) {
assertThat(!Objects.equals(actual, expected)).describedAs(description).isFalse();
void before4(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(!Objects.equals(actual, expected)).describedAs(description, descriptionArgs).isFalse();
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(T expected, T actual, String description) {
assertThat(actual).describedAs(description).isEqualTo(expected);
void after(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(actual).describedAs(description, descriptionArgs).isEqualTo(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@
import com.google.errorprone.refaster.Refaster;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;

public final class AssertjInstanceOfWithDescription<T, E> {

@BeforeTemplate
void before(T input, String description) {
assertThat(Refaster.<E>isInstance(input)).describedAs(description).isTrue();
void before(T input, String description, @Repeated Object descriptionArgs) {
assertThat(Refaster.<E>isInstance(input)).describedAs(description, descriptionArgs).isTrue();
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(T input, String description) {
assertThat(input).describedAs(description).isInstanceOf(Refaster.<E>clazz());
void after(T input, String description, @Repeated Object descriptionArgs) {
assertThat(input).describedAs(description, descriptionArgs).isInstanceOf(Refaster.<E>clazz());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Map;

public final class AssertjMapHasSizeExactlyWithDescription<K, V> {

@BeforeTemplate
void before1(Map<K, V> things, int size, String description) {
assertThat(things.size() == size).describedAs(description).isTrue();
void before1(Map<K, V> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() == size).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before2(Map<K, V> things, int size, String description) {
assertThat(things.size()).describedAs(description).isEqualTo(size);
void before2(Map<K, V> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isEqualTo(size);
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(Map<K, V> things, int size, String description) {
assertThat(things).describedAs(description).hasSize(size);
void after(Map<K, V> things, int size, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).hasSize(size);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,40 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Map;

public final class AssertjMapIsEmptyWithDescription<K, V> {

@BeforeTemplate
void before1(Map<K, V> things, String description) {
assertThat(things.size() == 0).describedAs(description).isTrue();
void before1(Map<K, V> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size() == 0).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before2(Map<K, V> things, String description) {
assertThat(things.isEmpty()).describedAs(description).isTrue();
void before2(Map<K, V> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.isEmpty()).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before3(Map<K, V> things, String description) {
assertThat(things.size()).describedAs(description).isZero();
void before3(Map<K, V> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isZero();
}

@BeforeTemplate
void before4(Map<K, V> things, String description) {
assertThat(things.size()).describedAs(description).isEqualTo(0);
void before4(Map<K, V> things, String description, @Repeated Object descriptionArgs) {
assertThat(things.size()).describedAs(description, descriptionArgs).isEqualTo(0);
}

@BeforeTemplate
void before5(Map<K, V> things, String description) {
assertThat(things).describedAs(description).hasSize(0);
void before5(Map<K, V> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).hasSize(0);
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(Map<K, V> things, String description) {
assertThat(things).describedAs(description).isEmpty();
void after(Map<K, V> things, String description, @Repeated Object descriptionArgs) {
assertThat(things).describedAs(description, descriptionArgs).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.errorprone.refaster.ImportPolicy;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;
import java.util.Objects;

Expand All @@ -31,28 +32,28 @@
public final class AssertjNotEqualsWithDescription<T> {

@BeforeTemplate
void before1(T expected, T actual, String description) {
assertThat(!actual.equals(expected)).describedAs(description).isTrue();
void before1(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(!actual.equals(expected)).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before2(T expected, T actual, String description) {
assertThat(!Objects.equals(actual, expected)).describedAs(description).isTrue();
void before2(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(!Objects.equals(actual, expected)).describedAs(description, descriptionArgs).isTrue();
}

@BeforeTemplate
void before3(T expected, T actual, String description) {
assertThat(actual.equals(expected)).describedAs(description).isFalse();
void before3(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(actual.equals(expected)).describedAs(description, descriptionArgs).isFalse();
}

@BeforeTemplate
void before4(T expected, T actual, String description) {
assertThat(Objects.equals(actual, expected)).describedAs(description).isFalse();
void before4(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(Objects.equals(actual, expected)).describedAs(description, descriptionArgs).isFalse();
}

@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(T expected, T actual, String description) {
assertThat(actual).describedAs(description).isNotEqualTo(expected);
void after(T expected, T actual, String description, @Repeated Object descriptionArgs) {
assertThat(actual).describedAs(description, descriptionArgs).isNotEqualTo(expected);
}
}
Loading