### Question:
ClientCredentialsGrantTypeHandler implements GrantRequestHandler { public String getCompleteUrl(final OAuth2Accessor accessor) throws OAuth2RequestException { if (accessor == null) { throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null", null); } if (!accessor.isValid() || accessor.isErrorResponse() || accessor.isRedirecting()) { throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is invalid", null); } if (!accessor.getGrantType().equalsIgnoreCase(OAuth2Message.CLIENT_CREDENTIALS)) { throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "grant type is not client_credentials", null); } String ret; try { final Map<String, String> queryParams = Maps.newHashMapWithExpectedSize(4); queryParams.put(OAuth2Message.GRANT_TYPE, this.getGrantType()); final String clientId = accessor.getClientId(); final byte[] secretBytes = accessor.getClientSecret(); final String secret = new String(secretBytes, "UTF-8"); queryParams.put(OAuth2Message.CLIENT_ID, clientId); queryParams.put(OAuth2Message.CLIENT_SECRET, secret); final String scope = accessor.getScope(); if (scope != null && scope.length() > 0) { queryParams.put(OAuth2Message.SCOPE, scope); } ret = OAuth2Utils.buildUrl(accessor.getTokenUrl(), queryParams, null); } catch (final UnsupportedEncodingException e) { throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM, "problem getting complete url", e); } return ret; } @Inject  ClientCredentialsGrantTypeHandler(
          final List<ClientAuthenticationHandler> clientAuthenticationHandlers); HttpRequest getAuthorizationRequest(final OAuth2Accessor accessor,
          final String completeAuthorizationUrl); String getCompleteUrl(final OAuth2Accessor accessor); String getGrantType(); boolean isAuthorizationEndpointResponse(); boolean isRedirectRequired(); boolean isTokenEndpointResponse();  }### Answer:
@Test(expected = OAuth2RequestException.class) public void testGetCompleteUrl_1() throws Exception { final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth; final OAuth2Accessor accessor = null; fixture.getCompleteUrl(accessor); }
@Test(expected = OAuth2RequestException.class) public void testGetCompleteUrl_2() throws Exception { final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error(); fixture.getCompleteUrl(accessor); }
@Test(expected = OAuth2RequestException.class) public void testGetCompleteUrl_3() throws Exception { final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code(); fixture.getCompleteUrl(accessor); }
@Test public void testGetCompleteUrl_4() throws Exception { final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials(); final String result = fixture.getCompleteUrl(accessor); Assert.assertNotNull(result); Assert .assertEquals( "http: result); }