### Question:
AbstractRestAuthCallbackHandler implements RestAuthCallbackHandler<T> { final JsonValue createJsonField(String name, Object value) { return JsonValueBuilder.jsonValue() .put("name", name == null ? "" : name) .put("value", value == null ? "" : value) .build(); }  boolean updateCallbackFromRequest(HttpServletRequest request, HttpServletResponse response, T callback);  }### Answer:
@Test public void shouldCreateJsonField() { String name = "NAME"; String value = "VALUE"; JsonValue jsonObject = abstractRestAuthCallbackHandler.createJsonField(name, value); assertEquals(jsonObject.get("name").asString(), "NAME"); assertEquals(jsonObject.get("value").asString(), "VALUE"); }
@Test public void shouldCreateJsonFieldWithNullValue() throws JSONException { String name = "NAME"; String value = null; JsonValue jsonObject = abstractRestAuthCallbackHandler.createJsonField(name, value); assertEquals(jsonObject.get("name").asString(), "NAME"); assertEquals(jsonObject.get("value").asString(), ""); }
@Test public void shouldCreateJsonFieldWithObjectArray() { String name = "NAME"; String[] values = new String[]{"VALUE1", "VALUE2", "VALUE3"}; JsonValue jsonObject = abstractRestAuthCallbackHandler.createJsonField(name, values); assertEquals(jsonObject.get("name").asString(), "NAME"); assertEquals(jsonObject.get("value").get(0).asString(), "VALUE1"); assertEquals(jsonObject.get("value").get(1).asString(), "VALUE2"); assertEquals(jsonObject.get("value").get(2).asString(), "VALUE3"); }
@Test public void shouldCreateJsonFieldWithNullObjectArray() { String name = "NAME"; String[] values = null; JsonValue jsonObject = abstractRestAuthCallbackHandler.createJsonField(name, values); assertEquals(jsonObject.get("name").asString(), "NAME"); assertEquals(jsonObject.get("value").size(), 0); }