use of com.github.mjeanroy.junit.servers.annotations.TestHttpClient in project junit-servers by mjeanroy.
the class HttpClientParameterResolverFunction method resolve.
@Override
public Object resolve(ParameterContext parameterContext, EmbeddedServerRunner serverAdapter) {
log.debug("Resolving HTTP Client for parameter: {}", parameterContext);
final Optional<TestHttpClient> maybeAnnotation = parameterContext.findAnnotation(TestHttpClient.class);
final HttpClientConfiguration configuration;
final HttpClientStrategy strategy;
if (maybeAnnotation.isPresent()) {
TestHttpClient annotation = maybeAnnotation.get();
strategy = getStrategy(annotation);
configuration = getConfiguration(annotation);
} else {
strategy = defaultStrategy();
configuration = defaultConfiguration();
}
return serverAdapter.getClient(strategy, configuration);
}
use of com.github.mjeanroy.junit.servers.annotations.TestHttpClient in project junit-servers by mjeanroy.
the class HttpClientAnnotationHandler method before.
@Override
public void before(Object target, Field field) {
log.debug("Inject HTTP client to {} # {}", target, field);
TestHttpClient httpClient = Annotations.findAnnotation(field, TestHttpClient.class);
if (httpClient != null) {
HttpClientStrategy strategy = httpClient.strategy();
setter(target, field, strategy.build(server));
}
}
Aggregations