diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc b/nifi-docs/src/main/asciidoc/user-guide.adoc index cee1d3b59203..1cfdbe6e74af 100644 --- a/nifi-docs/src/main/asciidoc/user-guide.adoc +++ b/nifi-docs/src/main/asciidoc/user-guide.adoc @@ -2139,6 +2139,8 @@ The supported keywords are the following: ** *timer*: Adds Processors to the result list where the Scheduling Strategy is "Timer Driven". +** *cron*: Adds Processors to the result list where the Scheduling Strategy is "CRON Driven". + - *Execution* ** *primary:* Adds Processors to the result list that are set to run on the primary node only (whether if the Processor is currently running or not). diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java index 115d9a1cf4cf..634260135db0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java @@ -23,13 +23,16 @@ import java.util.List; +import static org.apache.nifi.scheduling.SchedulingStrategy.CRON_DRIVEN; import static org.apache.nifi.scheduling.SchedulingStrategy.TIMER_DRIVEN; public class SchedulingMatcher implements AttributeMatcher { private static final String SEARCH_TERM_TIMER = "timer"; + private static final String SEARCH_TERM_CRON = "cron"; private static final String MATCH_PREFIX = "Scheduling strategy: "; private static final String MATCH_TIMER = "Timer driven"; + private static final String MATCH_CRON = "CRON driven"; @Override public void match(final ProcessorNode component, final SearchQuery query, final List matches) { @@ -38,6 +41,8 @@ public void match(final ProcessorNode component, final SearchQuery query, final if (TIMER_DRIVEN.equals(schedulingStrategy) && StringUtils.containsIgnoreCase(SEARCH_TERM_TIMER, searchTerm)) { matches.add(MATCH_PREFIX + MATCH_TIMER); + } else if (CRON_DRIVEN.equals(schedulingStrategy) && StringUtils.containsIgnoreCase(SEARCH_TERM_CRON, searchTerm)) { + matches.add(MATCH_PREFIX + MATCH_CRON); } } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java index 95325709c91d..49ae79850fe6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java @@ -28,11 +28,11 @@ public class SchedulingMatcherTest extends AbstractAttributeMatcherTest { private ProcessorNode component; @Test - public void testWhenKeywordAppearsAndNotEvent() { + public void testWhenKeywordAppearsAndNotTimer() { // given final SchedulingMatcher testSubject = new SchedulingMatcher(); - givenSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN); - givenSearchTerm("event"); + givenSchedulingStrategy(SchedulingStrategy.CRON_DRIVEN); + givenSearchTerm("timer"); // when testSubject.match(component, searchQuery, matches); @@ -42,11 +42,11 @@ public void testWhenKeywordAppearsAndNotEvent() { } @Test - public void testWhenKeywordDoesNotAppearAndEvent() { + public void testWhenKeywordDoesNotAppearAndTimer() { // given final SchedulingMatcher testSubject = new SchedulingMatcher(); givenSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN); - givenSearchTerm("event"); + givenSearchTerm("cron"); // when testSubject.match(component, searchQuery, matches); @@ -69,6 +69,20 @@ public void testWhenKeywordAppearsAndTimer() { thenMatchConsistsOf("Scheduling strategy: Timer driven"); } + @Test + public void testWhenKeywordAppearsAndCron() { + // given + final SchedulingMatcher testSubject = new SchedulingMatcher(); + givenSchedulingStrategy(SchedulingStrategy.CRON_DRIVEN); + givenSearchTerm("cron"); + + // when + testSubject.match(component, searchQuery, matches); + + // then + thenMatchConsistsOf("Scheduling strategy: CRON driven"); + } + private void givenSchedulingStrategy(final SchedulingStrategy schedulingStrategy) { Mockito.when(component.getSchedulingStrategy()).thenReturn(schedulingStrategy); }