Interface ArgumentsAggregator
-
- All Known Implementing Classes:
SimpleArgumentsAggregator
@API(status=STABLE, since="5.7") public interface ArgumentsAggregatorArgumentsAggregatoris an abstraction for the aggregation of arguments provided by anArgumentsProviderfor a single invocation of a@ParameterizedTestmethod into a single object.An
ArgumentsAggregatoris applied to a method parameter of a@ParameterizedTestmethod via the@AggregateWithannotation.The result of the aggregation will be passed as an argument to the
@ParameterizedTestmethod for the annotated parameter.A common use case is the aggregation of multiple columns from a single line in a CSV file into a domain object such as a
Person,Address,Order, etc.Implementations must provide a no-args constructor or a single unambiguous constructor to use parameter resolution. They should not make any assumptions regarding when they are instantiated or how often they are called. Since instances may potentially be cached and called from different threads, they should be thread-safe.
- Since:
- 5.2
- See Also:
AggregateWith,ArgumentsAccessor,SimpleArgumentsAggregator,ParameterizedTest
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.ObjectaggregateArguments(ArgumentsAccessor accessor, org.junit.jupiter.api.extension.ParameterContext context)Aggregate the arguments contained in the suppliedaccessorinto a single object.default java.lang.ObjectaggregateArguments(ArgumentsAccessor accessor, FieldContext context)Aggregate the arguments contained in the suppliedaccessorinto a single object.
-
-
-
Method Detail
-
aggregateArguments
java.lang.Object aggregateArguments(ArgumentsAccessor accessor, org.junit.jupiter.api.extension.ParameterContext context) throws ArgumentsAggregationException
Aggregate the arguments contained in the suppliedaccessorinto a single object.- Parameters:
accessor- anArgumentsAccessorcontaining the arguments to be aggregated; nevernullcontext- the parameter context where the aggregated result is to be supplied; nevernull- Returns:
- the aggregated result; may be
nullbut only if the target type is a reference type - Throws:
ArgumentsAggregationException- if an error occurs during the aggregation
-
aggregateArguments
@API(status=MAINTAINED, since="5.13.3") default java.lang.Object aggregateArguments(ArgumentsAccessor accessor, FieldContext context) throws ArgumentsAggregationExceptionAggregate the arguments contained in the suppliedaccessorinto a single object.- Parameters:
accessor- anArgumentsAccessorcontaining the arguments to be aggregated; nevernullcontext- the field context where the aggregated result is to be injected; nevernull- Returns:
- the aggregated result; may be
nullbut only if the target type is a reference type - Throws:
ArgumentsAggregationException- if an error occurs during the aggregation- Since:
- 5.13
-
-