This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
new e070753f39 NIFI-12987 allow controller service type to be searchable
e070753f39 is described below
commit e070753f39429ee5db176ced519f3827265d77c6
Author: Mike Moser <[email protected]>
AuthorDate: Mon Apr 1 18:09:16 2024 +0000
NIFI-12987 allow controller service type to be searchable
Signed-off-by: Pierre Villard <[email protected]>
This closes #8593.
---
.../ControllerServiceNodeMatcher.java | 3 ++
.../ControllerServiceNodeMatcherTest.java | 43 +++++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
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/ControllerServiceNodeMatcher.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcher.java
index ab20d14aba..7b5111330f 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcher.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcher.java
@@ -28,6 +28,7 @@ public class ControllerServiceNodeMatcher implements
AttributeMatcher<Controller
private static final String LABEL_VERSION_CONTROL_ID = "Version Control
ID";
private static final String LABEL_NAME = "Name";
private static final String LABEL_COMMENTS = "Comments";
+ private static final String LABEL_TYPE = "Type";
@Override
public void match(final ControllerServiceNode component, final SearchQuery
query, final List<String> matches) {
@@ -37,5 +38,7 @@ public class ControllerServiceNodeMatcher implements
AttributeMatcher<Controller
addIfMatching(searchTerm,
component.getVersionedComponentId().orElse(null), LABEL_VERSION_CONTROL_ID,
matches);
addIfMatching(searchTerm, component.getName(), LABEL_NAME, matches);
addIfMatching(searchTerm, component.getComments(), LABEL_COMMENTS,
matches);
+ addIfMatching(searchTerm,
component.getControllerServiceImplementation().getClass().getSimpleName(),
LABEL_TYPE, matches);
+ addIfMatching(searchTerm, component.getComponentType(), LABEL_TYPE,
matches);
}
}
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/ControllerServiceNodeMatcherTest.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcherTest.java
index 98d212a3f4..f02d8bac2e 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcherTest.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcherTest.java
@@ -16,11 +16,18 @@
*/
package org.apache.nifi.web.search.attributematchers;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.ControllerService;
+import org.apache.nifi.controller.ControllerServiceInitializationContext;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
+import java.util.Collection;
+import java.util.List;
import java.util.Optional;
public class ControllerServiceNodeMatcherTest extends
AbstractAttributeMatcherTest {
@@ -37,6 +44,8 @@ public class ControllerServiceNodeMatcherTest extends
AbstractAttributeMatcherTe
Mockito.when(component.getVersionedComponentId()).thenReturn(Optional.of("LoremVersionId"));
Mockito.when(component.getName()).thenReturn("LoremName");
Mockito.when(component.getComments()).thenReturn("LoremComment");
+
Mockito.when(component.getControllerServiceImplementation()).thenReturn(new
LoremControllerService());
+
Mockito.when(component.getComponentType()).thenReturn("LoremControllerService");
// when
testSubject.match(component, searchQuery, matches);
@@ -44,6 +53,38 @@ public class ControllerServiceNodeMatcherTest extends
AbstractAttributeMatcherTe
thenMatchConsistsOf("Id: LoremId", //
"Version Control ID: LoremVersionId", //
"Name: LoremName", //
- "Comments: LoremComment");
+ "Comments: LoremComment",
+ "Type: LoremControllerService");
+ }
+
+ private static class LoremControllerService implements ControllerService {
+
+ @Override
+ public Collection<ValidationResult> validate(ValidationContext
context) {
+ return null;
+ }
+
+ @Override
+ public PropertyDescriptor getPropertyDescriptor(String name) {
+ return null;
+ }
+
+ @Override
+ public void onPropertyModified(PropertyDescriptor descriptor, String
oldValue, String newValue) {
+ }
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors() {
+ return null;
+ }
+
+ @Override
+ public String getIdentifier() {
+ return null;
+ }
+
+ @Override
+ public void initialize(ControllerServiceInitializationContext context)
{
+ }
}
}
\ No newline at end of file