mirror of https://github.com/apache/nifi.git
NIFI-10095 Use Allowable Value Display Name for Default Value when found
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #6103.
This commit is contained in:
parent
2455ba2c45
commit
e19efa6658
|
@ -516,7 +516,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
}
|
||||
|
||||
xmlStreamWriter.writeEndElement();
|
||||
writeSimpleElement(xmlStreamWriter, "td", property.getDefaultValue(), false, "default-value");
|
||||
writeSimpleElement(xmlStreamWriter, "td", getDefaultValue(property), false, "default-value");
|
||||
xmlStreamWriter.writeStartElement("td");
|
||||
xmlStreamWriter.writeAttribute("id", "allowable-values");
|
||||
writeValidValues(xmlStreamWriter, property);
|
||||
|
@ -674,6 +674,25 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private String getDefaultValue(final PropertyDescriptor propertyDescriptor) {
|
||||
final String defaultValue;
|
||||
|
||||
final String descriptorDefaultValue = propertyDescriptor.getDefaultValue();
|
||||
|
||||
final List<AllowableValue> allowableValues = propertyDescriptor.getAllowableValues();
|
||||
if (allowableValues != null) {
|
||||
defaultValue = allowableValues.stream()
|
||||
.filter(allowableValue -> allowableValue.getValue().equals(descriptorDefaultValue))
|
||||
.findFirst()
|
||||
.map(AllowableValue::getDisplayName)
|
||||
.orElse(descriptorDefaultValue);
|
||||
} else {
|
||||
defaultValue = descriptorDefaultValue;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not the component contains at least one sensitive property.
|
||||
*
|
||||
|
|
|
@ -89,8 +89,8 @@ public class FullyDocumentedProcessor extends AbstractProcessor {
|
|||
.description("Indicates whether or not to pull files from subdirectories")
|
||||
.required(true)
|
||||
.allowableValues(
|
||||
new AllowableValue("true", "true", "Should pull from sub directories"),
|
||||
new AllowableValue("false", "false", "Should not pull from sub directories")
|
||||
new AllowableValue("true", "Enabled", "Should pull from sub directories"),
|
||||
new AllowableValue("false", "Disabled", "Should not pull from sub directories")
|
||||
)
|
||||
.defaultValue("true")
|
||||
.build();
|
||||
|
|
|
@ -94,6 +94,10 @@ public class ProcessorDocumentationWriterTest {
|
|||
assertContains(results, "Supports Expression Language: true (will be evaluated using variable registry only)");
|
||||
assertContains(results, "Supports Expression Language: true (undefined scope)");
|
||||
|
||||
// Check Property Values
|
||||
assertContains(results, "Enabled");
|
||||
assertContains(results, "0 sec");
|
||||
|
||||
// verify dynamic properties
|
||||
assertContains(results, "Routes FlowFiles to relationships based on XPath");
|
||||
|
||||
|
|
Loading…
Reference in New Issue