@Test public void testRequestAfterTokenExpiry() throws ControlPointApiException, IOException { Mockito.when(defaultHttpClient.execute(Mockito.any())) .thenReturn(buildLoginResponse()) .thenReturn(buildStandardResponse()) .thenReturn(buildStandardResponse()) .thenReturn(buildLoginResponse()) .thenReturn(buildStandardResponse()); defaultCPClient.get("status", Collections.singletonList( new BasicNameValuePair("format", "standard") ), Integer.class); clock.tick(Duration.ofSeconds(589)); defaultCPClient.get("status", Collections.singletonList( new BasicNameValuePair("format", "standard") ), Integer.class); clock.tick(Duration.ofSeconds(12)); defaultCPClient.get("status", Collections.singletonList( new BasicNameValuePair("format", "standard") ), Integer.class); final List<HttpUriRequest> requests = getRequests(5); Assert.assertEquals("should login", "POST", requests.get(0).getMethod()); Assert.assertEquals("should make request", "GET", requests.get(1).getMethod()); Assert.assertEquals("shouldn't login again before expiry", "GET", requests.get(2).getMethod()); Assert.assertEquals("should login again after expiry", "POST", requests.get(3).getMethod()); Assert.assertEquals("should make request after 2nd login", "GET", requests.get(4).getMethod()); }
public <R> R get( final String path, final List<NameValuePair> queryParams, final Class<R> resultType ) throws ControlPointApiException { return performAuthenticatedRequest(buildGetRequest(path, queryParams), resultType); }
ControlPointApiClient { public <R> R get( final String path, final List<NameValuePair> queryParams, final Class<R> resultType ) throws ControlPointApiException { return performAuthenticatedRequest(buildGetRequest(path, queryParams), resultType); } }
ControlPointApiClient { public <R> R get( final String path, final List<NameValuePair> queryParams, final Class<R> resultType ) throws ControlPointApiException { return performAuthenticatedRequest(buildGetRequest(path, queryParams), resultType); }  }
ControlPointApiClient { public <R> R get( final String path, final List<NameValuePair> queryParams, final Class<R> resultType ) throws ControlPointApiException { return performAuthenticatedRequest(buildGetRequest(path, queryParams), resultType); }  R get(
        final String path,
        final List<NameValuePair> queryParams,
        final Class<R> resultType
    ); R postUrlencoded(
        final String path,
        final List<NameValuePair> queryParams,
        final List<NameValuePair> bodyParams,
        final Class<R> resultType
    ); }
ControlPointApiClient { public <R> R get( final String path, final List<NameValuePair> queryParams, final Class<R> resultType ) throws ControlPointApiException { return performAuthenticatedRequest(buildGetRequest(path, queryParams), resultType); }  R get(
        final String path,
        final List<NameValuePair> queryParams,
        final Class<R> resultType
    ); R postUrlencoded(
        final String path,
        final List<NameValuePair> queryParams,
        final List<NameValuePair> bodyParams,
        final Class<R> resultType
    );  }