Search in sources :

Example 41 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class ListenableFutureTest method setUp.

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

Example 42 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class CompletableFutureTest method setUp.

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

Example 43 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class FlowableWithSchedulerTest 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 44 with Retrofit

use of retrofit2.Retrofit in project retrofit by square.

the class MaybeTest 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 45 with Retrofit

use of retrofit2.Retrofit in project cw-omnibus by commonsguy.

the class QuestionsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View result = super.onCreateView(inflater, container, savedInstanceState);
    setRetainInstance(true);
    Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.stackexchange.com").addConverterFactory(GsonConverterFactory.create()).build();
    StackOverflowInterface so = retrofit.create(StackOverflowInterface.class);
    so.questions("android").enqueue(this);
    return (result);
}
Also used : Retrofit(retrofit2.Retrofit) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

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