### Question:
CsvConverters { static String buildJsonString( @Nullable List<String> headers, List<String> values, @Nullable String jsonSchemaString) throws Exception { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); if (jsonSchemaString != null) { JsonArray jsonSchema = jsonParser.parse(jsonSchemaString).getAsJsonArray(); writer.beginObject(); for (int i = 0; i < jsonSchema.size(); i++) { JsonObject jsonObject = jsonSchema.get(i).getAsJsonObject(); String type = jsonObject.get("type").getAsString().toUpperCase(); writer.name(jsonObject.get("name").getAsString()); switch (type) { case "LONG": writer.value(Long.parseLong(values.get(i))); break; case "DOUBLE": writer.value(Double.parseDouble(values.get(i))); break; case "INTEGER": writer.value(Integer.parseInt(values.get(i))); break; case "SHORT": writer.value(Short.parseShort(values.get(i))); break; case "BYTE": writer.value(Byte.parseByte(values.get(i))); break; case "FLOAT": writer.value(Float.parseFloat(values.get(i))); break; case "TEXT": case "KEYWORD": case "STRING": writer.value(values.get(i)); break; default: LOG.error("Invalid data type, got: " + type); throw new RuntimeException("Invalid data type, got: " + type); } } writer.endObject(); writer.close(); return stringWriter.toString(); } else if (headers != null) { writer.beginObject(); for (int i = 0; i < headers.size(); i++) { writer.name(headers.get(i)); writer.value(values.get(i)); } writer.endObject(); writer.close(); return stringWriter.toString(); } else { LOG.error("No headers or schema specified"); throw new RuntimeException("No headers or schema specified"); } }  static CSVFormat getCsvFormat(String formatString, @Nullable String delimiter);  }### Answer:
@Test public void testBuildJsonStringHeaders() throws Exception { List<String> headers = Arrays.asList(HEADER_STRING.split(",")); List<String> record = Arrays.asList(RECORD_STRING.split(",")); String jsonSchema = null; String json = CsvConverters.buildJsonString(headers, record, jsonSchema); assertEquals(JSON_STRINGS_RECORD, json); }