use of feign.MethodMetadata in project feign by OpenFeign.
the class JAXRSContractTest method producesAddsAcceptHeader.
@Test
public void producesAddsAcceptHeader() throws Exception {
MethodMetadata md = parseAndValidateMetadata(ProducesAndConsumes.class, "produces");
assertThat(md.template()).hasHeaders(entry("Content-Type", asList("application/json")), entry("Accept", asList("application/xml")));
}
use of feign.MethodMetadata in project feign by OpenFeign.
the class JAXRSContractTest method bodyParamIsGeneric.
@Test
public void bodyParamIsGeneric() throws Exception {
MethodMetadata md = parseAndValidateMetadata(BodyParams.class, "post", List.class);
assertThat(md.bodyIndex()).isEqualTo(0);
assertThat(md.bodyType()).isEqualTo(getClass().getDeclaredField("STRING_LIST").getGenericType());
}
use of feign.MethodMetadata in project feign by OpenFeign.
the class JAXRSContractTest method headerParamsParseIntoIndexToName.
@Test
public void headerParamsParseIntoIndexToName() throws Exception {
MethodMetadata md = parseAndValidateMetadata(HeaderParams.class, "logout", String.class);
assertThat(md.template()).hasHeaders(entry("Auth-Token", asList("{Auth-Token}")));
assertThat(md.indexToName()).containsExactly(entry(0, asList("Auth-Token")));
}
use of feign.MethodMetadata in project feign by OpenFeign.
the class JAXRSContractTest method consumesAddsContentTypeHeader.
@Test
public void consumesAddsContentTypeHeader() throws Exception {
MethodMetadata md = parseAndValidateMetadata(ProducesAndConsumes.class, "consumes");
assertThat(md.template()).hasHeaders(entry("Accept", asList("text/html")), entry("Content-Type", asList("application/xml")));
}
use of feign.MethodMetadata in project feign by OpenFeign.
the class HystrixDelegatingContract method parseAndValidatateMetadata.
@Override
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
List<MethodMetadata> metadatas = this.delegate.parseAndValidatateMetadata(targetType);
for (MethodMetadata metadata : metadatas) {
Type type = metadata.returnType();
if (type instanceof ParameterizedType && ((ParameterizedType) type).getRawType().equals(HystrixCommand.class)) {
Type actualType = resolveLastTypeParameter(type, HystrixCommand.class);
metadata.returnType(actualType);
} else if (type instanceof ParameterizedType && ((ParameterizedType) type).getRawType().equals(Observable.class)) {
Type actualType = resolveLastTypeParameter(type, Observable.class);
metadata.returnType(actualType);
} else if (type instanceof ParameterizedType && ((ParameterizedType) type).getRawType().equals(Single.class)) {
Type actualType = resolveLastTypeParameter(type, Single.class);
metadata.returnType(actualType);
} else if (type instanceof ParameterizedType && ((ParameterizedType) type).getRawType().equals(Completable.class)) {
metadata.returnType(void.class);
}
}
return metadatas;
}
Aggregations