use of com.puppycrawl.tools.checkstyle.PropertyType in project checkstyle by checkstyle.
the class XdocsPagesTest method validatePropertySectionPropertyEx.
private static void validatePropertySectionPropertyEx(String fileName, String sectionName, Object instance, List<Node> columns, String propertyName) throws Exception {
assertWithMessage("%s section '%s' should have a description for %s", fileName, sectionName, propertyName).that(columns.get(1).getTextContent().trim()).isNotEmpty();
final String actualTypeName = columns.get(2).getTextContent().replace("\n", "").replace("\r", "").replaceAll(" +", " ").trim();
assertWithMessage(fileName + " section '" + sectionName + "' should have a type for " + propertyName).that(actualTypeName).isNotEmpty();
final Field field = getField(instance.getClass(), propertyName);
final Class<?> fieldClass = getFieldClass(fileName, sectionName, instance, field, propertyName);
final String expectedTypeName;
// SuppressWarningsHolder#aliasList is backed by a static (upper case) property.
if ("SuppressWarningsHolder".equals(sectionName) && "aliasList".equals(propertyName)) {
expectedTypeName = "String[] in a format of comma separated attribute=value entries. " + "The attribute is the fully qualified name of the Check and value is its alias.";
} else {
expectedTypeName = Optional.ofNullable(field).map(nonNullField -> nonNullField.getAnnotation(XdocsPropertyType.class)).map(propertyType -> propertyType.value().getDescription()).orElse(fieldClass.getSimpleName());
}
final String expectedValue = getModulePropertyExpectedValue(sectionName, propertyName, field, fieldClass, instance);
assertWithMessage(fileName + " section '" + sectionName + "' should have the type for " + propertyName).that(actualTypeName).isEqualTo(expectedTypeName);
if (expectedValue != null) {
final String actualValue = columns.get(3).getTextContent().trim().replaceAll("\\s+", " ").replaceAll("\\s,", ",");
assertWithMessage(fileName + " section '" + sectionName + "' should have the value for " + propertyName).that(actualValue).isEqualTo(expectedValue);
}
}
Aggregations