Class RestClientProducer

java.lang.Object
org.wildfly.testing.junit.extension.RestClientProducer
All Implemented Interfaces:
ServerResourceProducer

@MetaInfServices public class RestClientProducer extends Object implements ServerResourceProducer
Produces Client (Jakarta REST Client) instances for injection into test fields and parameters. The Client is obtained from ServerContext and shared across all tests for the server lifecycle.
Author:
James R. Perkins
  • Constructor Details

    • RestClientProducer

      public RestClientProducer()
  • Method Details

    • canInject

      public boolean canInject(ExtensionContext context, Class<?> clazz, Annotation... annotations)
      Description copied from interface: ServerResourceProducer
      Indicates the type can be produced from this producer.
      Specified by:
      canInject in interface ServerResourceProducer
      Parameters:
      context - the current extension context
      clazz - the type to check
      annotations - the annotations, if any, for the field or parameter
      Returns:
      true if this producer can create this type, otherwise false
    • produce

      public Object produce(ExtensionContext context, Class<?> clazz, Annotation... annotations) throws IllegalArgumentException
      Description copied from interface: ServerResourceProducer
      Creates the object which can be injected into a static field, an instance field or a parameter.
      Specified by:
      produce in interface ServerResourceProducer
      Parameters:
      context - the current extension context
      clazz - the type of the field or parameter
      annotations - the annotations, if any, for the field or parameter
      Returns:
      the newly constructed object or null if it could not be produced
      Throws:
      IllegalArgumentException - if the type cannot be assigned to the type this producer can produce