MParticleApiClientImpl extends MParticleBaseClientImpl implements MParticleApiClient { void checkThrottleTime(Endpoint endpoint) throws MPThrottleException { if (System.currentTimeMillis() < getNextRequestTime(endpoint)){ throw new MPThrottleException(); } } MParticleApiClientImpl(ConfigManager configManager, SharedPreferences sharedPreferences, Context context); @Override void fetchConfig(); void fetchConfig(boolean force); JSONObject fetchAudiences(); int sendMessageBatch(String message); @Override AliasNetworkResponse sendAliasRequest(String message); void setCookies(JSONObject serverCookies); JSONObject getCookies();  }
@Test @PrepareForTest({URL.class, MParticleApiClientImpl.class, MPUtility.class}) public void testCheckThrottleTime() throws Exception { setup(); for (MParticleBaseClientImpl.Endpoint endpoint: MParticleBaseClientImpl.Endpoint.values()) { client.checkThrottleTime(endpoint); client.getRequestHandler().setNextRequestTime(endpoint, System.currentTimeMillis() + 1000); Exception e = null; try { client.checkThrottleTime(endpoint); } catch (MParticleApiClientImpl.MPThrottleException cfe) { e = cfe; } assertNotNull(e); } }