Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-4798 allow empty value for UpdateAttribute property #6585

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -246,7 +246,6 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String
.build();
} else {
return propertyBuilder
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
}
}
Expand Down
Expand Up @@ -107,6 +107,34 @@ public void testDefault() throws Exception {
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
public void testDefaultAddAttribute() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
Expand Down