mirror of https://github.com/apache/nifi.git
NIFI-10853 Allow UpdateAttribute dynamic property to validate nifi
expressions Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #6770
This commit is contained in:
parent
4d3fcb6843
commit
b7f7b411ef
|
@ -233,21 +233,14 @@ public class UpdateAttribute extends AbstractProcessor implements Searchable {
|
|||
|
||||
@Override
|
||||
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
|
||||
PropertyDescriptor.Builder propertyBuilder = new PropertyDescriptor.Builder()
|
||||
return new PropertyDescriptor.Builder()
|
||||
.name(propertyDescriptorName)
|
||||
.required(false)
|
||||
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
|
||||
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
|
||||
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
||||
.dynamic(true);
|
||||
|
||||
if (stateful) {
|
||||
return propertyBuilder
|
||||
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
|
||||
.build();
|
||||
} else {
|
||||
return propertyBuilder
|
||||
.build();
|
||||
}
|
||||
.dynamic(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -151,6 +151,13 @@ public class TestUpdateAttribute {
|
|||
runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS).get(0).assertAttributeEquals("NewAttr", "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAttributeWithIncorrectExpression() throws Exception {
|
||||
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
||||
runner.setProperty("NewId", "${UUID(}");
|
||||
runner.assertNotValid();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicState() throws Exception {
|
||||
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
||||
|
|
Loading…
Reference in New Issue