### Question:
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(HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, LanguageCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(LanguageCallback callback, int index); LanguageCallback convertFromJson(LanguageCallback callback, JsonValue jsonCallback);  }### Answer:
@Test public void shouldConvertToJsonWhenLocaleNotSet() throws RestAuthException { LanguageCallback languageCallback = new LanguageCallback(); JsonValue jsonObject = restAuthLanguageCallbackHandler.convertToJson(languageCallback, 1); assertEquals(1, jsonObject.size()); assertEquals("LanguageCallback", jsonObject.get("type").asString()); }
@Test public void shouldConvertToJson() throws RestAuthException { 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()); }