mirror of https://github.com/apache/nifi.git
NIFI-4798 allow empty value for UpdateAttribute property
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #6585
This commit is contained in:
parent
19658df52b
commit
4e4f6437ee
|
@ -246,7 +246,6 @@ public class UpdateAttribute extends AbstractProcessor implements Searchable {
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
return propertyBuilder
|
return propertyBuilder
|
||||||
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,34 @@ public class TestUpdateAttribute {
|
||||||
result.get(0).assertAttributeEquals("attribute.2", "new.value.2");
|
result.get(0).assertAttributeEquals("attribute.2", "new.value.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetEmptyString() throws Exception {
|
||||||
|
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
||||||
|
runner.setProperty("attribute.1", "");
|
||||||
|
runner.assertValid();
|
||||||
|
|
||||||
|
// No attributes on flowfile
|
||||||
|
runner.enqueue(new byte[0]);
|
||||||
|
|
||||||
|
runner.run();
|
||||||
|
|
||||||
|
runner.assertAllFlowFilesTransferred(UpdateAttribute.REL_SUCCESS, 1);
|
||||||
|
List<MockFlowFile> result = runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS);
|
||||||
|
assertTrue(result.get(0).getAttribute("attribute.1").isEmpty());
|
||||||
|
runner.clearTransferState();
|
||||||
|
|
||||||
|
final Map<String, String> attributes = new HashMap<>();
|
||||||
|
attributes.put("attribute.1", "old.value.1");
|
||||||
|
// Existing attribute to be replaced on flowfile
|
||||||
|
runner.enqueue(new byte[0], attributes);
|
||||||
|
|
||||||
|
runner.run();
|
||||||
|
|
||||||
|
runner.assertAllFlowFilesTransferred(UpdateAttribute.REL_SUCCESS, 1);
|
||||||
|
result = runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS);
|
||||||
|
assertTrue(result.get(0).getAttribute("attribute.1").isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultAddAttribute() throws Exception {
|
public void testDefaultAddAttribute() throws Exception {
|
||||||
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
|
||||||
|
|
Loading…
Reference in New Issue