mirror of https://github.com/apache/nifi.git
NIFI-2060 - fixed unit tests to be compatible with 2.7.x
This closes #547
This commit is contained in:
parent
372a316deb
commit
8c011d91e1
|
@ -133,7 +133,7 @@ public class TestGetHDFSEvents {
|
|||
runner.run();
|
||||
|
||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(GetHDFSEvents.REL_SUCCESS);
|
||||
assertEquals(6, successfulFlowFiles.size());
|
||||
assertEquals(3, successfulFlowFiles.size());
|
||||
verify(eventBatch).getTxid();
|
||||
assertEquals("100", runner.getProcessContext().getStateManager().getState(Scope.CLUSTER).get("last.tx.id"));
|
||||
}
|
||||
|
@ -176,13 +176,13 @@ public class TestGetHDFSEvents {
|
|||
TestRunner runner = TestRunners.newTestRunner(processor);
|
||||
|
||||
runner.setProperty(GetHDFSEvents.HDFS_PATH_TO_WATCH, "/some/path(/.*)?");
|
||||
runner.setProperty(GetHDFSEvents.EVENT_TYPES, "create, metadata, rename");
|
||||
runner.setProperty(GetHDFSEvents.EVENT_TYPES, "create, metadata");
|
||||
runner.run();
|
||||
|
||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(GetHDFSEvents.REL_SUCCESS);
|
||||
assertEquals(3, successfulFlowFiles.size());
|
||||
assertEquals(2, successfulFlowFiles.size());
|
||||
|
||||
List<String> expectedEventTypes = Arrays.asList("CREATE", "METADATA", "RENAME");
|
||||
List<String> expectedEventTypes = Arrays.asList("CREATE", "METADATA");
|
||||
for (MockFlowFile f : successfulFlowFiles) {
|
||||
String eventType = f.getAttribute(EventAttributes.EVENT_TYPE);
|
||||
assertTrue(expectedEventTypes.contains(eventType));
|
||||
|
@ -195,9 +195,9 @@ public class TestGetHDFSEvents {
|
|||
@Test
|
||||
public void makeSureExpressionLanguageIsWorkingProperlyWithinTheHdfsPathToWatch() throws Exception {
|
||||
Event[] events = new Event[] {
|
||||
new Event.AppendEvent("/some/path/1/2/3/t.txt"),
|
||||
new Event.AppendEvent("/some/path/1/2/4/t.txt"),
|
||||
new Event.AppendEvent("/some/path/1/2/3/.t.txt")
|
||||
new Event.CreateEvent.Builder().path("/some/path/1/2/3/t.txt").build(),
|
||||
new Event.CreateEvent.Builder().path("/some/path/1/2/4/t.txt").build(),
|
||||
new Event.CreateEvent.Builder().path("/some/path/1/2/3/.t.txt").build()
|
||||
};
|
||||
|
||||
EventBatch eventBatch = mock(EventBatch.class);
|
||||
|
@ -211,7 +211,7 @@ public class TestGetHDFSEvents {
|
|||
TestRunner runner = TestRunners.newTestRunner(processor);
|
||||
|
||||
runner.setProperty(GetHDFSEvents.HDFS_PATH_TO_WATCH, "/some/path/${literal(1)}/${literal(2)}/${literal(3)}/.*.txt");
|
||||
runner.setProperty(GetHDFSEvents.EVENT_TYPES, "append");
|
||||
runner.setProperty(GetHDFSEvents.EVENT_TYPES, "create");
|
||||
runner.setProperty(GetHDFSEvents.IGNORE_HIDDEN_FILES, "true");
|
||||
runner.run();
|
||||
|
||||
|
@ -220,7 +220,7 @@ public class TestGetHDFSEvents {
|
|||
|
||||
for (MockFlowFile f : successfulFlowFiles) {
|
||||
String eventType = f.getAttribute(EventAttributes.EVENT_TYPE);
|
||||
assertTrue(eventType.equals("APPEND"));
|
||||
assertTrue(eventType.equals("CREATE"));
|
||||
}
|
||||
|
||||
verify(eventBatch).getTxid();
|
||||
|
@ -231,10 +231,7 @@ public class TestGetHDFSEvents {
|
|||
return new Event[]{
|
||||
EventTestUtils.createCreateEvent(),
|
||||
EventTestUtils.createCloseEvent(),
|
||||
EventTestUtils.createAppendEvent(),
|
||||
EventTestUtils.createRenameEvent(),
|
||||
EventTestUtils.createMetadataUpdateEvent(),
|
||||
EventTestUtils.createUnlinkEvent()
|
||||
EventTestUtils.createMetadataUpdateEvent()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,14 +47,6 @@ public class EventTestUtils {
|
|||
return new Event.CloseEvent("/some/path/close", 1L, 2L);
|
||||
}
|
||||
|
||||
public static Event.AppendEvent createAppendEvent() {
|
||||
return new Event.AppendEvent("/some/path/append");
|
||||
}
|
||||
|
||||
public static Event.RenameEvent createRenameEvent() {
|
||||
return new Event.RenameEvent("/some/path/rename/src", "/some/path/rename/dest", 200L);
|
||||
}
|
||||
|
||||
public static Event.MetadataUpdateEvent createMetadataUpdateEvent() {
|
||||
return new Event.MetadataUpdateEvent.Builder()
|
||||
.replication(0)
|
||||
|
@ -70,8 +62,4 @@ public class EventTestUtils {
|
|||
.xAttrsRemoved(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static Event.UnlinkEvent createUnlinkEvent() {
|
||||
return new Event.UnlinkEvent("/some/path/unlink", 300L);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue