-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/JUnitTemplates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tech.picnic.errorprone.refastertemplates; | ||
|
||
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
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 org.junit.jupiter.params.provider.Arguments; | ||
|
||
/** Refaster templates related to JUnit expressions and statements. */ | ||
final class JUnitTemplates { | ||
private JUnitTemplates() {} | ||
|
||
/** Prefer statically imported {@link Arguments#arguments} over {@link Arguments#of} calls. */ | ||
static final class ArgumentsEnumeration<T> { | ||
@BeforeTemplate | ||
Arguments before(@Repeated T objects) { | ||
return Arguments.of(objects); | ||
} | ||
|
||
@AfterTemplate | ||
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) | ||
Arguments after(@Repeated T objects) { | ||
return arguments(objects); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ontrib/src/test/resources/tech/picnic/errorprone/bugpatterns/JUnitTemplatesTestInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package tech.picnic.errorprone.bugpatterns; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
|
||
final class JUnitTemplatesTest implements RefasterTemplateTestCase { | ||
ImmutableSet<Arguments> testArgumentsEnumeration() { | ||
return ImmutableSet.of( | ||
Arguments.of("foo"), Arguments.of(1, "foo", 2, "bar"), Arguments.of(new Object())); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ntrib/src/test/resources/tech/picnic/errorprone/bugpatterns/JUnitTemplatesTestOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tech.picnic.errorprone.bugpatterns; | ||
|
||
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
|
||
final class JUnitTemplatesTest implements RefasterTemplateTestCase { | ||
ImmutableSet<Arguments> testArgumentsEnumeration() { | ||
return ImmutableSet.of( | ||
arguments("foo"), arguments(1, "foo", 2, "bar"), arguments(new Object())); | ||
} | ||
} |