A java implementation of the Binance API Specification
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.

29 lines
954 B

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);
}
}