Skip to content

Commit 6c69384

Browse files
committed
Improve Javadoc for @ClassTemplate, ParameterDeclarations, etc.
Closes #5165
1 parent 4df789e commit 6c69384

File tree

10 files changed

+69
-78
lines changed

10 files changed

+69
-78
lines changed

junit-jupiter-api/src/main/java/org/junit/jupiter/api/ClassTemplate.java

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,25 @@
2020
import java.lang.annotation.Target;
2121

2222
import org.apiguardian.api.API;
23-
import org.junit.jupiter.api.extension.AfterClassTemplateInvocationCallback;
24-
import org.junit.jupiter.api.extension.BeforeClassTemplateInvocationCallback;
25-
import org.junit.jupiter.api.extension.ClassTemplateInvocationContext;
26-
import org.junit.jupiter.api.extension.ClassTemplateInvocationContextProvider;
2723
import org.junit.platform.commons.annotation.Testable;
2824

2925
/**
3026
* {@code @ClassTemplate} is used to signal that the annotated class is a
3127
* <em>class template</em>.
3228
*
3329
* <p>In contrast to regular test classes, a class template is not directly
34-
* a test class but rather a template for a set of test cases. As such, it is
30+
* a test class but rather a template for a set of test classes. As such, it is
3531
* designed to be invoked multiple times depending on the number of {@linkplain
36-
* ClassTemplateInvocationContext invocation
37-
* contexts} returned by the registered {@linkplain
38-
* ClassTemplateInvocationContextProvider
39-
* providers}. Must be used together with at least one provider. Otherwise,
40-
* execution will fail.
32+
* org.junit.jupiter.api.extension.ClassTemplateInvocationContext invocation contexts}
33+
* returned by the registered {@linkplain
34+
* org.junit.jupiter.api.extension.ClassTemplateInvocationContextProvider providers}.
35+
* Must be used together with at least one provider. Otherwise, execution will fail.
4136
*
42-
* <p>Each invocation of a class template method behaves like the execution
43-
* of a regular test class with full support for the same lifecycle callbacks
44-
* and extensions.
37+
* <p>Each invocation of a class template behaves like the execution of a regular
38+
* test class with full support for the same lifecycle callbacks and extensions.
4539
*
46-
* <p>{@code @ClassTemplate} may be combined with {@link Nested @Nested} and
47-
* a class template may contain regular nested test classes or nested
48-
* class templates.
40+
* <p>{@code @ClassTemplate} may be combined with {@link Nested @Nested}, and a
41+
* class template may contain regular nested test classes or nested class templates.
4942
*
5043
* <p>{@code @ClassTemplate} may also be used as a meta-annotation in order
5144
* to create a custom <em>composed annotation</em> that inherits the semantics
@@ -56,11 +49,11 @@
5649
* <p>This annotation is inherited by subclasses.
5750
*
5851
* @since 5.13
59-
* @see TestTemplate
60-
* @see ClassTemplateInvocationContext
61-
* @see ClassTemplateInvocationContextProvider
62-
* @see BeforeClassTemplateInvocationCallback
63-
* @see AfterClassTemplateInvocationCallback
52+
* @see TestTemplate @TestTemplate
53+
* @see org.junit.jupiter.api.extension.ClassTemplateInvocationContext ClassTemplateInvocationContext
54+
* @see org.junit.jupiter.api.extension.ClassTemplateInvocationContextProvider ClassTemplateInvocationContextProvider
55+
* @see org.junit.jupiter.api.extension.BeforeClassTemplateInvocationCallback BeforeClassTemplateInvocationCallback
56+
* @see org.junit.jupiter.api.extension.AfterClassTemplateInvocationCallback AfterClassTemplateInvocationCallback
6457
*/
6558
@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
6659
@Retention(RetentionPolicy.RUNTIME)

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/AfterClassTemplateInvocationCallback.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* {@code AfterClassTemplateInvocationCallback} defines the API for
2020
* {@link Extension Extensions} that wish to provide additional behavior
21-
* <strong>once</strong> before each invocation of a
21+
* <strong>once</strong> after each invocation of a
2222
* {@link ClassTemplate @ClassTemplate}.
2323
*
2424
* <p>Concrete implementations often implement
@@ -34,7 +34,7 @@
3434
* <p>JUnit Jupiter guarantees <em>wrapping behavior</em> for multiple
3535
* registered extensions that implement lifecycle callbacks such as
3636
* {@link BeforeAllCallback}, {@link AfterAllCallback},
37-
* {@link AfterClassTemplateInvocationCallback},
37+
* {@link BeforeClassTemplateInvocationCallback},
3838
* {@link AfterClassTemplateInvocationCallback}, {@link BeforeEachCallback},
3939
* {@link AfterEachCallback}, {@link BeforeTestExecutionCallback}, and
4040
* {@link AfterTestExecutionCallback}.
@@ -64,7 +64,7 @@
6464
public interface AfterClassTemplateInvocationCallback extends Extension {
6565

6666
/**
67-
* Callback that is invoked <em>after</em> each invocation of a container
67+
* Callback that is invoked <em>after</em> each invocation of a class
6868
* template.
6969
*
7070
* @param context the current extension context; never {@code null}

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/BeforeClassTemplateInvocationCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
public interface BeforeClassTemplateInvocationCallback extends Extension {
6565

6666
/**
67-
* Callback that is invoked <em>before</em> each invocation of a container
67+
* Callback that is invoked <em>before</em> each invocation of a class
6868
* template.
6969
*
7070
* @param context the current extension context; never {@code null}

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ClassTemplateInvocationContext.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
* {@code ClassTemplateInvocationContext} represents the <em>context</em> of
2323
* a single invocation of a {@link ClassTemplate @ClassTemplate}.
2424
*
25-
* <p>Each context is provided by a
26-
* {@link ClassTemplateInvocationContextProvider}.
25+
* <p>Each context is provided by a {@link ClassTemplateInvocationContextProvider}.
2726
*
2827
* @since 5.13
2928
* @see ClassTemplate
@@ -36,7 +35,7 @@ public interface ClassTemplateInvocationContext {
3635
* Get the display name for this invocation.
3736
*
3837
* <p>The supplied {@code invocationIndex} is incremented by the framework
39-
* with each container invocation. Thus, in the case of multiple active
38+
* with each class template invocation. Thus, in the case of multiple active
4039
* {@linkplain ClassTemplateInvocationContextProvider providers}, only the
4140
* first active provider receives indices starting with {@code 1}.
4241
*
@@ -51,16 +50,16 @@ default String getDisplayName(int invocationIndex) {
5150
}
5251

5352
/**
54-
* Get the additional {@linkplain Extension extensions} for this invocation.
53+
* Get additional {@linkplain Extension extensions} for this invocation.
5554
*
5655
* <p>The extensions provided by this method will only be used for this
5756
* invocation of the class template. Thus, it does not make sense to return
58-
* an extension that acts solely on the container level (e.g.
59-
* {@link BeforeAllCallback}).
57+
* an extension that needs to perform some action at the container level,
58+
* such as an implementation of {@link BeforeAllCallback}.
6059
*
6160
* <p>The default implementation returns an empty list.
6261
*
63-
* @return the additional extensions for this invocation; never {@code null}
62+
* @return additional extensions for this invocation; never {@code null}
6463
* or containing {@code null} elements, but potentially empty
6564
*/
6665
default List<Extension> getAdditionalExtensions() {
@@ -74,7 +73,7 @@ default List<Extension> getAdditionalExtensions() {
7473
* {@link ExtensionContext.Store Store} to benefit from its cleanup support
7574
* or for retrieval by other extensions.
7675
*
77-
* @param context The invocation-level extension context.
76+
* @param context the invocation-level extension context
7877
*/
7978
default void prepareInvocation(ExtensionContext context) {
8079
}

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ClassTemplateInvocationContextProvider.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,34 @@
2222
* {@link Extension Extensions} that wish to provide one or multiple contexts
2323
* for the invocation of a {@link ClassTemplate @ClassTemplate}.
2424
*
25-
* <p>This extension point makes it possible to execute a class template in
25+
* <p>This extension API makes it possible to execute a class template in
2626
* different contexts &mdash; for example, with different parameters, by
2727
* preparing the test class instance differently, or multiple times without
2828
* modifying the context.
2929
*
30-
* <p>This interface defines two main methods:
31-
* {@link #supportsClassTemplate} and
30+
* <p>This interface defines two main methods: {@link #supportsClassTemplate} and
3231
* {@link #provideClassTemplateInvocationContexts}. The former is called by the
33-
* framework to determine whether this extension wants to act on a container
32+
* framework to determine whether this extension wants to act on a class
3433
* template that is about to be executed. If so, the latter is called and must
3534
* return a {@link Stream} of {@link ClassTemplateInvocationContext} instances.
3635
* Otherwise, this provider is ignored for the execution of the current class
3736
* template.
3837
*
39-
* <p>A provider that has returned {@code true} from its
40-
* {@link #supportsClassTemplate} method is called <em>active</em>. When
41-
* multiple providers are active for a class template, the
42-
* {@code Streams} returned by their
38+
* <p>A provider that has returned {@code true} from its {@link #supportsClassTemplate}
39+
* method is called <em>active</em>. When multiple providers are active for a class
40+
* template, the {@code Streams} returned by their
4341
* {@link #provideClassTemplateInvocationContexts} methods will be chained, and
4442
* the class template method will be invoked using the contexts of all active
4543
* providers.
4644
*
4745
* <p>An active provider may return zero invocation contexts from its
4846
* {@link #provideClassTemplateInvocationContexts} method if it overrides
49-
* {@link #mayReturnZeroClassTemplateInvocationContexts} to return
50-
* {@code true}.
47+
* {@link #mayReturnZeroClassTemplateInvocationContexts} to return {@code true}.
5148
*
5249
* <h2>Constructor Requirements</h2>
5350
*
54-
* <p>Consult the documentation in {@link Extension} for details on
55-
* constructor requirements.
51+
* <p>Consult the documentation in {@link Extension} for details on constructor
52+
* requirements.
5653
*
5754
* @since 5.13
5855
* @see ClassTemplate
@@ -90,8 +87,8 @@ public interface ClassTemplateInvocationContextProvider extends Extension {
9087
* invoked; never {@code null}
9188
* @return a {@code Stream} of {@code ClassTemplateInvocationContext}
9289
* instances for the invocation of the class template; never {@code null}
93-
* @throws TemplateInvocationValidationException if a validation fails when
94-
* while providing or closing the {@link java.util.stream.Stream}.
90+
* @throws TemplateInvocationValidationException if validation fails while
91+
* providing or closing the {@link Stream}
9592
* @see #supportsClassTemplate
9693
* @see ExtensionContext
9794
*/

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/TestTemplateInvocationContext.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface TestTemplateInvocationContext {
3636
* Get the display name for this invocation.
3737
*
3838
* <p>The supplied {@code invocationIndex} is incremented by the framework
39-
* with each test invocation. Thus, in the case of multiple active
39+
* with each test template invocation. Thus, in the case of multiple active
4040
* {@linkplain TestTemplateInvocationContextProvider providers}, only the
4141
* first active provider receives indices starting with {@code 1}.
4242
*
@@ -51,16 +51,16 @@ default String getDisplayName(int invocationIndex) {
5151
}
5252

5353
/**
54-
* Get the additional {@linkplain Extension extensions} for this invocation.
54+
* Get additional {@linkplain Extension extensions} for this invocation.
5555
*
5656
* <p>The extensions provided by this method will only be used for this
5757
* invocation of the test template. Thus, it does not make sense to return
58-
* an extension that acts solely on the container level (e.g.
59-
* {@link BeforeAllCallback}).
58+
* an extension that needs to perform some action at the container level,
59+
* such as an implementation of {@link BeforeAllCallback}.
6060
*
6161
* <p>The default implementation returns an empty list.
6262
*
63-
* @return the additional extensions for this invocation; never {@code null}
63+
* @return additional extensions for this invocation; never {@code null}
6464
* or containing {@code null} elements, but potentially empty
6565
*/
6666
default List<Extension> getAdditionalExtensions() {
@@ -74,7 +74,7 @@ default List<Extension> getAdditionalExtensions() {
7474
* {@link ExtensionContext.Store Store} to benefit from its cleanup support
7575
* or for retrieval by other extensions.
7676
*
77-
* @param context The invocation-level extension context.
77+
* @param context the invocation-level extension context
7878
* @since 5.13
7979
*/
8080
@API(status = EXPERIMENTAL, since = "6.0")

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/TestTemplateInvocationContextProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* for the invocation of a
2424
* {@link org.junit.jupiter.api.TestTemplate @TestTemplate} method.
2525
*
26-
* <p>This extension point makes it possible to execute a test template in
26+
* <p>This extension API makes it possible to execute a test template in
2727
* different contexts &mdash; for example, with different parameters, by
2828
* preparing the test class instance differently, or multiple times without
2929
* modifying the context.
@@ -48,8 +48,8 @@
4848
*
4949
* <h2>Constructor Requirements</h2>
5050
*
51-
* <p>Consult the documentation in {@link Extension} for details on
52-
* constructor requirements.
51+
* <p>Consult the documentation in {@link Extension} for details on constructor
52+
* requirements.
5353
*
5454
* @since 5.0
5555
* @see org.junit.jupiter.api.TestTemplate
@@ -86,8 +86,8 @@ public interface TestTemplateInvocationContextProvider extends Extension {
8686
* to be invoked; never {@code null}
8787
* @return a {@code Stream} of {@code TestTemplateInvocationContext}
8888
* instances for the invocation of the test template method; never {@code null}
89-
* @throws TemplateInvocationValidationException if a validation fails when
90-
* while providing or closing the {@link java.util.stream.Stream}.
89+
* @throws TemplateInvocationValidationException if validation fails while
90+
* providing or closing the {@link Stream}
9191
* @see #supportsTestTemplate
9292
* @see ExtensionContext
9393
*/

junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public interface ParameterInfo {
7777
ParameterDeclarations getDeclarations();
7878

7979
/**
80-
* {@return the accessor to the arguments of the current invocation}
80+
* {@return an accessor for the arguments of the current invocation}
8181
*/
8282
ArgumentsAccessor getArguments();
8383

junit-jupiter-params/src/main/java/org/junit/jupiter/params/aggregator/ArgumentsAccessor.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@
2121
* {@code ArgumentsAccessor} defines the public API for accessing arguments provided
2222
* by an {@link org.junit.jupiter.params.provider.ArgumentsProvider ArgumentsProvider}
2323
* for a single invocation of a
24-
* {@link org.junit.jupiter.params.ParameterizedTest @ParameterizedTest} method.
24+
* {@link org.junit.jupiter.params.ParameterizedClass @ParameterizedClass} or
25+
* {@link org.junit.jupiter.params.ParameterizedTest @ParameterizedTest}.
2526
*
2627
* <p>Specifically, an {@code ArgumentsAccessor} <em>aggregates</em> a set of
27-
* arguments for a given invocation of a parameterized test and provides convenience
28-
* methods for accessing those arguments in a type-safe manner with support for
29-
* automatic type conversion.
28+
* arguments for a given invocation of a parameterized class or parameterized
29+
* test and provides convenience methods for accessing those arguments in a
30+
* type-safe manner with support for automatic type conversion.
3031
*
3132
* <p>An instance of {@code ArgumentsAccessor} will be automatically supplied
32-
* for any parameter of type {@code ArgumentsAccessor} in a parameterized test.
33-
* In addition, {@link ArgumentsAggregator} implementations are given access to
34-
* an {@code ArgumentsAccessor}.
33+
* for any parameter of type {@code ArgumentsAccessor} in a parameterized class
34+
* or parameterized test. In addition, {@link ArgumentsAggregator} implementations
35+
* are given access to an {@code ArgumentsAccessor}.
3536
*
3637
* <p>This interface is not intended to be implemented by clients.
3738
*
@@ -201,7 +202,8 @@ public interface ArgumentsAccessor {
201202
List<@Nullable Object> toList();
202203

203204
/**
204-
* Get the index of the current test invocation.
205+
* Get the index of the current invocation.
205206
*/
206207
int getInvocationIndex();
208+
207209
}

junit-jupiter-params/src/main/java/org/junit/jupiter/params/support/ParameterDeclarations.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121

2222
/**
2323
* {@code ParameterDeclarations} encapsulates the combined <em>declarations</em>
24-
* of all <em>indexed</em> {@code @ParameterizedClass} or
25-
* {@code @ParameterizedTest} parameters.
24+
* of all <em>indexed</em> parameters for a {@code @ParameterizedClass} or
25+
* {@code @ParameterizedTest}.
2626
*
2727
* <p>For a {@code @ParameterizedTest}, the parameter declarations are derived
2828
* from the method signature. For a {@code @ParameterizedClass}, they may be
2929
* derived from the constructor or
30-
* {@link java.lang.reflect.Parameter @Parameter}-annotated fields.
30+
* {@link org.junit.jupiter.params.Parameter @Parameter}-annotated fields.
3131
*
32-
* <p>Aggregators, that is parameters of type
33-
* {@link ArgumentsAccessor ArgumentsAccessor} or parameters annotated with
34-
* {@link org.junit.jupiter.params.aggregator.AggregateWith @AggregateWith}, are
35-
* <em>not</em> indexed and thus not included in the list of parameter
32+
* <p>Aggregators &mdash; parameters of type {@link ArgumentsAccessor ArgumentsAccessor}
33+
* or parameters annotated with
34+
* {@link org.junit.jupiter.params.aggregator.AggregateWith @AggregateWith} &mdash;
35+
* are <em>not</em> indexed and thus not included in the list of parameter
3636
* declarations.
3737
*
3838
* @since 5.13
@@ -44,20 +44,20 @@
4444
public interface ParameterDeclarations {
4545

4646
/**
47-
* {@return all <em>indexed</em> parameter declarations; never {@code null},
48-
* sorted by index}
47+
* {@return all <em>indexed</em> parameter declarations, sorted by index;
48+
* never {@code null}, but potentially empty}
4949
*/
5050
List<ParameterDeclaration> getAll();
5151

5252
/**
5353
* {@return the first <em>indexed</em> parameter declaration, if available;
54-
* never {@code null}}
54+
* never {@code null}, but potentially empty}
5555
*/
5656
Optional<ParameterDeclaration> getFirst();
5757

5858
/**
5959
* {@return the <em>indexed</em> parameter declaration for the supplied
60-
* index, if available; never {@code null}}
60+
* index, if available; never {@code null}, but potentially empty}
6161
*/
6262
Optional<ParameterDeclaration> get(int parameterIndex);
6363

0 commit comments

Comments
 (0)