### Question:
OAuthArguments { private static UseToken parseUseToken(AuthType auth, String useTokenStr) throws GadgetException { if (useTokenStr.length() == 0) { if (auth == AuthType.SIGNED) { return UseToken.NEVER; } else { return UseToken.ALWAYS; } } useTokenStr = useTokenStr.toLowerCase(); if ("always".equals(useTokenStr)) { return UseToken.ALWAYS; } if ("if_available".equals(useTokenStr)) { return UseToken.IF_AVAILABLE; } if ("never".equals(useTokenStr)) { return UseToken.NEVER; } throw new GadgetException(GadgetException.Code.INVALID_PARAMETER, "Unknown use token value " + useTokenStr, HttpResponse.SC_BAD_REQUEST); } OAuthArguments(AuthType auth, HttpServletRequest request);  OAuthArguments(RequestAuthenticationInfo info);  OAuthArguments(AuthType auth,  Map<String, String> map);  OAuthArguments();  OAuthArguments(OAuthArguments orig); boolean mustUseToken(); boolean mayUseToken(); UseToken getUseToken(); void setUseToken(UseToken useToken); String getServiceName(); void setServiceName(String serviceName); String getTokenName(); void setTokenName(String tokenName); String getRequestToken(); void setRequestToken(String requestToken); String getRequestTokenSecret(); void setRequestTokenSecret(String requestTokenSecret); String getOrigClientState(); void setOrigClientState(String origClientState); boolean getBypassSpecCache(); void setBypassSpecCache(boolean bypassSpecCache); boolean getSignOwner(); void setSignOwner(boolean signOwner); boolean getSignViewer(); void setSignViewer(boolean signViewer); void setRequestOption(String name, String value); void removeRequestOption(String name); String getRequestOption(String name); String getRequestOption(String name, String def); boolean isProxiedContentRequest(); void setProxiedContentRequest(boolean proxiedContentRequest); boolean programmaticConfig(); String getReceivedCallbackUrl(); void setReceivedCallbackUrl(String receivedCallbackUrl); @Override int hashCode(); @Override boolean equals(Object obj); static final String PROGRAMMATIC_CONFIG_PARAM; static final String REQUEST_METHOD_PARAM; static final String PARAM_LOCATION_PARAM; static final String REQUEST_TOKEN_URL_PARAM; static final String ACCESS_TOKEN_URL_PARAM; static final String AUTHORIZATION_URL_PARAM; }### Answer:
@Test public void testParseUseToken() throws Exception { FakeHttpServletRequest req = new FakeHttpServletRequest(); req.setParameter("OAUTH_USE_TOKEN", "ALWAYS"); OAuthArguments args = new OAuthArguments(AuthType.SIGNED, req); assertEquals(UseToken.ALWAYS, args.getUseToken()); req.setParameter("OAUTH_USE_TOKEN", "if_available"); args = new OAuthArguments(AuthType.SIGNED, req); assertEquals(UseToken.IF_AVAILABLE, args.getUseToken()); req.setParameter("OAUTH_USE_TOKEN", "never"); args = new OAuthArguments(AuthType.SIGNED, req); assertEquals(UseToken.NEVER, args.getUseToken()); req.setParameter("OAUTH_USE_TOKEN", ""); args = new OAuthArguments(AuthType.SIGNED, req); assertEquals(UseToken.NEVER, args.getUseToken()); req.setParameter("OAUTH_USE_TOKEN", ""); args = new OAuthArguments(AuthType.OAUTH, req); assertEquals(UseToken.ALWAYS, args.getUseToken()); try { req.setParameter("OAUTH_USE_TOKEN", "stuff"); new OAuthArguments(AuthType.OAUTH, req); fail("Should have thrown"); } catch (GadgetException e) { } }