Source:
<code>public void testDocAnnotations() throws Exception { String file1 = "package test1;\n" + " \n\n" + "message X {\n" + " \n" + " optional int32 field1 = 1;\n" + "}\n"; FileDescriptorSource fileDescriptorSource = new FileDescriptorSource(); fileDescriptorSource.addProtoFile("file1.proto", file1); Map<String, FileDescriptor> descriptors = parseAndResolve(fileDescriptorSource); assertEquals(1, descriptors.size()); assertTrue(descriptors.containsKey("file1.proto")); Map<String, GenericDescriptor> types = descriptors.get("file1.proto").getTypes(); Descriptor typeX = (Descriptor) types.get("test1.X"); assertNotNull(typeX); assertEquals(1, typeX.getFields().size()); FieldDescriptor field1 = typeX.getFields().get(0); assertEquals("@Indexed(Index.YES) \n some more doc text", typeX.getDocumentation()); <START> Map<String, AnnotationElement.Annotation> typeAnnotations = typeX.getAnnotations(); <END> assertEquals("@Field(Stored.NO)", field1.getDocumentation()); Map<String, AnnotationElement.Annotation> fieldAnnotations = field1.getAnnotations(); }</code><technical_language>Missing assertion</technical_language>

Target:
public void testDocAnnotations() throws Exception { String file1 = "package test1;\n" + " \n\n" + "message X {\n" + " \n" + " optional int32 field1 = 1;\n" + "}\n"; Configuration config = new Configuration.Builder() .messageAnnotation("Foo") .attribute(AnnotationElement.Annotation.DEFAULT_ATTRIBUTE) .identifierType() .annotationMetadataCreator(new AnnotationMetadataCreator<Object, Descriptor>() { @Override public Object create(Descriptor descriptor, AnnotationElement.Annotation annotation) { AnnotationElement.Value value = annotation.getDefaultAttributeValue(); return value == null ? null : value.getValue(); } }) .fieldAnnotation("Bar") .attribute(AnnotationElement.Annotation.DEFAULT_ATTRIBUTE) .identifierType() .annotationMetadataCreator(new AnnotationMetadataCreator<Object, FieldDescriptor>() { @Override public Object create(FieldDescriptor fieldDescriptor, AnnotationElement.Annotation annotation) { AnnotationElement.Value value = annotation.getDefaultAttributeValue(); return value == null ? null : value.getValue(); } }) .build(); FileDescriptorSource fileDescriptorSource = new FileDescriptorSource(); fileDescriptorSource.addProtoFile("file1.proto", file1); Map<String, FileDescriptor> descriptors = new SquareProtoParser(config).parseAndResolve(fileDescriptorSource); assertEquals(1, descriptors.size()); assertTrue(descriptors.containsKey("file1.proto")); Map<String, GenericDescriptor> types = descriptors.get("file1.proto").getTypes(); Descriptor typeX = (Descriptor) types.get("test1.X"); assertNotNull(typeX); assertEquals(1, typeX.getFields().size()); FieldDescriptor field1 = typeX.getFields().get(0); assertEquals("@Foo(fooValue) \n some more doc text", typeX.getDocumentation()); Map<String, AnnotationElement.Annotation> typeAnnotations = typeX.getAnnotations(); assertEquals("fooValue", typeAnnotations.get("Foo").getDefaultAttributeValue().getValue()); assertEquals("fooValue", typeX.getParsedAnnotation("Foo")); assertEquals("@Bar(barValue)", field1.getDocumentation()); Map<String, AnnotationElement.Annotation> fieldAnnotations = field1.getAnnotations(); assertEquals("barValue", fieldAnnotations.get("Bar").getDefaultAttributeValue().getValue()); assertEquals("barValue", field1.getParsedAnnotation("Bar")); }