未验证 提交 cd333f70 编写于 作者: J Jesse Wilson 提交者: GitHub

Merge pull request #2790 from square/jakew/refactorings/2018-06-12

Jakew/refactorings/2018 06 12
此差异已折叠。
......@@ -25,11 +25,11 @@ import retrofit2.http.GET;
import retrofit2.http.Url;
import static org.assertj.core.api.Assertions.assertThat;
import static retrofit2.RequestBuilderTest.buildRequest;
import static retrofit2.RequestFactoryTest.buildRequest;
@RunWith(RobolectricTestRunner.class)
@SuppressWarnings({"UnusedParameters", "unused"}) // Parameters inspected reflectively.
public final class RequestBuilderAndroidTest {
public final class RequestFactoryAndroidTest {
@Test public void getWithAndroidUriUrl() {
class Example {
@GET
......
......@@ -20,7 +20,8 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public final class ServiceMethodTest {
// TODO this test is far too white box, migrate to black box.
public final class RequestFactoryBuilderTest {
@Test public void pathParameterParsing() throws Exception {
expectParams("/");
expectParams("/foo");
......@@ -41,7 +42,7 @@ public final class ServiceMethodTest {
}
private static void expectParams(String path, String... expected) {
Set<String> calculated = ServiceMethod.parsePathParameters(path);
Set<String> calculated = RequestFactory.Builder.parsePathParameters(path);
assertThat(calculated).containsExactly(expected);
}
}
......@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
......@@ -65,7 +64,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
@SuppressWarnings({"UnusedParameters", "unused"}) // Parameters inspected reflectively.
public final class RequestBuilderTest {
public final class RequestFactoryTest {
private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain");
@Test public void customMethodNoBody() {
......@@ -2689,10 +2688,8 @@ public final class RequestBuilderTest {
}
static <T> Request buildRequest(Class<T> cls, Retrofit.Builder builder, Object... args) {
final AtomicReference<Request> requestRef = new AtomicReference<>();
okhttp3.Call.Factory callFactory = new okhttp3.Call.Factory() {
@Override public okhttp3.Call newCall(Request request) {
requestRef.set(request);
throw new UnsupportedOperationException("Not implemented");
}
};
......@@ -2700,13 +2697,8 @@ public final class RequestBuilderTest {
Retrofit retrofit = builder.callFactory(callFactory).build();
Method method = TestingUtils.onlyMethod(cls);
//noinspection unchecked
Call<T> call = (Call<T>) retrofit.loadServiceMethod(method).invoke(args);
try {
call.execute();
throw new AssertionError();
} catch (UnsupportedOperationException ignored) {
return requestRef.get();
return RequestFactory.parseAnnotations(retrofit, method).create(args);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册