use of retrofit2.http.Query in project retrofit by square.
the class RequestBuilderTest method getWithPathAndQueryHashParam.
@Test
public void getWithPathAndQueryHashParam() {
class Example {
//
@GET("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path("ping") String ping, @Query("kit") String kit) {
return null;
}
}
Request request = buildRequest(Example.class, "pong#", "kat#");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/pong%23/?kit=kat%23");
assertThat(request.body()).isNull();
}
use of retrofit2.http.Query in project retrofit by square.
the class RequestBuilderTest method queryParamOptionalOmitsQuery.
@Test
public void queryParamOptionalOmitsQuery() {
class Example {
//
@GET("/foo/bar/")
Call<ResponseBody> method(@Query("ping") String ping) {
return null;
}
}
Request request = buildRequest(Example.class, new Object[] { null });
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");
}
use of retrofit2.http.Query in project retrofit by square.
the class RequestBuilderTest method getWithPathAndQueryParam.
@Test
public void getWithPathAndQueryParam() {
class Example {
//
@GET("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path("ping") String ping, @Query("kit") String kit, @Query("riff") String riff) {
return null;
}
}
Request request = buildRequest(Example.class, "pong", "kat", "raff");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/pong/?kit=kat&riff=raff");
assertThat(request.body()).isNull();
}
use of retrofit2.http.Query in project retrofit by square.
the class RequestBuilderTest method getWithQueryParam.
@Test
public void getWithQueryParam() {
class Example {
//
@GET("/foo/bar/")
Call<ResponseBody> method(@Query("ping") String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "pong");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/?ping=pong");
assertThat(request.body()).isNull();
}
use of retrofit2.http.Query in project retrofit by square.
the class RequestBuilderTest method getWithUrlThenQuery.
@Test
public void getWithUrlThenQuery() {
class Example {
@GET
Call<ResponseBody> method(@Url String url, @Query("hey") String hey) {
return null;
}
}
Request request = buildRequest(Example.class, "foo/bar/", "hey!");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/?hey=hey!");
}
Aggregations