package com.sigmaflare.binancej.matchers; import org.apache.http.client.methods.HttpGet; import org.mockito.ArgumentMatcher; public class GetMatcher implements ArgumentMatcher { 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); } }