@Test (expectedExceptions = RestAuthException.class) public void shouldFailToConvertFromJsonWithInvalidType() { TextInputCallback textInputCallback = new TextInputCallback("Enter text:", "DEFAULT_VALUE"); JsonValue jsonTextInputCallback = JsonValueBuilder.jsonValue() .array("input") .addLast(JsonValueBuilder.jsonValue().put("value", "TEXT_VALUE").build()) .array("output") .add(JsonValueBuilder.jsonValue().put("value", "Enter text:").build()) .addLast(JsonValueBuilder.jsonValue().put("value", "DEFAULT_VALUE").build()) .put("type", "PasswordCallback") .build(); restAuthTextInputCallbackHandler.convertFromJson(textInputCallback, jsonTextInputCallback); fail(); }
public TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setText(value); return callback; }
RestAuthTextInputCallbackHandler extends AbstractRestAuthCallbackHandler<TextInputCallback> { public TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setText(value); return callback; } }
RestAuthTextInputCallbackHandler extends AbstractRestAuthCallbackHandler<TextInputCallback> { public TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setText(value); return callback; }  }
RestAuthTextInputCallbackHandler extends AbstractRestAuthCallbackHandler<TextInputCallback> { public TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setText(value); return callback; }  TextInputCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, TextInputCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(TextInputCallback callback, int index); TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback); }
RestAuthTextInputCallbackHandler extends AbstractRestAuthCallbackHandler<TextInputCallback> { public TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setText(value); return callback; }  TextInputCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, TextInputCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(TextInputCallback callback, int index); TextInputCallback convertFromJson(TextInputCallback callback, JsonValue jsonCallback);  }