use of ch.jalu.configme.SectionComments in project AuthMeReloaded by AuthMe.
the class SettingsConsistencyTest method getSectionCommentMethods.
/**
* Gets all {@link SectionComments} methods from {@link SettingsHolder} implementations.
*/
@SuppressWarnings("unchecked")
private List<Method> getSectionCommentMethods() {
// Find all SettingsHolder classes
List<Class<? extends SettingsHolder>> settingsClasses = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT + "settings/properties/").collectClasses(SettingsHolder.class);
checkArgument(!settingsClasses.isEmpty(), "Could not find any SettingsHolder classes");
// Find all @SectionComments methods in these classes
return settingsClasses.stream().map(Class::getDeclaredMethods).flatMap(Arrays::stream).filter(method -> method.isAnnotationPresent(SectionComments.class)).collect(Collectors.toList());
}
use of ch.jalu.configme.SectionComments in project AuthMeReloaded by AuthMe.
the class SettingsConsistencyTest method shouldNotHaveVeryLongSectionCommentLines.
@Test
public void shouldNotHaveVeryLongSectionCommentLines() {
// given
List<Method> sectionCommentMethods = getSectionCommentMethods();
Set<Method> badMethods = new HashSet<>();
// when
for (Method method : sectionCommentMethods) {
boolean hasTooLongLine = getSectionComments(method).stream().anyMatch(line -> line.length() > MAX_COMMENT_LENGTH);
if (hasTooLongLine) {
badMethods.add(method);
}
}
// then
if (!badMethods.isEmpty()) {
String methodList = badMethods.stream().map(m -> m.getName() + " in " + m.getDeclaringClass().getSimpleName()).collect(Collectors.joining("\n- "));
fail("Found SectionComments methods with too long comments:\n- " + methodList);
}
}
Aggregations