### Question:
StripeJsonUtils { @Nullable @SuppressWarnings("unchecked") static JSONArray listToJsonArray(@Nullable List values) { if (values == null) { return null; } JSONArray jsonArray = new JSONArray(); for (Object object : values) { if (object instanceof Map<?, ?>) { try { Map<String, Object> mapObject = (Map<String, Object>) object; jsonArray.put(mapToJsonObject(mapObject)); } catch (ClassCastException classCastException) { } } else if (object instanceof List<?>) { jsonArray.put(listToJsonArray((List) object)); } else if (object instanceof Number || object instanceof Boolean) { jsonArray.put(object); } else { jsonArray.put(object.toString()); } } return jsonArray; }    }### Answer:
@Test public void listToJsonArray_forNull_returnsNull() { assertNull(StripeJsonUtils.listToJsonArray(null)); }
@Test public void listToJsonArray_forSimpleList_returnsExpectedArray() { List<Object> testList = new ArrayList<>(); testList.add(1); testList.add(2); testList.add(3); testList.add("a"); testList.add(true); testList.add("cde"); try { JSONArray expectedJsonArray = new JSONArray(SIMPLE_JSON_TEST_ARRAY); JSONArray testJsonArray = StripeJsonUtils.listToJsonArray(testList); JsonTestUtils.assertJsonArrayEquals(expectedJsonArray, testJsonArray); } catch (JSONException jsonException) { fail("Test data failure " + jsonException.getLocalizedMessage()); } }