@Test public void shouldConvertToJson() { ConfirmationCallback confirmationCallback = new ConfirmationCallback("Select confirmation:", ConfirmationCallback.INFORMATION, new String[]{"OK", "NO", "CANCEL"}, 0); JsonValue jsonObject = restAuthConfirmationCallbackHandler.convertToJson(confirmationCallback, 1); assertEquals("ConfirmationCallback", jsonObject.get("type").asString()); assertNotNull(jsonObject.get("output")); assertEquals(5, jsonObject.get("output").size()); assertEquals("Select confirmation:", jsonObject.get("output").get(0).get("value").asString()); assertEquals(ConfirmationCallback.INFORMATION, (int)jsonObject.get("output").get(1).get("value").asInteger()); assertEquals("OK", jsonObject.get("output").get(2).get("value").get(0).asString()); assertEquals("NO", jsonObject.get("output").get(2).get("value").get(1).asString()); assertEquals("CANCEL", jsonObject.get("output").get(2).get("value").get(2).asString()); assertEquals(-1, (int) jsonObject.get("output").get(3).get("value").asInteger()); assertEquals(0, (int) jsonObject.get("output").get(4).get("value").asInteger()); assertNotNull(jsonObject.get("input")); assertEquals(1, jsonObject.get("input").size()); assertEquals(0, (int) jsonObject.get("input").get(0).get("value").asInteger()); }
public JsonValue convertToJson(ConfirmationCallback callback, int index) { String prompt = callback.getPrompt(); int messageType = callback.getMessageType(); String[] options = callback.getOptions(); int optionType = callback.getOptionType(); int defaultOption = callback.getDefaultOption(); int selectedIndex = callback.getSelectedIndex(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .add(createOutputField("prompt", prompt)) .add(createOutputField("messageType", messageType)) .add(createOutputField("options", options)) .add(createOutputField("optionType", optionType)) .addLast(createOutputField("defaultOption", defaultOption)) .array("input") .addLast(createInputField(index, selectedIndex)) .build(); return jsonValue; }
RestAuthConfirmationCallbackHandler extends AbstractRestAuthCallbackHandler<ConfirmationCallback> { public JsonValue convertToJson(ConfirmationCallback callback, int index) { String prompt = callback.getPrompt(); int messageType = callback.getMessageType(); String[] options = callback.getOptions(); int optionType = callback.getOptionType(); int defaultOption = callback.getDefaultOption(); int selectedIndex = callback.getSelectedIndex(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .add(createOutputField("prompt", prompt)) .add(createOutputField("messageType", messageType)) .add(createOutputField("options", options)) .add(createOutputField("optionType", optionType)) .addLast(createOutputField("defaultOption", defaultOption)) .array("input") .addLast(createInputField(index, selectedIndex)) .build(); return jsonValue; } }
RestAuthConfirmationCallbackHandler extends AbstractRestAuthCallbackHandler<ConfirmationCallback> { public JsonValue convertToJson(ConfirmationCallback callback, int index) { String prompt = callback.getPrompt(); int messageType = callback.getMessageType(); String[] options = callback.getOptions(); int optionType = callback.getOptionType(); int defaultOption = callback.getDefaultOption(); int selectedIndex = callback.getSelectedIndex(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .add(createOutputField("prompt", prompt)) .add(createOutputField("messageType", messageType)) .add(createOutputField("options", options)) .add(createOutputField("optionType", optionType)) .addLast(createOutputField("defaultOption", defaultOption)) .array("input") .addLast(createInputField(index, selectedIndex)) .build(); return jsonValue; }  }
RestAuthConfirmationCallbackHandler extends AbstractRestAuthCallbackHandler<ConfirmationCallback> { public JsonValue convertToJson(ConfirmationCallback callback, int index) { String prompt = callback.getPrompt(); int messageType = callback.getMessageType(); String[] options = callback.getOptions(); int optionType = callback.getOptionType(); int defaultOption = callback.getDefaultOption(); int selectedIndex = callback.getSelectedIndex(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .add(createOutputField("prompt", prompt)) .add(createOutputField("messageType", messageType)) .add(createOutputField("options", options)) .add(createOutputField("optionType", optionType)) .addLast(createOutputField("defaultOption", defaultOption)) .array("input") .addLast(createInputField(index, selectedIndex)) .build(); return jsonValue; }  ConfirmationCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, ConfirmationCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(ConfirmationCallback callback, int index); ConfirmationCallback convertFromJson(ConfirmationCallback callback, JsonValue jsonCallback); }
RestAuthConfirmationCallbackHandler extends AbstractRestAuthCallbackHandler<ConfirmationCallback> { public JsonValue convertToJson(ConfirmationCallback callback, int index) { String prompt = callback.getPrompt(); int messageType = callback.getMessageType(); String[] options = callback.getOptions(); int optionType = callback.getOptionType(); int defaultOption = callback.getDefaultOption(); int selectedIndex = callback.getSelectedIndex(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .add(createOutputField("prompt", prompt)) .add(createOutputField("messageType", messageType)) .add(createOutputField("options", options)) .add(createOutputField("optionType", optionType)) .addLast(createOutputField("defaultOption", defaultOption)) .array("input") .addLast(createInputField(index, selectedIndex)) .build(); return jsonValue; }  ConfirmationCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, ConfirmationCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(ConfirmationCallback callback, int index); ConfirmationCallback convertFromJson(ConfirmationCallback callback, JsonValue jsonCallback);  }