OltuOAuth2ClientFacade implements OAuth2ClientFacade { @Override public void refreshAccessToken(OAuth2Profile profile) throws Exception { OAuth2Parameters parameters = buildParametersFrom(profile); validateRequiredStringValue(parameters.refreshToken, "refresh token"); validateRequiredStringValue(parameters.clientId, "client ID"); validateRequiredStringValue(parameters.clientSecret, "client secret"); getOAuth2TokenExtractor().refreshAccessToken(parameters); }  @Override void requestAccessToken(OAuth2Profile profile); @Override void refreshAccessToken(OAuth2Profile profile); @Override void applyAccessToken(OAuth2Profile profile, HttpRequestBase request, String requestContent);  }
@Test public void refreshesAccessToken() throws Exception { profile.setAccessToken("expiredAccessToken"); profile.setRefreshToken(OAuth2TestUtils.REFRESH_TOKEN); oltuClientFacade.refreshAccessToken(profile); assertThat(profile.getAccessToken(), is(OAuth2TestUtils.ACCESS_TOKEN)); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsEmptyRefreshTokenOnRefresh() throws Exception { profile.setRefreshToken(""); oltuClientFacade.refreshAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsEmptyClientIdOnRefresh() throws Exception { profile.setRefreshToken("someRefreshToken"); profile.setClientID(""); oltuClientFacade.refreshAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsEmptyClientSecretOnRefresh() throws Exception { profile.setRefreshToken("someRefreshToken"); profile.setClientSecret(""); oltuClientFacade.refreshAccessToken(profile); }