### Question:
DocumentationExtractor { public static String getDocumentation(ProtoDoc[] annotations) { int start = 0; while (start < annotations.length && annotations[start].value().isEmpty()) { start++; } int end = annotations.length; while (end > start && annotations[end - 1].value().isEmpty()) { end--; } StringBuilder sb = null; for (int i = start; i < end; i++) { if (sb == null) { sb = new StringBuilder(); } else { sb.append('\n'); } sb.append(annotations[i].value()); } return sb == null ? null : sb.toString(); }  static String getDocumentation(ProtoDoc[] annotations);  }### Answer:
@Test public void testSingleDoc1() throws Exception { String doc = DocumentationExtractor.getDocumentation(TestDocs.class.getDeclaredField("field1").getAnnotationsByType(ProtoDoc.class)); assertEquals("1", doc); }
@Test public void testSingleDoc2() throws Exception { String doc = DocumentationExtractor.getDocumentation(TestDocs.class.getDeclaredMethod("method1").getAnnotationsByType(ProtoDoc.class)); assertEquals("1", doc); }
@Test public void testMultiDoc1() throws Exception { String doc = DocumentationExtractor.getDocumentation(TestDocs.class.getDeclaredField("field2").getAnnotationsByType(ProtoDoc.class)); assertEquals("1\n2", doc); }
@Test public void testMultiDoc2() throws Exception { String doc = DocumentationExtractor.getDocumentation(TestDocs.class.getDeclaredField("field3").getAnnotationsByType(ProtoDoc.class)); assertEquals("1\n2", doc); }
@Test public void testMultiDoc3() throws Exception { String doc = DocumentationExtractor.getDocumentation(TestDocs.class.getDeclaredField("field4").getAnnotationsByType(ProtoDoc.class)); assertEquals("1", doc); }
@Test public void testMultiDoc4() throws Exception { String doc = DocumentationExtractor.getDocumentation(TestDocs.class.getDeclaredField("field5").getAnnotationsByType(ProtoDoc.class)); assertEquals("1\n\n2\n3", doc); }