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
|
@Override
|
||||||
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
|
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
|
||||||
PropertyDescriptor.Builder propertyBuilder = new PropertyDescriptor.Builder()
|
return new PropertyDescriptor.Builder()
|
||||||
.name(propertyDescriptorName)
|
.name(propertyDescriptorName)
|
||||||
.required(false)
|
.required(false)
|
||||||
|
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
|
||||||
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
|
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
|
||||||
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
||||||
.dynamic(true);
|
.dynamic(true)
|
||||||
|
|
||||||
if (stateful) {
|
|
||||||
return propertyBuilder
|
|
||||||
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
|
|
||||||
.build();
|
.build();
|
||||||
} else {
|
|
||||||
return propertyBuilder
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -151,6 +151,13 @@ public class TestUpdateAttribute {
|
||||||
runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS).get(0).assertAttributeEquals("NewAttr", "3");
|
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
|
@Test
|
||||||
public void testBasicState() throws Exception {
|
public void testBasicState() throws Exception {
|
||||||
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
||||||
|
|
Loading…
Reference in New Issue