NIFI-5871 ignore UUID attribute when copying flow file attributes (#3203)

NIFI-5871 ignore UUID attribute when copying flow file attributes

Signed-off-by: Peter Wicks <patricker@gmail.com>
This commit is contained in:
SavtechSolutions 2018-12-20 12:05:25 -05:00 committed by Peter Wicks
parent f22a6c46ad
commit f9f386b0f0
3 changed files with 8 additions and 14 deletions

View File

@ -496,7 +496,14 @@ public class MockProcessSession implements ProcessSession {
final MockFlowFile newFlowFile = new MockFlowFile(mock.getId(), flowFile); final MockFlowFile newFlowFile = new MockFlowFile(mock.getId(), flowFile);
currentVersions.put(newFlowFile.getId(), newFlowFile); currentVersions.put(newFlowFile.getId(), newFlowFile);
newFlowFile.putAttributes(attrs); final Map<String, String> updatedAttributes;
if (attrs.containsKey(CoreAttributes.UUID.key())) {
updatedAttributes = new HashMap<>(attrs);
updatedAttributes.remove(CoreAttributes.UUID.key());
} else {
updatedAttributes = attrs;
}
newFlowFile.putAttributes(updatedAttributes);
return newFlowFile; return newFlowFile;
} }

View File

@ -268,7 +268,6 @@ public class TestPutCouchbaseKey {
ArgumentCaptor<RawJsonDocument> capture = ArgumentCaptor.forClass(RawJsonDocument.class); ArgumentCaptor<RawJsonDocument> capture = ArgumentCaptor.forClass(RawJsonDocument.class);
verify(bucket, times(1)).upsert(capture.capture(), eq(PersistTo.NONE), eq(ReplicateTo.NONE)); verify(bucket, times(1)).upsert(capture.capture(), eq(PersistTo.NONE), eq(ReplicateTo.NONE));
assertEquals(uuid, capture.getValue().id());
assertEquals(inFileData, capture.getValue().content()); assertEquals(inFileData, capture.getValue().content());
testRunner.assertTransferCount(REL_SUCCESS, 1); testRunner.assertTransferCount(REL_SUCCESS, 1);

View File

@ -218,7 +218,6 @@ public class TestWait {
waitAttributes.put("releaseSignalAttribute", "key"); waitAttributes.put("releaseSignalAttribute", "key");
waitAttributes.put("wait.only", "waitValue"); waitAttributes.put("wait.only", "waitValue");
waitAttributes.put("both", "waitValue"); waitAttributes.put("both", "waitValue");
waitAttributes.put("uuid", UUID.randomUUID().toString());
String flowFileContent = "content"; String flowFileContent = "content";
runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes); runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
@ -234,8 +233,6 @@ public class TestWait {
// show a new attribute was copied from the cache // show a new attribute was copied from the cache
assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only")); assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only"));
// show that uuid was not overwritten
assertEquals(waitAttributes.get("uuid"), outputFlowFile.getAttribute("uuid"));
// show that the original attributes are still there // show that the original attributes are still there
assertEquals("waitValue", outputFlowFile.getAttribute("wait.only")); assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
@ -265,7 +262,6 @@ public class TestWait {
waitAttributes.put("releaseSignalAttribute", "key"); waitAttributes.put("releaseSignalAttribute", "key");
waitAttributes.put("wait.only", "waitValue"); waitAttributes.put("wait.only", "waitValue");
waitAttributes.put("both", "waitValue"); waitAttributes.put("both", "waitValue");
waitAttributes.put("uuid", UUID.randomUUID().toString());
String flowFileContent = "content"; String flowFileContent = "content";
runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes); runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
@ -278,8 +274,6 @@ public class TestWait {
// show a new attribute was copied from the cache // show a new attribute was copied from the cache
assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only")); assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only"));
// show that uuid was not overwritten
assertEquals(waitAttributes.get("uuid"), outputFlowFile.getAttribute("uuid"));
// show that the original attributes are still there // show that the original attributes are still there
assertEquals("waitValue", outputFlowFile.getAttribute("wait.only")); assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
@ -307,7 +301,6 @@ public class TestWait {
waitAttributes.put("targetSignalCount", "3"); waitAttributes.put("targetSignalCount", "3");
waitAttributes.put("wait.only", "waitValue"); waitAttributes.put("wait.only", "waitValue");
waitAttributes.put("both", "waitValue"); waitAttributes.put("both", "waitValue");
waitAttributes.put("uuid", UUID.randomUUID().toString());
String flowFileContent = "content"; String flowFileContent = "content";
runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes); runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
@ -359,8 +352,6 @@ public class TestWait {
// show a new attribute was copied from the cache // show a new attribute was copied from the cache
assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only")); assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only"));
// show that uuid was not overwritten
assertEquals(waitAttributes.get("uuid"), outputFlowFile.getAttribute("uuid"));
// show that the original attributes are still there // show that the original attributes are still there
assertEquals("waitValue", outputFlowFile.getAttribute("wait.only")); assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
// show that the original attribute is kept // show that the original attribute is kept
@ -391,7 +382,6 @@ public class TestWait {
waitAttributes.put("signalCounterName", "counter-B"); waitAttributes.put("signalCounterName", "counter-B");
waitAttributes.put("wait.only", "waitValue"); waitAttributes.put("wait.only", "waitValue");
waitAttributes.put("both", "waitValue"); waitAttributes.put("both", "waitValue");
waitAttributes.put("uuid", UUID.randomUUID().toString());
String flowFileContent = "content"; String flowFileContent = "content";
runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes); runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
@ -446,8 +436,6 @@ public class TestWait {
// show a new attribute was copied from the cache // show a new attribute was copied from the cache
assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only")); assertEquals("notifyValue", outputFlowFile.getAttribute("notify.only"));
// show that uuid was not overwritten
assertEquals(waitAttributes.get("uuid"), outputFlowFile.getAttribute("uuid"));
// show that the original attributes are still there // show that the original attributes are still there
assertEquals("waitValue", outputFlowFile.getAttribute("wait.only")); assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
// show that the original attribute is kept // show that the original attribute is kept