Package feign

Examples of feign.MethodMetadata.template()


  @Test public void bodyParamIsGeneric() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(BodyParams.class.getDeclaredMethod("post",
        List.class));
    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertNull(md.urlIndex());
    assertEquals(md.bodyIndex(), Integer.valueOf(0));
    assertEquals(md.bodyType(), new TypeToken<List<String>>() {
    }.getType());
  }
View Full Code Here


    @GET @Path("/{param}") Response emptyPathParam(@PathParam("") String empty);
  }

  @Test public void pathOnType() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(PathOnType.class.getDeclaredMethod("base"));
    assertEquals(md.template().url(), "/base");
    md = contract.parseAndValidatateMetadata(PathOnType.class.getDeclaredMethod("get"));
    assertEquals(md.template().url(), "/base/specific");
  }

  @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Path.value\\(\\) was empty on method emptyPath")
View Full Code Here

  @Test public void pathOnType() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(PathOnType.class.getDeclaredMethod("base"));
    assertEquals(md.template().url(), "/base");
    md = contract.parseAndValidatateMetadata(PathOnType.class.getDeclaredMethod("get"));
    assertEquals(md.template().url(), "/base/specific");
  }

  @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Path.value\\(\\) was empty on method emptyPath")
  public void emptyPathOnMethod() throws Exception {
    contract.parseAndValidatateMetadata(PathOnType.class.getDeclaredMethod("emptyPath"));
View Full Code Here

  }

  @Test public void pathParamsParseIntoIndexToName() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(WithURIParam.class.getDeclaredMethod("uriParam", String.class,
        URI.class, String.class));
    assertEquals(md.template().url(), "/{1}/{2}");
    assertEquals(md.indexToName().get(0), ImmutableSet.of("1"));
    assertEquals(md.indexToName().get(2), ImmutableSet.of("2"));
  }

  interface WithPathAndQueryParams {
View Full Code Here

  }

  @Test public void mixedRequestLineParams() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(WithPathAndQueryParams.class.getDeclaredMethod
        ("recordsByNameAndType", int.class, String.class, String.class));
    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertTrue(md.template().headers().isEmpty());
    assertEquals(md.template().url(), "/domains/{domainId}/records");
    assertEquals(md.template().queries().get("name"), ImmutableSet.of("{name}"));
    assertEquals(md.template().queries().get("type"), ImmutableSet.of("{type}"));
View Full Code Here

  @Test public void mixedRequestLineParams() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(WithPathAndQueryParams.class.getDeclaredMethod
        ("recordsByNameAndType", int.class, String.class, String.class));
    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertTrue(md.template().headers().isEmpty());
    assertEquals(md.template().url(), "/domains/{domainId}/records");
    assertEquals(md.template().queries().get("name"), ImmutableSet.of("{name}"));
    assertEquals(md.template().queries().get("type"), ImmutableSet.of("{type}"));
    assertEquals(md.indexToName().get(0), ImmutableSet.of("domainId"));
View Full Code Here

  @Test public void mixedRequestLineParams() throws Exception {
    MethodMetadata md = contract.parseAndValidatateMetadata(WithPathAndQueryParams.class.getDeclaredMethod
        ("recordsByNameAndType", int.class, String.class, String.class));
    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertTrue(md.template().headers().isEmpty());
    assertEquals(md.template().url(), "/domains/{domainId}/records");
    assertEquals(md.template().queries().get("name"), ImmutableSet.of("{name}"));
    assertEquals(md.template().queries().get("type"), ImmutableSet.of("{type}"));
    assertEquals(md.indexToName().get(0), ImmutableSet.of("domainId"));
    assertEquals(md.indexToName().get(1), ImmutableSet.of("name"));
View Full Code Here

    MethodMetadata md = contract.parseAndValidatateMetadata(WithPathAndQueryParams.class.getDeclaredMethod
        ("recordsByNameAndType", int.class, String.class, String.class));
    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertTrue(md.template().headers().isEmpty());
    assertEquals(md.template().url(), "/domains/{domainId}/records");
    assertEquals(md.template().queries().get("name"), ImmutableSet.of("{name}"));
    assertEquals(md.template().queries().get("type"), ImmutableSet.of("{type}"));
    assertEquals(md.indexToName().get(0), ImmutableSet.of("domainId"));
    assertEquals(md.indexToName().get(1), ImmutableSet.of("name"));
    assertEquals(md.indexToName().get(2), ImmutableSet.of("type"));
View Full Code Here

        ("recordsByNameAndType", int.class, String.class, String.class));
    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertTrue(md.template().headers().isEmpty());
    assertEquals(md.template().url(), "/domains/{domainId}/records");
    assertEquals(md.template().queries().get("name"), ImmutableSet.of("{name}"));
    assertEquals(md.template().queries().get("type"), ImmutableSet.of("{type}"));
    assertEquals(md.indexToName().get(0), ImmutableSet.of("domainId"));
    assertEquals(md.indexToName().get(1), ImmutableSet.of("name"));
    assertEquals(md.indexToName().get(2), ImmutableSet.of("type"));
    assertEquals(md.template().toString(), "GET /domains/{domainId}/records?name={name}&type={type} HTTP/1.1\n");
View Full Code Here

    assertNull(md.template().body());
    assertNull(md.template().bodyTemplate());
    assertTrue(md.template().headers().isEmpty());
    assertEquals(md.template().url(), "/domains/{domainId}/records");
    assertEquals(md.template().queries().get("name"), ImmutableSet.of("{name}"));
    assertEquals(md.template().queries().get("type"), ImmutableSet.of("{type}"));
    assertEquals(md.indexToName().get(0), ImmutableSet.of("domainId"));
    assertEquals(md.indexToName().get(1), ImmutableSet.of("name"));
    assertEquals(md.indexToName().get(2), ImmutableSet.of("type"));
    assertEquals(md.template().toString(), "GET /domains/{domainId}/records?name={name}&type={type} HTTP/1.1\n");
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.