use of org.forgerock.openam.scripting.ScriptConstants.ScriptErrorCode in project OpenAM by OpenRock.
the class ScriptExceptionMappingHandlerTest method shouldTranslateMessageToAcceptLanguage.
@Test
public void shouldTranslateMessageToAcceptLanguage() throws Exception {
// given
final Context serverContext = getHttpServerContext("te");
for (ScriptErrorCode errorCode : ScriptErrorCode.values()) {
// when
ResourceException re = mappingHandler.handleError(serverContext, null, new ScriptException(errorCode));
// then
assertNotNull(re);
// assertEquals("Test message", re.getMessage()); //TODO dont get this...
}
}
use of org.forgerock.openam.scripting.ScriptConstants.ScriptErrorCode in project OpenAM by OpenRock.
the class ScriptExceptionTest method shouldMapScriptErrorCodeToLocalisedMessage.
@Test
public void shouldMapScriptErrorCodeToLocalisedMessage() {
// given
ScriptException se;
Locale locale = new Locale("te");
for (ScriptErrorCode errorCode : ScriptErrorCode.values()) {
// when
se = new ScriptException(errorCode);
//then
assertThat(se.getL10NMessage(locale)).isEqualTo(format(errorCode.name() + "-TRANSLATED"));
}
}
use of org.forgerock.openam.scripting.ScriptConstants.ScriptErrorCode in project OpenAM by OpenRock.
the class ScriptExceptionMappingHandlerTest method shouldHandleAllScriptExceptionCodes.
@Test
public void shouldHandleAllScriptExceptionCodes() throws Exception {
for (ScriptErrorCode errorCode : ScriptErrorCode.values()) {
// when
ResourceException re = mappingHandler.handleError(new ScriptException(errorCode));
// then
assertNotNull(re);
assertNotNull(re.getMessage());
assertTrue(isClientError(re.getCode()) || re.isServerError());
}
}
Aggregations