Skip to content

Commit

Permalink
Fix whitespace across the project
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Feb 4, 2025
1 parent 3fb8be6 commit fad9d56
Show file tree
Hide file tree
Showing 19 changed files with 174 additions and 174 deletions.
134 changes: 68 additions & 66 deletions documentation/src/test/java/example/ParameterizedTestDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ void testWithMultiArgFieldSource(String str, int num, List<String> list) {
// tag::CsvSource_example[]
@ParameterizedTest
@CsvSource({
"apple, 1",
"banana, 2",
"apple, 1",
"banana, 2",
"'lemon, lime', 0xF1",
"strawberry, 700_000"
"strawberry, 700_000"
})
void testWithCsvSource(String fruit, int rank) {
assertNotNull(fruit);
Expand Down Expand Up @@ -497,75 +497,77 @@ void testWithExplicitJavaTimeConverter(
// @formatter:on

// @formatter:off
// tag::ArgumentsAccessor_example[]
@ParameterizedTest
@CsvSource({
"Jane, Doe, F, 1990-05-20",
"John, Doe, M, 1990-10-22"
})
void testWithArgumentsAccessor(ArgumentsAccessor arguments) {
Person person = new Person(arguments.getString(0),
arguments.getString(1),
arguments.get(2, Gender.class),
arguments.get(3, LocalDate.class));

if (person.getFirstName().equals("Jane")) {
assertEquals(Gender.F, person.getGender());
}
else {
assertEquals(Gender.M, person.getGender());
}
assertEquals("Doe", person.getLastName());
assertEquals(1990, person.getDateOfBirth().getYear());
}
// end::ArgumentsAccessor_example[]
// tag::ArgumentsAccessor_example[]
@ParameterizedTest
@CsvSource({
"Jane, Doe, F, 1990-05-20",
"John, Doe, M, 1990-10-22"
})
void testWithArgumentsAccessor(ArgumentsAccessor arguments) {
Person person = new Person(
arguments.getString(0),
arguments.getString(1),
arguments.get(2, Gender.class),
arguments.get(3, LocalDate.class));

if (person.getFirstName().equals("Jane")) {
assertEquals(Gender.F, person.getGender());
}
else {
assertEquals(Gender.M, person.getGender());
}
assertEquals("Doe", person.getLastName());
assertEquals(1990, person.getDateOfBirth().getYear());
}
// end::ArgumentsAccessor_example[]
// @formatter:on

// @formatter:off
// tag::ArgumentsAggregator_example[]
@ParameterizedTest
@CsvSource({
"Jane, Doe, F, 1990-05-20",
"John, Doe, M, 1990-10-22"
})
void testWithArgumentsAggregator(@AggregateWith(PersonAggregator.class) Person person) {
// perform assertions against person
}

// end::ArgumentsAggregator_example[]
static
// tag::ArgumentsAggregator_example_PersonAggregator[]
public class PersonAggregator implements ArgumentsAggregator {
@Override
public Person aggregateArguments(ArgumentsAccessor arguments, ParameterContext context) {
return new Person(arguments.getString(0),
arguments.getString(1),
arguments.get(2, Gender.class),
arguments.get(3, LocalDate.class));
}
}
// end::ArgumentsAggregator_example_PersonAggregator[]
// tag::ArgumentsAggregator_example[]
@ParameterizedTest
@CsvSource({
"Jane, Doe, F, 1990-05-20",
"John, Doe, M, 1990-10-22"
})
void testWithArgumentsAggregator(@AggregateWith(PersonAggregator.class) Person person) {
// perform assertions against person
}

// end::ArgumentsAggregator_example[]
static
// tag::ArgumentsAggregator_example_PersonAggregator[]
public class PersonAggregator implements ArgumentsAggregator {
@Override
public Person aggregateArguments(ArgumentsAccessor arguments, ParameterContext context) {
return new Person(
arguments.getString(0),
arguments.getString(1),
arguments.get(2, Gender.class),
arguments.get(3, LocalDate.class));
}
}
// end::ArgumentsAggregator_example_PersonAggregator[]
// @formatter:on

// @formatter:off
// tag::ArgumentsAggregator_with_custom_annotation_example[]
@ParameterizedTest
@CsvSource({
"Jane, Doe, F, 1990-05-20",
"John, Doe, M, 1990-10-22"
})
void testWithCustomAggregatorAnnotation(@CsvToPerson Person person) {
// perform assertions against person
}
// end::ArgumentsAggregator_with_custom_annotation_example[]

// tag::ArgumentsAggregator_with_custom_annotation_example_CsvToPerson[]
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@AggregateWith(PersonAggregator.class)
public @interface CsvToPerson {
}
// end::ArgumentsAggregator_with_custom_annotation_example_CsvToPerson[]
// tag::ArgumentsAggregator_with_custom_annotation_example[]
@ParameterizedTest
@CsvSource({
"Jane, Doe, F, 1990-05-20",
"John, Doe, M, 1990-10-22"
})
void testWithCustomAggregatorAnnotation(@CsvToPerson Person person) {
// perform assertions against person
}
// end::ArgumentsAggregator_with_custom_annotation_example[]

// tag::ArgumentsAggregator_with_custom_annotation_example_CsvToPerson[]
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@AggregateWith(PersonAggregator.class)
public @interface CsvToPerson {
}
// end::ArgumentsAggregator_with_custom_annotation_example_CsvToPerson[]
// @formatter:on

// tag::custom_display_names[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@
@ExtendWith(ThirdExecutedHandler.class)
class MultipleHandlersTestCase {

// Register handlers for @Test, @BeforeEach, @AfterEach only
@ExtendWith(SecondExecutedHandler.class)
@ExtendWith(FirstExecutedHandler.class)
@Test
void testMethod() {
}

// end::user_guide[]

static class FirstExecutedHandler implements TestExecutionExceptionHandler {
@Override
public void handleTestExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
throw ex;
}
}

static class SecondExecutedHandler implements LifecycleMethodExecutionExceptionHandler {
@Override
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
throw ex;
}
}

static class ThirdExecutedHandler implements LifecycleMethodExecutionExceptionHandler {
@Override
public void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
throw ex;
}
}
// Register handlers for @Test, @BeforeEach, @AfterEach only
@ExtendWith(SecondExecutedHandler.class)
@ExtendWith(FirstExecutedHandler.class)
@Test
void testMethod() {
}

// end::user_guide[]

static class FirstExecutedHandler implements TestExecutionExceptionHandler {
@Override
public void handleTestExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
throw ex;
}
}

static class SecondExecutedHandler implements LifecycleMethodExecutionExceptionHandler {
@Override
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
throw ex;
}
}

static class ThirdExecutedHandler implements LifecycleMethodExecutionExceptionHandler {
@Override
public void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
throw ex;
}
}
// tag::user_guide[]
}
// end::user_guide[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,37 @@
// tag::user_guide[]
class RecordStateOnErrorExtension implements LifecycleMethodExecutionExceptionHandler {

@Override
public void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during class setup");
throw ex;
}

@Override
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during test setup");
throw ex;
}

@Override
public void handleAfterEachMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during test cleanup");
throw ex;
}

@Override
public void handleAfterAllMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during class cleanup");
throw ex;
}
// end::user_guide[]

private void memoryDumpForFurtherInvestigation(String error) {

}
@Override
public void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during class setup");
throw ex;
}

@Override
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during test setup");
throw ex;
}

@Override
public void handleAfterEachMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during test cleanup");
throw ex;
}

@Override
public void handleAfterAllMethodExecutionException(ExtensionContext context, Throwable ex)
throws Throwable {
memoryDumpForFurtherInvestigation("Failure recorded during class cleanup");
throw ex;
}
// end::user_guide[]

private void memoryDumpForFurtherInvestigation(String error) {
}
// tag::user_guide[]
}
// end::user_guide[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public AssertionFailureBuilder actual(Object actual) {
* failure message.
*
* @param includeValuesInMessage whether to include the actual and expected
* values
* values
* @return this builder for method chaining
*/
public AssertionFailureBuilder includeValuesInMessage(boolean includeValuesInMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ public static void assertArrayEquals(Object[] expected, Object[] actual, Supplie
* iterators must return equal elements in the same order as each other. <strong>Note:</strong>
* this means that the iterables <em>do not</em> need to be of the same type. Example: <pre>{@code
* import static java.util.Arrays.asList;
* . . .
* ...
* Iterable<Integer> i0 = new ArrayList<>(asList(1, 2, 3));
* Iterable<Integer> i1 = new LinkedList<>(asList(1, 2, 3));
* assertIterableEquals(i0, i1); // Passes
Expand All @@ -1516,7 +1516,7 @@ public static void assertIterableEquals(Iterable<?> expected, Iterable<?> actual
* elements in the same order as each other. <strong>Note:</strong> this means that the iterables
* <em>do not</em> need to be of the same type. Example: <pre>{@code
* import static java.util.Arrays.asList;
* . . .
* ...
* Iterable<Integer> i0 = new ArrayList<>(asList(1, 2, 3));
* Iterable<Integer> i1 = new LinkedList<>(asList(1, 2, 3));
* assertIterableEquals(i0, i1); // Passes
Expand All @@ -1540,7 +1540,7 @@ public static void assertIterableEquals(Iterable<?> expected, Iterable<?> actual
* elements in the same order as each other. <strong>Note:</strong> this means that the iterables
* <em>do not</em> need to be of the same type. Example: <pre>{@code
* import static java.util.Arrays.asList;
* . . .
* ...
* Iterable<Integer> i0 = new ArrayList<>(asList(1, 2, 3));
* Iterable<Integer> i1 = new LinkedList<>(asList(1, 2, 3));
* assertIterableEquals(i0, i1); // Passes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ default void publishEntry(String value) {
* The file will be copied to the report output directory replacing any
* potentially existing file with the same name.
*
* @param file the file to be attached; never {@code null} or blank
* @param file the file to be attached; never {@code null} or blank
* @param mediaType the media type of the file; never {@code null}; use
* {@link MediaType#APPLICATION_OCTET_STREAM} if unknown
* {@link MediaType#APPLICATION_OCTET_STREAM} if unknown
* @since 5.12
*/
@API(status = EXPERIMENTAL, since = "5.12")
Expand Down Expand Up @@ -146,12 +146,11 @@ default void publishDirectory(Path directory) {
* The {@link Path} passed to the supplied action will be relative to the
* report output directory, but it's up to the action to write the file.
*
* @param name the name of the file to be attached; never {@code null}
* or blank and must not contain any path separators
* @param name the name of the file to be attached; never {@code null} or
* blank and must not contain any path separators
* @param mediaType the media type of the file; never {@code null}; use
* {@link MediaType#APPLICATION_OCTET_STREAM} if unknown
* @param action the action to be executed to write the file; never
* {@code null}
* {@link MediaType#APPLICATION_OCTET_STREAM} if unknown
* @param action the action to be executed to write the file; never {@code null}
* @since 5.12
*/
@API(status = EXPERIMENTAL, since = "5.12")
Expand All @@ -168,9 +167,8 @@ default void publishFile(String name, MediaType mediaType, ThrowingConsumer<Path
* to the action to write files to it.
*
* @param name the name of the directory to be attached; never {@code null}
* or blank and must not contain any path separators
* @param action the action to be executed to write the file; never
* {@code null}
* or blank and must not contain any path separators
* @param action the action to be executed to write the file; never {@code null}
* @since 5.12
*/
@API(status = EXPERIMENTAL, since = "5.12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ default void publishReportEntry(String value) {
* The file will be resolved in the report output directory prior to
* invoking the supplied action.
*
* @param name the name of the file to be attached; never {@code null}
* or blank and must not contain any path separators
* @param name the name of the file to be attached; never {@code null} or
* blank and must not contain any path separators
* @param mediaType the media type of the file; never {@code null}; use
* {@link MediaType#APPLICATION_OCTET_STREAM} if unknown
* @param action the action to be executed to write the file; never {@code null}
* {@link MediaType#APPLICATION_OCTET_STREAM} if unknown
* @param action the action to be executed to write the file; never {@code null}
* @since 5.12
* @see org.junit.platform.engine.EngineExecutionListener#fileEntryPublished
*/
Expand All @@ -392,8 +392,8 @@ default void publishReportEntry(String value) {
* The directory will be resolved and created in the report output directory
* prior to invoking the supplied action.
*
* @param name the name of the directory to be attached; never {@code null}
* or blank and must not contain any path separators
* @param name the name of the directory to be attached; never {@code null}
* or blank and must not contain any path separators
* @param action the action to be executed to write the file; never {@code null}
* @since 5.12
* @see org.junit.platform.engine.EngineExecutionListener#fileEntryPublished
Expand Down
Loading

0 comments on commit fad9d56

Please sign in to comment.