use of ch.jalu.configme.SettingsHolder in project AuthMeReloaded by AuthMe.
the class SettingsClassConsistencyTest method shouldHaveAllClassesInConfigurationData.
/**
* Checks that {@link AuthMeSettingsRetriever} returns a ConfigurationData with all
* available SettingsHolder classes.
*/
@Test
public void shouldHaveAllClassesInConfigurationData() {
// given
long totalProperties = classes.stream().map(Class::getDeclaredFields).flatMap(Arrays::stream).filter(field -> Property.class.isAssignableFrom(field.getType())).count();
// when
ConfigurationData configData = AuthMeSettingsRetriever.buildConfigurationData();
// then
assertThat("ConfigurationData should have " + totalProperties + " properties (as found manually)", configData.getProperties(), hasSize((int) totalProperties));
}
use of ch.jalu.configme.SettingsHolder in project AuthMeReloaded by AuthMe.
the class SettingsClassConsistencyTest method scanForSettingsClasses.
@BeforeClass
public static void scanForSettingsClasses() {
ClassCollector collector = new ClassCollector(TestHelper.SOURCES_FOLDER, SETTINGS_FOLDER);
classes = collector.collectClasses(SettingsHolder.class);
if (classes.isEmpty()) {
throw new IllegalStateException("Did not find any SettingsHolder classes. Is the folder correct?");
}
System.out.println("Found " + classes.size() + " SettingsHolder implementations");
}
use of ch.jalu.configme.SettingsHolder 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());
}
Aggregations