use of retrofit2.helpers.DelegatingCallAdapterFactory in project retrofit by square.
the class RetrofitTest method callAdapterFactoryDelegateNoMatchThrows.
@Test
public void callAdapterFactoryDelegateNoMatchThrows() {
Type type = String.class;
Annotation[] annotations = new Annotation[0];
DelegatingCallAdapterFactory delegatingFactory1 = new DelegatingCallAdapterFactory();
DelegatingCallAdapterFactory delegatingFactory2 = new DelegatingCallAdapterFactory();
NonMatchingCallAdapterFactory nonMatchingFactory = new NonMatchingCallAdapterFactory();
Retrofit retrofit = new Retrofit.Builder().baseUrl("http://example.com/").addCallAdapterFactory(delegatingFactory1).addCallAdapterFactory(delegatingFactory2).addCallAdapterFactory(nonMatchingFactory).build();
try {
retrofit.callAdapter(type, annotations);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("" + "Could not locate call adapter for class java.lang.String.\n" + " Skipped:\n" + " * retrofit2.helpers.DelegatingCallAdapterFactory\n" + " * retrofit2.helpers.DelegatingCallAdapterFactory\n" + " Tried:\n" + " * retrofit2.helpers.NonMatchingCallAdapterFactory\n" + " * retrofit2.DefaultCallAdapterFactory");
}
assertThat(delegatingFactory1.called).isTrue();
assertThat(delegatingFactory2.called).isTrue();
assertThat(nonMatchingFactory.called).isTrue();
}
Aggregations