@Test public void testAllMatch() { final TestRunner runner = TestRunners.newTestRunner(new ScanAttribute()); runner.setProperty(ScanAttribute.DICTIONARY_FILE, "src/test/resources/ScanAttribute/dictionary1"); runner.setProperty(ScanAttribute.MATCHING_CRITERIA, ScanAttribute.MATCH_CRITERIA_ALL); runner.setProperty(ScanAttribute.ATTRIBUTE_PATTERN, "a.*"); final Map<String, String> attributes = new HashMap<>(); attributes.put("abc", "world"); runner.enqueue(new byte[0], attributes); runner.run(); runner.assertAllFlowFilesTransferred(ScanAttribute.REL_MATCHED, 1); runner.clearTransferState(); attributes.remove("abc"); runner.enqueue(new byte[0], attributes); runner.run(); runner.assertAllFlowFilesTransferred(ScanAttribute.REL_MATCHED, 1); runner.clearTransferState(); attributes.put("abc", "world"); attributes.put("a world", "apart"); runner.enqueue(new byte[0], attributes); runner.run(); runner.assertAllFlowFilesTransferred(ScanAttribute.REL_UNMATCHED, 1); runner.clearTransferState(); attributes.put("abc", "world"); attributes.put("a world", "hello"); runner.enqueue(new byte[0], attributes); runner.run(); runner.assertAllFlowFilesTransferred(ScanAttribute.REL_MATCHED, 1); }
private boolean allMatch(final FlowFile flowFile, final Pattern attributePattern, final Set<String> dictionary) { for (final Map.Entry<String, String> entry : flowFile.getAttributes().entrySet()) { if (attributePattern == null || attributePattern.matcher(entry.getKey()).matches()) { if (!dictionary.contains(entry.getValue())) { return false; } } } return true; }
ScanAttribute extends AbstractProcessor { private boolean allMatch(final FlowFile flowFile, final Pattern attributePattern, final Set<String> dictionary) { for (final Map.Entry<String, String> entry : flowFile.getAttributes().entrySet()) { if (attributePattern == null || attributePattern.matcher(entry.getKey()).matches()) { if (!dictionary.contains(entry.getValue())) { return false; } } } return true; } }
ScanAttribute extends AbstractProcessor { private boolean allMatch(final FlowFile flowFile, final Pattern attributePattern, final Set<String> dictionary) { for (final Map.Entry<String, String> entry : flowFile.getAttributes().entrySet()) { if (attributePattern == null || attributePattern.matcher(entry.getKey()).matches()) { if (!dictionary.contains(entry.getValue())) { return false; } } } return true; }  }
ScanAttribute extends AbstractProcessor { private boolean allMatch(final FlowFile flowFile, final Pattern attributePattern, final Set<String> dictionary) { for (final Map.Entry<String, String> entry : flowFile.getAttributes().entrySet()) { if (attributePattern == null || attributePattern.matcher(entry.getKey()).matches()) { if (!dictionary.contains(entry.getValue())) { return false; } } } return true; }  @Override Set<Relationship> getRelationships(); @OnScheduled void onScheduled(final ProcessContext context); @Override void onTrigger(final ProcessContext context, final ProcessSession session); }
ScanAttribute extends AbstractProcessor { private boolean allMatch(final FlowFile flowFile, final Pattern attributePattern, final Set<String> dictionary) { for (final Map.Entry<String, String> entry : flowFile.getAttributes().entrySet()) { if (attributePattern == null || attributePattern.matcher(entry.getKey()).matches()) { if (!dictionary.contains(entry.getValue())) { return false; } } } return true; }  @Override Set<Relationship> getRelationships(); @OnScheduled void onScheduled(final ProcessContext context); @Override void onTrigger(final ProcessContext context, final ProcessSession session); static final String MATCH_CRITERIA_ALL; static final String MATCH_CRITERIA_ANY; static final PropertyDescriptor MATCHING_CRITERIA; static final PropertyDescriptor ATTRIBUTE_PATTERN; static final PropertyDescriptor DICTIONARY_FILE; static final PropertyDescriptor DICTIONARY_FILTER; static final Relationship REL_MATCHED; static final Relationship REL_UNMATCHED; }