Search in sources :

Example 36 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class GsonConverterFactoryTest method setUp.

@Before
public void setUp() {
    Gson gson = new GsonBuilder().registerTypeAdapter(AnInterface.class, new AnInterfaceAdapter()).setLenient().create();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/")).addConverterFactory(GsonConverterFactory.create(gson)).build();
    service = retrofit.create(Service.class);
}
Also used : Retrofit(retrofit2.Retrofit) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) Before(org.junit.Before)

Example 37 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class SingleTest method setUp.

@Before
public void setUp() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/")).addConverterFactory(new StringConverterFactory()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();
    service = retrofit.create(Service.class);
}
Also used : Retrofit(retrofit2.Retrofit) Before(org.junit.Before)

Example 38 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class SingleWithSchedulerTest method setUp.

@Before
public void setUp() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/")).addConverterFactory(new StringConverterFactory()).addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(scheduler)).build();
    service = retrofit.create(Service.class);
}
Also used : Retrofit(retrofit2.Retrofit) Before(org.junit.Before)

Example 39 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class MaybeWithSchedulerTest method setUp.

@Before
public void setUp() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/")).addConverterFactory(new StringConverterFactory()).addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(scheduler)).build();
    service = retrofit.create(Service.class);
}
Also used : Retrofit(retrofit2.Retrofit) Before(org.junit.Before)

Example 40 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class ObservableTest method setUp.

@Before
public void setUp() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/")).addConverterFactory(new StringConverterFactory()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();
    service = retrofit.create(Service.class);
}
Also used : Retrofit(retrofit2.Retrofit) Before(org.junit.Before)

Aggregations

Retrofit (retrofit2.Retrofit)81 Test (org.junit.Test)42 ToStringConverterFactory (retrofit2.helpers.ToStringConverterFactory)35 Before (org.junit.Before)34 MockResponse (okhttp3.mockwebserver.MockResponse)30 ResponseBody (okhttp3.ResponseBody)27 Type (java.lang.reflect.Type)25 IOException (java.io.IOException)22 OkHttpClient (okhttp3.OkHttpClient)22 ParameterizedType (java.lang.reflect.ParameterizedType)13 MediaType (okhttp3.MediaType)13 NonMatchingConverterFactory (retrofit2.helpers.NonMatchingConverterFactory)13 CountDownLatch (java.util.concurrent.CountDownLatch)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 Gson (com.google.gson.Gson)11 GsonBuilder (com.google.gson.GsonBuilder)11 NonMatchingCallAdapterFactory (retrofit2.helpers.NonMatchingCallAdapterFactory)11 Converter (retrofit2.Converter)10 DelegatingCallAdapterFactory (retrofit2.helpers.DelegatingCallAdapterFactory)10 Annotation (java.lang.annotation.Annotation)9