FieldDescriptorUtil { public static void assertAllDocumented(Collection<FieldDescriptor> fieldDescriptors, String what) { List<String> undocumentedFields = fieldDescriptors.stream() .filter(descriptor -> isBlank((String) descriptor.getDescription())) .map(FieldDescriptor::getPath) .collect(toList()); if (!undocumentedFields.isEmpty()) { throw new SnippetException( "Following " + what + " were not documented: " + undocumentedFields); } } private  FieldDescriptorUtil(); static void assertAllDocumented(Collection<FieldDescriptor> fieldDescriptors,
            String what);  }
@Test public void assertAllDocumented() throws Exception { List<FieldDescriptor> fields = new ArrayList<>(); fields.add(fieldWithPath("1").description("")); fields.add(fieldWithPath("2").description("something")); fields.add(fieldWithPath("2")); thrown.expect(SnippetException.class); thrown.expectMessage("Following fields were not documented: [1, 2]"); FieldDescriptorUtil.assertAllDocumented(fields, "fields"); }