### Question:
SchemaUpdate implements UpdateSchema { private static Types.StructType addFields(Types.StructType struct, Collection<Types.NestedField> adds) { List<Types.NestedField> newFields = Lists.newArrayList(struct.fields()); newFields.addAll(adds); return Types.StructType.of(newFields); } SchemaUpdate(TableOperations ops);   SchemaUpdate(Schema schema, int lastColumnId); @Override UpdateSchema addColumn(String name, Type type); @Override UpdateSchema addColumn(String parent, String name, Type type); @Override UpdateSchema deleteColumn(String name); @Override UpdateSchema renameColumn(String name, String newName); @Override UpdateSchema updateColumn(String name, Type.PrimitiveType newType); @Override Schema apply(); @Override void commit();  }### Answer:
@Test public void testAddFields() { Schema expected = new Schema( required(1, "id", Types.IntegerType.get()), optional(2, "data", Types.StringType.get()), optional(3, "preferences", Types.StructType.of( required(8, "feature1", Types.BooleanType.get()), optional(9, "feature2", Types.BooleanType.get()) )), required(4, "locations", Types.MapType.ofRequired(10, 11, Types.StructType.of( required(20, "address", Types.StringType.get()), required(21, "city", Types.StringType.get()), required(22, "state", Types.StringType.get()), required(23, "zip", Types.IntegerType.get()) ), Types.StructType.of( required(12, "lat", Types.FloatType.get()), required(13, "long", Types.FloatType.get()), optional(25, "alt", Types.FloatType.get()) ))), optional(5, "points", Types.ListType.ofOptional(14, Types.StructType.of( required(15, "x", Types.LongType.get()), required(16, "y", Types.LongType.get()), optional(26, "z", Types.LongType.get()), optional(27, "t.t", Types.LongType.get()) ))), required(6, "doubles", Types.ListType.ofRequired(17, Types.DoubleType.get() )), optional(7, "properties", Types.MapType.ofOptional(18, 19, Types.StringType.get(), Types.StringType.get() )), optional(24, "toplevel", Types.DecimalType.of(9, 2)) ); Schema added = new SchemaUpdate(SCHEMA, SCHEMA_LAST_COLUMN_ID) .addColumn("toplevel", Types.DecimalType.of(9, 2)) .addColumn("locations", "alt", Types.FloatType.get()) .addColumn("points", "z", Types.LongType.get()) .addColumn("points", "t.t", Types.LongType.get()) .apply(); Assert.assertEquals("Should match with added fields", expected.asStruct(), added.asStruct()); }