Annotation Interface ConstraintsMethodSource


@Retention(RUNTIME) @Target({PARAMETER,FIELD}) public @interface ConstraintsMethodSource
Reference to a method providing a Stream, Collection or array of constraint annotations tuples for a TestTemplate. The method will be invoked by the KafkaClusterExtension to provide a list of constraint lists over which the test will parameterized. The annotation should be used on a KafkaCluster-typed parameter of a TestTemplate-annotated method. The referenced method must be static and package- or publicly-accessible.

For example


 static Stream<List<Annotation>> clusters() {
     return Stream.of(
         List.of(ConstraintUtils.brokerCluster(1), ConstraintUtils.kraftCluster(1)),
         List.of(ConstraintUtils.brokerCluster(3), ConstraintUtils.kraftCluster(1)),
         List.of(ConstraintUtils.brokerCluster(3), ConstraintUtils.zooKeeperCluster()));
 }

 @TestTemplate
 void matrixTest(@ConstraintMethodSource("clusters") KafkaCluster cluster) {
     // ....
 }
 *

If you want to execute a tests for each of the Cartesian product of a number of dimensions you might find @DimensionMethodSource more convenient.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Value of contraints method source.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The class where defining the static method, or Void.class (default), if the method is defined with the class defining the annotation test.
  • Element Details

    • value

      String value
      Value of contraints method source.
      Returns:
      the value
    • clazz

      Class<?> clazz
      The class where defining the static method, or Void.class (default), if the method is defined with the class defining the annotation test.
      Returns:
      the class
      Default:
      java.lang.Void.class