### Question:
ParquetUtil { public static String buildSchema(List<Field> fields) { StringBuilder sb = new StringBuilder("message row { "); for (Field field : fields) { String fieldName = field.getName(); Class<?> type = field.getJavaTypeClass(); switch (type.getSimpleName()) { case "String": sb.append("optional binary ").append(fieldName).append(" (UTF8); "); break; case "Byte": case "Short": case "Integer": sb.append("optional INT32 ").append(fieldName).append("; "); break; case "Long": case "Date": sb.append("optional INT64 ").append(fieldName).append("; "); break; case "Float": sb.append("optional FLOAT ").append(fieldName).append("; "); break; case "Double": case "BigDecimal": sb.append("optional DOUBLE ").append(fieldName).append("; "); break; case "Boolean": sb.append("optional BOOLEAN ").append(fieldName).append("; "); break; case "byte[]": sb.append("optional binary ").append(fieldName).append("; "); break; case "Map": throw new UnsupportedOperationException("this type[Map] have't support!"); default: throw new UnsupportedOperationException("this " + type + " have't support!"); } } sb.append("} "); return sb.toString(); } private  ParquetUtil(); static String buildSchema(List<Field> fields);  }### Answer:
@Test public void testBuildSchema() { List<Field> arrayList = Arrays.asList( new Field("String", String.class), new Field("Byte", Byte.class), new Field("Short", Short.class), new Field("Integer", Integer.class), new Field("Long", Long.class), new Field("Date", Date.class), new Field("Float", Float.class), new Field("Double", Double.class), new Field("BigDecimal", BigDecimal.class), new Field("Boolean", Boolean.class), new Field("byte[]", byte[].class)); String actual = "message row { optional binary String (UTF8); " + "optional INT32 Byte; optional INT32 Short; " + "optional INT32 Integer; optional INT64 Long; " + "optional INT64 Date; optional FLOAT Float; " + "optional DOUBLE Double; optional DOUBLE BigDecimal; " + "optional BOOLEAN Boolean; optional binary byte[]; } "; Assert.assertEquals(actual, ParquetUtil.buildSchema(arrayList)); }
@Test public void testBuildSchemaThrowsExceptionGiveMapType() { thrown.expect(UnsupportedOperationException.class); ParquetUtil.buildSchema(Arrays.asList(new Field("Map", Map.class))); }
@Test public void testBuildSchemaThrowsException() { thrown.expect(UnsupportedOperationException.class); ParquetUtil.buildSchema(Arrays.asList(new Field("Object", Object.class))); }