@Before
 public void setUp() {
   Retrofit retrofit =
       new Retrofit.Builder()
           .baseUrl(server.url("/"))
           .addConverterFactory(ScalarsConverterFactory.create())
           .build();
   service = retrofit.create(Service.class);
 }
Exemplo n.º 2
0
 public <S> S createServiceOfScalars(Class<S> serviceClass) {
   Retrofit retrofit =
       new Retrofit.Builder()
           .baseUrl(BASEURL)
           .client(httpClient.build())
           .addConverterFactory(ScalarsConverterFactory.create())
           .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
           .build();
   return retrofit.create(serviceClass);
 }
Exemplo n.º 3
0
  public void createDefaultAdapter() {
    Gson gson =
        new GsonBuilder()
            .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
            .registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
            .registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter())
            .create();

    okBuilder = new OkHttpClient.Builder();

    String baseUrl = "http://petstore.swagger.io/v2";
    if (!baseUrl.endsWith("/")) baseUrl = baseUrl + "/";

    adapterBuilder =
        new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(ScalarsConverterFactory.create())
            .addConverterFactory(GsonCustomConverterFactory.create(gson));
  }