SchemaParser { public Schema parse() throws IOException { SchemaProducer producer = new SchemaProducer(); Annotations incrAnnotations = new Annotations(); parse(producer, incrAnnotations); return producer.getSchema().addAnnotations(incrAnnotations); } SchemaParser(Reader reader); Schema parse(); void parse(SchemaVisitor sv, Annotations incrAnnotations); static Schema parse(String s);  }
@Test public void testGroupDefPlain() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Message", -1, null, Collections.emptyList(), null, null) ), null), SchemaParser.parse("Message")); }
@Test public void testGroupDefWithAnnotation() throws IOException { Map<String,String> annotations = new HashMap<>(); annotations.put("key", "value"); assertEquals( new Schema( Arrays.asList( new GroupDef("Message", -1, null, Collections.emptyList(), annotations, null) ), null), SchemaParser.parse("@key=\"value\" Message")); }
@Test public void testGroupDefWithId1() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Message", 1, null, Collections.emptyList(), null, null) ), null), SchemaParser.parse("Message/1")); }
@Test public void testGroupDefWithId12() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Message", 12, null, Collections.emptyList(), null, null) ), null), SchemaParser.parse("Message/12")); }
@Test public void testGroupDefSuper() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Foo", -1, "Bar", Collections.emptyList(), null, null), new GroupDef("Bar", -1, null, Collections.emptyList(), null, null) ), null), SchemaParser.parse("Foo:Bar Bar")); }
@Test public void testGroupDefSuperWithId1() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Foo", 1, "Bar", Collections.emptyList(), null, null), new GroupDef("Bar", -1, null, Collections.emptyList(), null, null) ), null), SchemaParser.parse("Foo/1:Bar Bar")); }
@Test public void testGroupDefOneField() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Message", -1, null, Arrays.asList(new FieldDef("i", -1, true, TypeDef.INT8, null, null)), null, null) ), null), SchemaParser.parse("Message -> i8 i")); }
@Test public void testGroupDefTwoFields() throws IOException { assertEquals( new Schema( Arrays.asList( new GroupDef("Message", -1, null, Arrays.asList( new FieldDef("i", -1, true, TypeDef.INT8, null, null), new FieldDef("x", -1, true, TypeDef.STRING, null, null) ), null, null) ), null), SchemaParser.parse("Message -> i8 i, string x")); }
@Test(expected = IOException.class) public void testGroupDefWithErrorId() throws IOException { SchemaParser.parse("Message/abc"); }
@Test(expected = IOException.class) public void testGroupDefWithErrorName() throws IOException { SchemaParser.parse("123Message"); }