You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
954 B
30 lines
954 B
6 years ago
|
package com.sigmaflare.binancej.matchers;
|
||
|
|
||
|
import org.apache.http.client.methods.HttpGet;
|
||
|
import org.mockito.ArgumentMatcher;
|
||
|
|
||
|
public class GetMatcher implements ArgumentMatcher<HttpGet> {
|
||
|
private String url;
|
||
|
private String apiKey;
|
||
|
|
||
|
public GetMatcher(String url, String apiKey) {
|
||
|
this.url = url;
|
||
|
this.apiKey = apiKey;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Matches HttpGet objects based on "loose matching". We really only care that the URL and associated
|
||
|
* headers we care about are correct.
|
||
|
* @param httpGet The HttpGet object under test
|
||
|
* @return True if they are equal by our definition, false otherwise
|
||
|
*/
|
||
|
public boolean matches(HttpGet httpGet) {
|
||
|
final String url = httpGet.getURI().toASCIIString();
|
||
|
final String apiKeyHeaderValue = httpGet.getFirstHeader("X-MBX-APIKEY").getValue();
|
||
|
|
||
|
|
||
|
return url.equals(this.url) && apiKeyHeaderValue != null && apiKeyHeaderValue.equals(apiKey);
|
||
|
}
|
||
|
}
|
||
|
|