Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/321#discussion_r59908921
--- Diff: nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java ---
@@ -865,4 +866,21 @@
* @return the State Manager that is used to store and retrieve state
for the given controller service
*/
MockStateManager getStateManager(ControllerService service);
+
+ /**
+ * Maybe we should add possibility to be more precise:
+ * "All FlowFiles must meet all conditions"
+ * or
+ * "At least one FlowFile must meet all conditions"
+ * or
+ * "Each FlowFile should meet at least one condition"
+ *
+ * Current functionality is: "Each FlowFile should meet at least one
condition"
+ * So instead of assertAllConditionsMet we should use something like
assertFlowFileMeetAnyCondition
+ * Or add extra parameter which specifies how FlowFile must meet
conditions.
+ *
+ */
+ void assertAllConditionsMet(final String relationshipName,
ConditionsBuilder... andContentEqual);
--- End diff --
I wonder if rather than using a ConditionsBuilder, perhaps we should be
taking in a Predicate here instead?
We could then supply isXX() Methods on FlowFile, such as isContentEqual()
For instance,
`void assertAllConditionsMet(String relationshipName,
Predicate<MockFlowFile> predicate);`
This way, we can easily chain together conditions if we want by using one
of:
```
runner.assertAllConditionsMet(MY_RELATIONSHIP, mff ->
mff.isAttributeEqual("aa", "bb")
&& mff.isContentEqual("hello"));
```
Additionally, if we needed to combine these programmatically, we could do
so with something like:
```
Predicate<MockFlowFile> firstPredicate = mff -> mff.isAttributeEqual("aa",
"bb");
Predicate<MockFlowFile> secondPredicate = mff ->
mff.isContentEqual("hello");
Predicate<MockFlowFile> all = firstPredicate.and(secondPredicate);
Predicate<MockFlowFile> any = firstPredicate.or(secondPredicate);
```
In addition to asserting that all conditions are met, I think a very
valuable method/test would be to indicate that all conditions are met exactly
once.
Thoughts?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---