bossenti commented on code in PR #1940:
URL: https://github.com/apache/streampipes/pull/1940#discussion_r1329602383


##########
streampipes-extensions/streampipes-processors-transformation-jvm/src/test/java/org/apache/streampipes/processors/transformation/jvm/Additional
 Tests:
##########
@@ -0,0 +1,96 @@
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import 
org.apache.streampipes.extensions.api.pe.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.extensions.api.pe.routing.SpOutputCollector;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.wrapper.params.compat.ProcessorParams;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+public class TextFilterProcessorTest {
+
+    @Mock
+    private ProcessorParams processorParams;
+
+    @Mock
+    private SpOutputCollector spOutputCollector;
+
+    @Mock
+    private EventProcessorRuntimeContext eventProcessorRuntimeContext;
+
+    @BeforeEach
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testConstructorInitialization() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertNull(processor.getKeyword());
+        assertNull(processor.getStringOperator());
+        assertNull(processor.getFilterProperty());
+    }
+
+    @Test
+    public void testModelDeclaration() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertNotNull(processor.declareModel());
+        // Add more assertions to validate the description

Review Comment:
   Are you willing to come up with some here? 



##########
streampipes-extensions/streampipes-processors-transformation-jvm/src/test/java/org/apache/streampipes/processors/transformation/jvm/Additional
 Tests:
##########


Review Comment:
   This is not a valid `java` class. Can you please give it a valid file name 
and put it in the corresponding package? 



##########
streampipes-extensions/streampipes-processors-transformation-jvm/src/test/java/org/apache/streampipes/processors/transformation/jvm/Additional
 Tests:
