tpalfy commented on code in PR #6349:
URL: https://github.com/apache/nifi/pull/6349#discussion_r959658184
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestTailFile.java:
##########
@@ -1338,6 +1369,21 @@ public void testMigrateFrom100To110FileNotFound() throws
IOException {
runner.assertTransferCount(TailFile.REL_SUCCESS, 0);
}
+ private void assertNumberOfStateMapEntries(int expectedNumberOfLogFiles)
throws IOException {
+ final int numberOfStateKeysPerFile = 6;
+ StateMap states = runner.getStateManager().getState(Scope.LOCAL);
+ assertEquals(numberOfStateKeysPerFile * expectedNumberOfLogFiles,
states.toMap().size());
+ }
+
+ private void assertFilenamesInStateMap(List<String> expectedFilenames)
throws IOException {
+ StateMap states = runner.getStateManager().getState(Scope.LOCAL);
+ List<String> filenames = states.toMap().entrySet().stream()
+ .filter(entry -> entry.getKey().endsWith("filename"))
+ .map(Entry::getValue)
+ .collect(Collectors.toList());
+ assertEquals(expectedFilenames, filenames);
+ }
Review Comment:
Tests fail because the order or file names in `filenames` is not ensured.
```suggestion
private void assertFilenamesInStateMap(Collection<String>
expectedFilenames) throws IOException {
StateMap states = runner.getStateManager().getState(Scope.LOCAL);
Set<String> actualFileNames = states.toMap().entrySet().stream()
.filter(entry -> entry.getKey().endsWith("filename"))
.map(Entry::getValue)
.collect(Collectors.toSet());
assertEquals(new HashSet<>(expectedFilenames), actualFileNames);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]