### Question:
CodeGrantTypeHandler implements GrantRequestHandler { public String getCompleteUrl(final OAuth2Accessor accessor) throws OAuth2RequestException { if (accessor == null) { throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "accessor is null", null); } if (!accessor.isValid() || accessor.isErrorResponse() || accessor.isRedirecting()) { throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "accessor is invalid", null); } if (!accessor.getGrantType().equalsIgnoreCase(OAuth2Message.AUTHORIZATION)) { throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "grant type is not code", null); } final Map<String, String> queryParams = Maps.newHashMapWithExpectedSize(4); queryParams.put(OAuth2Message.RESPONSE_TYPE, this.getGrantType()); queryParams.put(OAuth2Message.CLIENT_ID, accessor.getClientId()); final String redirectUri = accessor.getRedirectUri(); if (redirectUri != null && redirectUri.length() > 0) { queryParams.put(OAuth2Message.REDIRECT_URI, redirectUri); } final OAuth2CallbackState state = accessor.getState(); if (state != null) { try { queryParams.put(OAuth2Message.STATE, state.getEncryptedState()); } catch (final BlobCrypterException e) { throw new OAuth2RequestException(OAuth2Error.CODE_GRANT_PROBLEM, "encryption problem", e); } } final String scope = accessor.getScope(); if (scope != null && scope.length() > 0) { queryParams.put(OAuth2Message.SCOPE, scope); } for (final Map.Entry<String, String> entry : accessor.getAdditionalRequestParams().entrySet()) { queryParams.put(entry.getKey(), entry.getValue()); } return OAuth2Utils.buildUrl(accessor.getAuthorizationUrl(), queryParams, null); }  HttpRequest getAuthorizationRequest(final OAuth2Accessor accessor,
          final String completeAuthorizationUrl); String getCompleteUrl(final OAuth2Accessor accessor); String getGrantType(); static String getResponseType(); boolean isAuthorizationEndpointResponse(); boolean isRedirectRequired(); boolean isTokenEndpointResponse();  }### Answer:
@Test(expected = OAuth2RequestException.class) public void testGetCompleteUrl_1() throws Exception { final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth; final OAuth2Accessor accessor = null; fixture.getCompleteUrl(accessor); }
@Test(expected = OAuth2RequestException.class) public void testGetCompleteUrl_2() throws Exception { final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error(); fixture.getCompleteUrl(accessor); }
@Test(expected = OAuth2RequestException.class) public void testGetCompleteUrl_3() throws Exception { final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentialsRedirecting(); fixture.getCompleteUrl(accessor); }
@Test public void testGetCompleteUrl_4() throws Exception { final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code(); final String result = fixture.getCompleteUrl(accessor); Assert.assertNotNull(result); Assert.assertTrue(result .startsWith("http: }
@Test public void testGetCompleteUrl_5() throws Exception { final CodeGrantTypeHandler fixture = CodeGrantTypeHandlerTest.cgth; final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code(); final Map<String, String> additionalParams = Maps.newHashMap(); additionalParams.put("param1", "value1"); accessor.setAdditionalRequestParams(additionalParams); final String result = fixture.getCompleteUrl(accessor); Assert.assertNotNull(result); Assert.assertTrue(result.contains("&param1=value1")); }