Skip to content

Commit

Permalink
Replace deprecated methods (#582)
Browse files Browse the repository at this point in the history
* Replace deprecated methods

* Fix test
  • Loading branch information
laurit authored Jun 19, 2023
1 parent cd36d72 commit 84e88bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ enum VolleyHttpClientAttributesGetter
INSTANCE;

@Override
public String getUrl(RequestWrapper requestWrapper) {
public String getUrlFull(RequestWrapper requestWrapper) {
return requestWrapper.getRequest().getUrl();
}

@Nullable
@Override
public String getMethod(RequestWrapper requestWrapper) {
public String getHttpRequestMethod(RequestWrapper requestWrapper) {
Request<?> request = requestWrapper.getRequest();
switch (request.getMethod()) {
case Request.Method.GET:
Expand All @@ -64,7 +64,7 @@ public String getMethod(RequestWrapper requestWrapper) {
}

@Override
public List<String> getRequestHeader(RequestWrapper requestWrapper, String name) {
public List<String> getHttpRequestHeader(RequestWrapper requestWrapper, String name) {
Request<?> request = requestWrapper.getRequest();
try {
Map<String, String> headers = request.getHeaders();
Expand All @@ -89,13 +89,13 @@ private List<String> findCaseInsensitive(String name, Map<String, String> header
}

@Override
public Integer getStatusCode(
public Integer getHttpResponseStatusCode(
RequestWrapper requestWrapper, HttpResponse response, @Nullable Throwable error) {
return response.getStatusCode();
}

@Override
public List<String> getResponseHeader(
public List<String> getHttpResponseHeader(
RequestWrapper requestWrapper, @Nullable HttpResponse response, String name) {
if (response == null) {
return emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public String getTransport(RequestWrapper requestWrapper, @Nullable HttpResponse

@Nullable
@Override
public String getPeerName(RequestWrapper requestWrapper) {
public String getServerAddress(RequestWrapper requestWrapper) {
return UrlParser.getHost(requestWrapper.getRequest().getUrl());
}

@Nullable
@Override
public Integer getPeerPort(RequestWrapper requestWrapper) {
public Integer getServerPort(RequestWrapper requestWrapper) {
return UrlParser.getPort(requestWrapper.getRequest().getUrl());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public void testRequestHeader() throws Exception {

VolleyHttpClientAttributesGetter testClass = VolleyHttpClientAttributesGetter.INSTANCE;

List<String> values = testClass.getRequestHeader(requestWrapper, "content-type");
List<String> values = testClass.getHttpRequestHeader(requestWrapper, "content-type");
assertThat(values).containsExactly("application/json");

List<String> fooValues = testClass.getRequestHeader(requestWrapper, "FOO");
List<String> fooValues = testClass.getHttpRequestHeader(requestWrapper, "FOO");
assertThat(fooValues).containsExactly("bar", "baz", "beep");
List<String> ayeValues = testClass.getRequestHeader(requestWrapper, "aYe");
List<String> ayeValues = testClass.getHttpRequestHeader(requestWrapper, "aYe");
assertThat(ayeValues).contains("b", "beeee");
}

Expand All @@ -81,17 +81,17 @@ public void testResponseHeader() {

VolleyHttpClientAttributesGetter testClass = VolleyHttpClientAttributesGetter.INSTANCE;

List<String> values = testClass.getResponseHeader(request, response, "content-type");
List<String> values = testClass.getHttpResponseHeader(request, response, "content-type");
assertThat(values).containsExactly("application/json");

List<String> fooValues = testClass.getResponseHeader(request, response, "FOO");
List<String> fooValues = testClass.getHttpResponseHeader(request, response, "FOO");
assertThat(fooValues).containsExactly("bar", "baz");
}

@Test
public void testNullResponse() {
VolleyHttpClientAttributesGetter testClass = VolleyHttpClientAttributesGetter.INSTANCE;
List<String> values = testClass.getResponseHeader(null, null, "content-type");
List<String> values = testClass.getHttpResponseHeader(null, null, "content-type");
assertThat(values).isEmpty();
}
}

0 comments on commit 84e88bc

Please sign in to comment.