@Override public String toString() { return '[' + this.error.toString() + ',' + this.errorText + ']'; } }
/** * Create an exception and record information about the exception to be returned to the gadget. * * @param error * {@link OAuth2Error} for this error * @param errorText * String to help elaborate on the cause of this error * @param cause * {@link Throwable} optional root cause of the error * @param errorUri * optional errorUri from the OAuth2 spec * @param errorDescription * optionally provide more details about the error */ public OAuth2RequestException(final OAuth2Error error, final String errorText, final Throwable cause, final String errorUri, final String errorDescription) { super('[' + error.name() + ',' + String.format(error.toString(), errorText) + ']', cause); this.error = error; this.errorText = error.getErrorDescription(errorText); this.errorUri = errorUri; this.errorDescription = errorDescription; }
@Test public void testGetError1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
@Test public void testGetError_1() throws Exception { final OAuth2RequestException fixture = new OAuth2RequestException( OAuth2Error.AUTHENTICATION_PROBLEM, "", new Throwable()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
@Test public void testGetError1() throws Exception { final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM, "", new Exception()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
@Test public void testGetError_1() throws Exception { final OAuth2RequestException fixture = new OAuth2RequestException( OAuth2Error.AUTHENTICATION_PROBLEM, "", new Throwable()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }