@Test public void shouldConvertToJson() { LanguageCallback languageCallback = new LanguageCallback(); languageCallback.setLocale(new Locale("LANGUAGE", "COUNTRY")); JsonValue jsonObject = restAuthLanguageCallbackHandler.convertToJson(languageCallback, 1); assertEquals(2, jsonObject.size()); assertEquals("LanguageCallback", jsonObject.get("type").asString()); assertNotNull(jsonObject.get("input")); assertEquals(2, jsonObject.get("input").size()); assertEquals("language", jsonObject.get("input").get(0).get("value").asString()); assertEquals("COUNTRY", jsonObject.get("input").get(1).get("value").asString()); }
public JsonValue convertToJson(LanguageCallback callback, int index) { Locale locale = callback.getLocale(); JsonObject jsonObject = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME); if (locale != null) { jsonObject.array("input") .add(createInputField(index, "Language", locale.getLanguage())) .addLast(createInputField(index, "Country", locale.getCountry())); } return jsonObject.build(); }
RestAuthLanguageCallbackHandler extends AbstractRestAuthCallbackHandler<LanguageCallback> { public JsonValue convertToJson(LanguageCallback callback, int index) { Locale locale = callback.getLocale(); JsonObject jsonObject = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME); if (locale != null) { jsonObject.array("input") .add(createInputField(index, "Language", locale.getLanguage())) .addLast(createInputField(index, "Country", locale.getCountry())); } return jsonObject.build(); } }
RestAuthLanguageCallbackHandler extends AbstractRestAuthCallbackHandler<LanguageCallback> { public JsonValue convertToJson(LanguageCallback callback, int index) { Locale locale = callback.getLocale(); JsonObject jsonObject = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME); if (locale != null) { jsonObject.array("input") .add(createInputField(index, "Language", locale.getLanguage())) .addLast(createInputField(index, "Country", locale.getCountry())); } return jsonObject.build(); }  }
RestAuthLanguageCallbackHandler extends AbstractRestAuthCallbackHandler<LanguageCallback> { public JsonValue convertToJson(LanguageCallback callback, int index) { Locale locale = callback.getLocale(); JsonObject jsonObject = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME); if (locale != null) { jsonObject.array("input") .add(createInputField(index, "Language", locale.getLanguage())) .addLast(createInputField(index, "Country", locale.getCountry())); } return jsonObject.build(); }  LanguageCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, LanguageCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(LanguageCallback callback, int index); LanguageCallback convertFromJson(LanguageCallback callback, JsonValue jsonCallback); }
RestAuthLanguageCallbackHandler extends AbstractRestAuthCallbackHandler<LanguageCallback> { public JsonValue convertToJson(LanguageCallback callback, int index) { Locale locale = callback.getLocale(); JsonObject jsonObject = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME); if (locale != null) { jsonObject.array("input") .add(createInputField(index, "Language", locale.getLanguage())) .addLast(createInputField(index, "Country", locale.getCountry())); } return jsonObject.build(); }  LanguageCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, LanguageCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(LanguageCallback callback, int index); LanguageCallback convertFromJson(LanguageCallback callback, JsonValue jsonCallback);  }