use of org.infinispan.protostream.impl.parser.SquareProtoParser in project protostream by infinispan.
the class ProtoSchemaBuilderTest method testDocumentation.
@Test
public void testDocumentation() throws Exception {
SerializationContext ctx = createContext();
ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
String schemaFile = protoSchemaBuilder.fileName("test1.proto").packageName("test_package1").addClass(TestEnum.class).addClass(TestClass.class).build(ctx);
FileDescriptorSource fileDescriptorSource = FileDescriptorSource.fromString("test1.proto", schemaFile);
Map<String, FileDescriptor> fileDescriptors = new SquareProtoParser(ctx.getConfiguration()).parse(fileDescriptorSource);
FileDescriptor fd = fileDescriptors.get("test1.proto");
assertNotNull(fd);
Map<String, EnumDescriptor> enums = new HashMap<>();
for (EnumDescriptor e : fd.getEnumTypes()) {
enums.put(e.getFullName(), e);
}
Map<String, Descriptor> messages = new HashMap<>();
for (Descriptor m : fd.getMessageTypes()) {
messages.put(m.getFullName(), m);
}
EnumDescriptor testEnum = enums.get("test_package1.TestEnumABC");
assertNotNull(testEnum);
assertEquals("bla bla bla\nand some more bla\n@TypeId(100777)", testEnum.getDocumentation());
assertEquals("This should never be read.", testEnum.getValues().get(0).getDocumentation());
Descriptor testClass = messages.get("test_package1.TestClass");
assertNotNull(testClass);
assertEquals("@Indexed()\nbla bla bla\nand some more bla", testClass.getDocumentation());
assertEquals("The surname, of course", testClass.getFields().get(0).getDocumentation());
}
Aggregations