Search in sources :

Example 6 with MethodMetadata

use of feign.MethodMetadata in project feign by OpenFeign.

the class WhatShouldWeCacheBenchmarks method setup.

@Setup
public void setup() {
    feignContract = new Contract.Default();
    cachedContact = new Contract() {

        private final List<MethodMetadata> cached = new Default().parseAndValidatateMetadata(FeignTestInterface.class);

        public List<MethodMetadata> parseAndValidatateMetadata(Class<?> declaring) {
            return cached;
        }
    };
    fakeClient = new Client() {

        public Response execute(Request request, Request.Options options) throws IOException {
            Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>();
            return Response.create(200, "ok", headers, (byte[]) null);
        }
    };
    cachedFakeFeign = Feign.builder().client(fakeClient).build();
    cachedFakeApi = cachedFakeFeign.newInstance(new HardCodedTarget<FeignTestInterface>(FeignTestInterface.class, "http://localhost"));
}
Also used : Request(feign.Request) HardCodedTarget(feign.Target.HardCodedTarget) IOException(java.io.IOException) Response(feign.Response) Collection(java.util.Collection) MethodMetadata(feign.MethodMetadata) List(java.util.List) Client(feign.Client) Contract(feign.Contract) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Setup(org.openjdk.jmh.annotations.Setup)

Example 7 with MethodMetadata

use of feign.MethodMetadata in project feign by OpenFeign.

the class JAXRSContractTest method withPathAndURIParams.

@Test
public void withPathAndURIParams() throws Exception {
    MethodMetadata md = parseAndValidateMetadata(WithURIParam.class, "uriParam", String.class, URI.class, String.class);
    assertThat(md.indexToName()).containsExactly(entry(0, asList("1")), // Skips 1 as it is a url index!
    entry(2, asList("2")));
    assertThat(md.urlIndex()).isEqualTo(1);
}
Also used : MethodMetadata(feign.MethodMetadata) Test(org.junit.Test)

Example 8 with MethodMetadata

use of feign.MethodMetadata in project feign by OpenFeign.

the class JAXRSContractTest method formParamsParseIntoIndexToName.

@Test
public void formParamsParseIntoIndexToName() throws Exception {
    MethodMetadata md = parseAndValidateMetadata(FormParams.class, "login", String.class, String.class, String.class);
    assertThat(md.formParams()).containsExactly("customer_name", "user_name", "password");
    assertThat(md.indexToName()).containsExactly(entry(0, asList("customer_name")), entry(1, asList("user_name")), entry(2, asList("password")));
}
Also used : MethodMetadata(feign.MethodMetadata) Test(org.junit.Test)

Example 9 with MethodMetadata

use of feign.MethodMetadata in project feign by OpenFeign.

the class JAXRSContractTest method formParamsDoesNotSetBodyType.

/**
   * Body type is only for the body param.
   */
@Test
public void formParamsDoesNotSetBodyType() throws Exception {
    MethodMetadata md = parseAndValidateMetadata(FormParams.class, "login", String.class, String.class, String.class);
    assertThat(md.bodyType()).isNull();
}
Also used : MethodMetadata(feign.MethodMetadata) Test(org.junit.Test)

Example 10 with MethodMetadata

use of feign.MethodMetadata in project feign by OpenFeign.

the class JAXRSContractTest method pathAndQueryParams.

@Test
public void pathAndQueryParams() throws Exception {
    MethodMetadata md = parseAndValidateMetadata(WithPathAndQueryParams.class, "recordsByNameAndType", int.class, String.class, String.class);
    assertThat(md.template()).hasQueries(entry("name", asList("{name}")), entry("type", asList("{type}")));
    assertThat(md.indexToName()).containsExactly(entry(0, asList("domainId")), entry(1, asList("name")), entry(2, asList("type")));
}
Also used : MethodMetadata(feign.MethodMetadata) Test(org.junit.Test)

Aggregations

MethodMetadata (feign.MethodMetadata)11 Test (org.junit.Test)9 HystrixCommand (com.netflix.hystrix.HystrixCommand)1 Client (feign.Client)1 Contract (feign.Contract)1 Request (feign.Request)1 Response (feign.Response)1 HardCodedTarget (feign.Target.HardCodedTarget)1 IOException (java.io.IOException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Setup (org.openjdk.jmh.annotations.Setup)1 Observable (rx.Observable)1 Single (rx.Single)1