This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 7fdaa5f311 NIFI-13052 allow CRON driven components to be searchable
7fdaa5f311 is described below

commit 7fdaa5f3114e72f69f33708937efe11ed70cef66
Author: Mike Moser <[email protected]>
AuthorDate: Mon Apr 15 21:54:09 2024 +0000

    NIFI-13052 allow CRON driven components to be searchable
    
    Signed-off-by: Pierre Villard <[email protected]>
    
    This closes #8655.
---
 nifi-docs/src/main/asciidoc/user-guide.adoc        |  2 ++
 .../attributematchers/SchedulingMatcher.java       |  5 +++++
 .../attributematchers/SchedulingMatcherTest.java   | 24 +++++++++++++++++-----
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc 
b/nifi-docs/src/main/asciidoc/user-guide.adoc
index cee1d3b592..1cfdbe6e74 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 115d9a1cf4..634260135d 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 org.apache.nifi.web.search.query.SearchQuery;
 
 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<ProcessorNode> {
     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<String> matches) {
@@ -38,6 +41,8 @@ public class SchedulingMatcher implements 
AttributeMatcher<ProcessorNode> {
 
         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 95325709c9..49ae79850f 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 class SchedulingMatcherTest extends 
AbstractAttributeMatcherTest {
     }
 
     @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 class SchedulingMatcherTest extends 
AbstractAttributeMatcherTest {
         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);
     }

Reply via email to