@Test public void testCallRequest() throws Exception { RestfitClient client = new RestfitClient.Builder() .userAgent("RestfitTest/1.0") .httpStack( new RestfitHttpStack() { @NonNull @Override public Single<RestfitResponse> perform(@NonNull RestfitRequest request) { return Single.just(response); } }) .build(); final RestfitRequest.Builder requestBuilder = client.requestBuilder().method("GET").url("http://example.com/"); response = new RestfitResponse.Builder().request(requestBuilder.build()).build(); TestSubscriber<RestfitResponse> testSubscriber = TestSubscriber.create(); client.call(requestBuilder).subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(10, TimeUnit.MILLISECONDS); testSubscriber.assertCompleted(); testSubscriber.assertReceivedOnNext(Collections.singletonList(response)); }
@Test public void testCreateInstance() throws Exception { RestfitClient client = new RestfitClient.Builder() .userAgent("RestfitTest/1.0") .httpStack(new DummyHttpStack()) .build(); assertThat(client.getUserAgent(), is("RestfitTest/1.0")); }