FlattrAuthenticator { public String authenticate() throws FlattrException { try { StringBuilder url = new StringBuilder(); url.append(requestTokenUrl); url.append("?response_type=").append(URLEncoder.encode(responseType, ENCODING)); url.append("&client_id=").append(URLEncoder.encode(consumerKey.getKey(), ENCODING)); if (callbackUrl != null) { url.append("&redirect_uri=").append(URLEncoder.encode(callbackUrl, ENCODING)); } if (!scope.isEmpty()) { url.append("&scope=").append(URLEncoder.encode(buildScopeString(), ENCODING)); } return url.toString(); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } } FlattrAuthenticator(ConsumerKey consumerKey);  FlattrAuthenticator(String key, String secret); String getRequestTokenUrl(); void setRequestTokenUrl(String requestTokenUrl); String getAccessTokenUrl(); void setAccessTokenUrl(String accessTokenUrl); String getCallbackUrl(); void setCallbackUrl(String callbackUrl); EnumSet<Scope> getScope(); void setScope(EnumSet<Scope> scope); void setResponseType(String responseType); String getResponseType(); String authenticate(); AccessToken fetchAccessToken(String code);  }
@Test public void testAuthenticate() throws FlattrException { ConsumerKey ck = new ConsumerKey("ck-abc", "ck-123"); FlattrAuthenticator auth = new FlattrAuthenticator(ck); auth.getScope().add(Scope.FLATTR); auth.getScope().add(Scope.THING); String url = auth.authenticate(); assertThat(url, is("https: }