@Test
public void testAddEmbeddedColumnMapping() {
ColumnMapping mapping = new ColumnMapping.Builder()
.key("id")
.column("username", "u", "username")
.column("real_name", "u", "name")
.build();
Schema original = new Schema.Parser().parse("{" +
" \"type\": \"record\"," +
" \"name\": \"User\"," +
" \"partitions\": [" +
" {\"type\": \"identity\", \"source\": \"id\", \"name\": \"id_copy\"}" +
" ]," +
" \"fields\": [" +
" {\"name\": \"id\", \"type\": \"long\"}," +
" {\"name\": \"username\", \"type\": \"string\"}," +
" {\"name\": \"real_name\", \"type\": \"string\"}" +
" ]" +
"}");
Schema embedded = ColumnMappingParser.embedColumnMapping(original, mapping);
junit.framework.Assert.assertTrue(ColumnMappingParser.hasEmbeddedColumnMapping(embedded));
junit.framework.Assert.assertEquals(mapping, ColumnMappingParser.parseFromSchema(embedded));
}