##########
@@ -0,0 +1,96 @@
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import 
org.apache.streampipes.extensions.api.pe.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.extensions.api.pe.routing.SpOutputCollector;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.wrapper.params.compat.ProcessorParams;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+public class TextFilterProcessorTest {
+
+    @Mock
+    private ProcessorParams processorParams;
+
+    @Mock
+    private SpOutputCollector spOutputCollector;
+
+    @Mock
+    private EventProcessorRuntimeContext eventProcessorRuntimeContext;
+
+    @BeforeEach
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testConstructorInitialization() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertNull(processor.getKeyword());
+        assertNull(processor.getStringOperator());
+        assertNull(processor.getFilterProperty());
+    }
+
+    @Test
+    public void testModelDeclaration() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertNotNull(processor.declareModel());
+        // Add more assertions to validate the description
+    }
+
+    @Test
+    public void testOnInvocation() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        when(processorParams.extractor().singleValueParameter(anyString(), 
eq(String.class))).thenReturn("keyword");
+        when(processorParams.extractor().selectedSingleValue(anyString(), 
eq(String.class))).thenReturn("MATCHES");
+        
when(processorParams.extractor().mappingPropertyValue(anyString())).thenReturn("text");
+
+        assertDoesNotThrow(() -> processor.onInvocation(processorParams, 
spOutputCollector, eventProcessorRuntimeContext));
+
+        assertEquals("keyword", processor.getKeyword());
+        assertEquals(TextFilterProcessor.StringOperator.MATCHES, 
processor.getStringOperator());
+        assertEquals("text", processor.getFilterProperty());
+    }
+
+    @Test
+    public void testOnEvent() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        when(processorParams.extractor().singleValueParameter(anyString(), 
eq(String.class))).thenReturn("keyword");
+        when(processorParams.extractor().selectedSingleValue(anyString(), 
eq(String.class))).thenReturn("MATCHES");
+        
when(processorParams.extractor().mappingPropertyValue(anyString())).thenReturn("text");
+
+        processor.onInvocation(processorParams, spOutputCollector, 
eventProcessorRuntimeContext);
+
+        Event matchingEvent = createMockEvent("Some text that MATCHES the 
keyword");

Review Comment:
   This text only contains the keyword, doesn't it?
   If you would like to test for equality, your string should just be `keyword`.



##########
streampipes-extensions/streampipes-processors-transformation-jvm/src/test/java/org/apache/streampipes/processors/transformation/jvm/Additional
 Tests:
##########
@@ -0,0 +1,96 @@
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import 
org.apache.streampipes.extensions.api.pe.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.extensions.api.pe.routing.SpOutputCollector;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.wrapper.params.compat.ProcessorParams;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+public class TextFilterProcessorTest {
+
+    @Mock
+    private ProcessorParams processorParams;
+
+    @Mock
+    private SpOutputCollector spOutputCollector;
+
+    @Mock
+    private EventProcessorRuntimeContext eventProcessorRuntimeContext;
+
+    @BeforeEach
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void testConstructorInitialization() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertNull(processor.getKeyword());
+        assertNull(processor.getStringOperator());
+        assertNull(processor.getFilterProperty());
+    }
+
+    @Test
+    public void testModelDeclaration() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertNotNull(processor.declareModel());
+        // Add more assertions to validate the description
+    }
+
+    @Test
+    public void testOnInvocation() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        when(processorParams.extractor().singleValueParameter(anyString(), 
eq(String.class))).thenReturn("keyword");
+        when(processorParams.extractor().selectedSingleValue(anyString(), 
eq(String.class))).thenReturn("MATCHES");
+        
when(processorParams.extractor().mappingPropertyValue(anyString())).thenReturn("text");
+
+        assertDoesNotThrow(() -> processor.onInvocation(processorParams, 
spOutputCollector, eventProcessorRuntimeContext));
+
+        assertEquals("keyword", processor.getKeyword());
+        assertEquals(TextFilterProcessor.StringOperator.MATCHES, 
processor.getStringOperator());
+        assertEquals("text", processor.getFilterProperty());
+    }
+
+    @Test
+    public void testOnEvent() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        when(processorParams.extractor().singleValueParameter(anyString(), 
eq(String.class))).thenReturn("keyword");
+        when(processorParams.extractor().selectedSingleValue(anyString(), 
eq(String.class))).thenReturn("MATCHES");
+        
when(processorParams.extractor().mappingPropertyValue(anyString())).thenReturn("text");
+
+        processor.onInvocation(processorParams, spOutputCollector, 
eventProcessorRuntimeContext);
+
+        Event matchingEvent = createMockEvent("Some text that MATCHES the 
keyword");
+        Event containingEvent = createMockEvent("Some text that CONTAINS the 
keyword");
+        Event nonMatchingEvent = createMockEvent("Some text that does not 
match or contain the keyword");
+
+        spOutputCollector.resetCollectedEvents(); // Reset collected events 
for each test case
+
+        processor.onEvent(matchingEvent, spOutputCollector);
+        assertEquals(1, spOutputCollector.getCollectedEvents().size());
+
+        processor.onEvent(containingEvent, spOutputCollector);
+        assertEquals(1, spOutputCollector.getCollectedEvents().size());
+
+        processor.onEvent(nonMatchingEvent, spOutputCollector);
+        assertEquals(0, spOutputCollector.getCollectedEvents().size());
+    }
+
+    @Test
+    public void testOnDetach() {
+        TextFilterProcessor processor = new TextFilterProcessor();
+        assertDoesNotThrow(() -> processor.onDetach());
+        // Add assertions if there is any specific behavior to test

Review Comment:
   I think there is no more to test here, so you can safely remove this comment



##########
streampipes-extensions/streampipes-processors-transformation-jvm/src/test/java/org/apache/streampipes/processors/transformation/jvm/Additional
 Tests:
##########
@@ -0,0 +1,96 @@
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;

Review Comment:
   This file misses our Apache license header, see an example 
[here](https://github.com/apache/streampipes/blob/ca4e0c2d44c1a713caaee3e9c1bff46096f41c53/streampipes-extensions/streampipes-processors-transformation-jvm/src/test/java/org/apache/streampipes/processors/transformation/jvm/processor/value/change/TestChangedValueDetectionProcessor.java#L1).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to