@Override
    public OAuth2AccessToken extract(Response response) throws IOException {
        final String body = response.getBody();
        Preconditions.checkEmptyString(body, "Response body is incorrect. Can't extract a token from an empty string");

        if (response.getCode() != 200) {
            generateError(response);
        }
        return createToken(body);
    }
@Test
    public void shouldThrowExceptionIfResponseIsError() throws IOException {
        final String responseBody = "{"
                + "\"error_description\":\"unknown, invalid, or expired refresh token\","
                + "\"error\":\"invalid_grant\""
                + "}";
        try (Response response = error(responseBody)) {
            final OAuth2AccessTokenErrorResponse oaer = assertThrows(OAuth2AccessTokenErrorResponse.class,
                    new ThrowingRunnable() {
                @Override
                public void run() throws Throwable {
                    extractor.extract(response);
                }
            });
            assertEquals(OAuth2Error.INVALID_GRANT, oaer.getError());
            assertEquals("unknown, invalid, or expired refresh token", oaer.getErrorDescription());
        }
    }