### Question:
DescriptorExtractor { public static List<FieldDescriptor> extract(AbstractFieldsSnippet snippet) { try { Method getFieldDescriptors = AbstractFieldsSnippet.class.getDeclaredMethod("getFieldDescriptors"); getFieldDescriptors.setAccessible(true); return (List<FieldDescriptor>) getFieldDescriptors.invoke(snippet); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { e.printStackTrace(); } return emptyList(); }  static List<FieldDescriptor> extract(AbstractFieldsSnippet snippet); static List<LinkDescriptor> extract(LinksSnippet snippet); static List<HeaderDescriptor> extract(AbstractHeadersSnippet snippet); static List<ParameterDescriptor> extract(AbstractParametersSnippet snippet);  }### Answer:
@Test public void should_extract_request_field_descriptors() { RequestFieldsSnippet snippet = requestFields( fieldWithPath("object.field").description("Is documented!") ); List<FieldDescriptor> descriptors = extract(snippet); then(descriptors).hasSize(1); then(descriptors.get(0).getPath()).isEqualTo("object.field"); then(descriptors.get(0).getDescription()).isEqualTo("Is documented!"); }
@Test public void should_extract_response_field_descriptors() { ResponseFieldsSnippet snippet = responseFields( fieldWithPath("object.field").description("Is documented!"), fieldWithPath("object.anotherField").description("Is documented, too!") ); List<FieldDescriptor> descriptors = extract(snippet); then(descriptors).hasSize(2); then(descriptors.stream().map(FieldDescriptor::getPath).collect(toList())) .containsExactly("object.field", "object.anotherField"); then(descriptors.stream().map(AbstractDescriptor::getDescription).collect(toList())) .containsExactly("Is documented!", "Is documented, too!"); }
@Test public void should_extract_link_descriptors() { LinksSnippet snippet = links( linkWithRel("self").description("Is documented!") ); List<LinkDescriptor> descriptors = extract(snippet); then(descriptors).hasSize(1); then(descriptors.get(0).getRel()).isEqualTo("self"); then(descriptors.get(0).getDescription()).isEqualTo("Is documented!"); }
@Test public void should_extract_request_parameter_descriptors() { RequestParametersSnippet snippet = requestParameters( parameterWithName("page").description("Is documented!"), parameterWithName("elementsPerPage").description("Is documented!") ); List<ParameterDescriptor> descriptors = extract(snippet); then(descriptors).hasSize(2); then(descriptors.stream().map(ParameterDescriptor::getName).collect(toList())) .containsExactly("page", "elementsPerPage"); then(descriptors.stream().map(AbstractDescriptor::getDescription).collect(toList())) .containsExactly("Is documented!", "Is documented!"); }