On Thu, Jul 19, 2012 at 10:32 PM, Sameer Deokule <[email protected]> wrote:
> Is this something that has been tested/used via a generic record?
I wrote the following test, added it to TestSchema.java, and it passes.
Can you provide a self-contained test that fails?
Thanks,
Doug
@Test
public void testMapInRecord2() throws Exception {
String xJson = "{\"type\":\"record\", \"name\":\"X\", \"fields\":"
+"[{\"name\":\"g\", \"type\":\"long\"}]}";
String json = "{\"type\":\"record\", \"name\":\"Test\", \"fields\":"
+"[{\"name\":\"f\", \"type\": {\"type\":\"map\", \"values\":"
+ xJson
+"}}]}";
Schema schema = Schema.parse(json);
Schema xSchema = Schema.parse(xJson);
GenericData.Record x = new GenericData.Record(xSchema);
x.put("g", 11L);
HashMap<Utf8,GenericData.Record> map=new HashMap<Utf8,GenericData.Record>();
map.put(new Utf8("a"), x);
GenericData.Record r = new GenericData.Record(schema);
r.put("f", map);
check(json, "{\"f\":{\"a\":{\"g\":11}}}", r, false);
}