-
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.
Introduce utilities to validate Refaster template collections (#43)
The `Refaster` check is now located in the new `refaster-runner` Maven module. The new `refaster-test-support` module exposes `RefasterTemplateCollection#validate`, which for a given template collection validates: - That there exist corresponding `*Test{Input,Output}.java` files. - That each template is exercised by precisely one method in these files.
- Loading branch information
Showing
131 changed files
with
1,387 additions
and
281 deletions.
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
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
191 changes: 0 additions & 191 deletions
191
error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterTest.java
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
...contrib/src/test/java/tech/picnic/errorprone/refastertemplates/RefasterTemplatesTest.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,81 @@ | ||
package tech.picnic.errorprone.refastertemplates; | ||
|
||
import static java.util.function.Predicate.not; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import tech.picnic.errorprone.refaster.test.RefasterTemplateCollection; | ||
|
||
final class RefasterTemplatesTest { | ||
/** The names of all Refaster template groups defined in this module. */ | ||
private static final ImmutableSet<Class<?>> TEMPLATE_COLLECTIONS = | ||
ImmutableSet.of( | ||
AssertJTemplates.class, | ||
AssertJBigDecimalTemplates.class, | ||
AssertJBigIntegerTemplates.class, | ||
AssertJBooleanTemplates.class, | ||
AssertJByteTemplates.class, | ||
AssertJCharSequenceTemplates.class, | ||
AssertJDoubleTemplates.class, | ||
AssertJEnumerableTemplates.class, | ||
AssertJFloatTemplates.class, | ||
AssertJIntegerTemplates.class, | ||
AssertJLongTemplates.class, | ||
AssertJNumberTemplates.class, | ||
AssertJMapTemplates.class, | ||
AssertJObjectTemplates.class, | ||
AssertJOptionalTemplates.class, | ||
AssertJShortTemplates.class, | ||
AssertJStringTemplates.class, | ||
AssertJThrowingCallableTemplates.class, | ||
AssortedTemplates.class, | ||
BigDecimalTemplates.class, | ||
CollectionTemplates.class, | ||
ComparatorTemplates.class, | ||
DoubleStreamTemplates.class, | ||
EqualityTemplates.class, | ||
ImmutableListTemplates.class, | ||
ImmutableListMultimapTemplates.class, | ||
ImmutableMapTemplates.class, | ||
ImmutableMultisetTemplates.class, | ||
ImmutableSetTemplates.class, | ||
ImmutableSetMultimapTemplates.class, | ||
ImmutableSortedMapTemplates.class, | ||
ImmutableSortedMultisetTemplates.class, | ||
ImmutableSortedSetTemplates.class, | ||
IntStreamTemplates.class, | ||
JUnitTemplates.class, | ||
LongStreamTemplates.class, | ||
MapEntryTemplates.class, | ||
MockitoTemplates.class, | ||
MultimapTemplates.class, | ||
NullTemplates.class, | ||
OptionalTemplates.class, | ||
PrimitiveTemplates.class, | ||
ReactorTemplates.class, | ||
RxJava2AdapterTemplates.class, | ||
StreamTemplates.class, | ||
StringTemplates.class, | ||
TestNGToAssertJTemplates.class, | ||
TimeTemplates.class, | ||
WebClientTemplates.class); | ||
|
||
// XXX: Create a JUnit extension to automatically discover the template collections in a given | ||
// context to make sure the list is exhaustive. | ||
private static Stream<Arguments> validateTemplateCollectionTestCases() { | ||
// XXX: Drop the filter once we have added tests for AssertJ! We can then also replace this | ||
// method with `@ValueSource(classes = {...})`. | ||
return TEMPLATE_COLLECTIONS.stream() | ||
.filter(not(AssertJTemplates.class::equals)) | ||
.map(Arguments::arguments); | ||
} | ||
|
||
@MethodSource("validateTemplateCollectionTestCases") | ||
@ParameterizedTest | ||
void validateTemplateCollection(Class<?> clazz) { | ||
RefasterTemplateCollection.validate(clazz); | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.