Skip to content

Commit

Permalink
feat(#2374): Fix cyclic dependencies and checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Apr 29, 2024
1 parent 92f55ec commit 5735eee
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 60 deletions.
Expand Up @@ -64,7 +64,6 @@
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-test-utils-executors</artifactId>
<version>0.95.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Expand Up @@ -20,7 +20,6 @@

import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down
Expand Up @@ -21,10 +21,10 @@
import org.apache.streampipes.model.graph.DataProcessorInvocation;
import org.apache.streampipes.model.output.CustomOutputStrategy;
import org.apache.streampipes.model.output.OutputStrategy;

import org.apache.streampipes.test.executors.PrefixStrategy;
import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down
Expand Up @@ -19,10 +19,10 @@

import org.apache.streampipes.model.graph.DataProcessorInvocation;
import org.apache.streampipes.model.output.CustomOutputStrategy;

import org.apache.streampipes.test.executors.PrefixStrategy;
import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -35,7 +35,6 @@
import java.util.stream.Stream;



public class TestMergeByTimeProcessor {

private static final String S0_PREFIX = "s0";
Expand Down
Expand Up @@ -20,7 +20,6 @@

import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
Expand Up @@ -19,9 +19,9 @@
package org.apache.streampipes.processors.filters.jvm.processor.sdt;

import org.apache.streampipes.commons.exceptions.SpRuntimeException;

import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -46,8 +46,9 @@ public void setup() {
}

@Test
public void test(){
TestConfiguration configuration = TestConfiguration.builder()
public void test() {
TestConfiguration configuration = TestConfiguration
.builder()
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY, sdtTimestampField)
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY, sdtValueField)
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY, "10.0")
Expand All @@ -57,32 +58,44 @@ public void test(){

List<Map<String, Object>> inputEvents = List.of(
Map.of(sdtTimestampField, 0,
sdtValueField, 50.0),
sdtValueField, 50.0
),
Map.of(sdtTimestampField, 50,
sdtValueField, 50.0),
sdtValueField, 50.0
),
Map.of(sdtTimestampField, 200,
sdtValueField, 100.0),
sdtValueField, 100.0
),
Map.of(sdtTimestampField, 270,
sdtValueField, 140.0),
sdtValueField, 140.0
),
Map.of(sdtTimestampField, 300,
sdtValueField, 250.0),
sdtValueField, 250.0
),
Map.of(sdtTimestampField, 900,
sdtValueField, 500.0),
sdtValueField, 500.0
),
Map.of(sdtTimestampField, 1100,
sdtValueField, 800.0),
sdtValueField, 800.0
),
Map.of(sdtTimestampField, 1250,
sdtValueField, 1600.0)
sdtValueField, 1600.0
)
);

List<Map<String, Object>> outputEvents = List.of(
Map.of(sdtTimestampField, 0,
sdtValueField, 50.0),
Map.of(sdtTimestampField, 270,
sdtValueField, 140.0),
Map.of(sdtTimestampField, 900,
sdtValueField, 500.0),
Map.of(sdtTimestampField, 1100,
sdtValueField, 800.0)
Map.of(sdtTimestampField, 0,
sdtValueField, 50.0
),
Map.of(sdtTimestampField, 270,
sdtValueField, 140.0
),
Map.of(sdtTimestampField, 900,
sdtValueField, 500.0
),
Map.of(sdtTimestampField, 1100,
sdtValueField, 800.0
)
);

ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(processor, configuration);
Expand All @@ -91,13 +104,29 @@ public void test(){
}

@Test
public void testInvalidDeviationKey(){
TestConfiguration configuration = TestConfiguration.builder()
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY, sdtTimestampField)
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY, sdtValueField)
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY, "-10.0")
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MIN_INTERVAL_KEY, "100")
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MAX_INTERVAL_KEY, "500")
public void testInvalidDeviationKey() {
TestConfiguration configuration = TestConfiguration
.builder()
.configWithDefaultPrefix(
SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY,
sdtTimestampField
)
.configWithDefaultPrefix(
SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY,
sdtValueField
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY,
"-10.0"
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MIN_INTERVAL_KEY,
"100"
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MAX_INTERVAL_KEY,
"500"
)
.build();

List<Map<String, Object>> inputEvents = new ArrayList<>();
Expand All @@ -118,13 +147,29 @@ public void testInvalidDeviationKey(){
}

@Test
public void testNegativeMinimumTime(){
TestConfiguration configuration = TestConfiguration.builder()
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY, sdtTimestampField)
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY, sdtValueField)
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY, "10.0")
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MIN_INTERVAL_KEY, "-100")
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MAX_INTERVAL_KEY, "500")
public void testNegativeMinimumTime() {
TestConfiguration configuration = TestConfiguration
.builder()
.configWithDefaultPrefix(
SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY,
sdtTimestampField
)
.configWithDefaultPrefix(
SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY,
sdtValueField
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY,
"10.0"
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MIN_INTERVAL_KEY,
"-100"
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MAX_INTERVAL_KEY,
"500"
)
.build();

List<Map<String, Object>> inputEvents = new ArrayList<>();
Expand All @@ -144,13 +189,29 @@ public void testNegativeMinimumTime(){
}

@Test
public void testInvalidTimeInterval(){
TestConfiguration configuration = TestConfiguration.builder()
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY, sdtTimestampField)
.configWithDefaultPrefix(SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY, sdtValueField)
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY, "10.0")
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MIN_INTERVAL_KEY, "1000")
.config(SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MAX_INTERVAL_KEY, "500")
public void testInvalidTimeInterval() {
TestConfiguration configuration = TestConfiguration
.builder()
.configWithDefaultPrefix(
SwingingDoorTrendingFilterProcessor.SDT_TIMESTAMP_FIELD_KEY,
sdtTimestampField
)
.configWithDefaultPrefix(
SwingingDoorTrendingFilterProcessor.SDT_VALUE_FIELD_KEY,
sdtValueField
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_DEVIATION_KEY,
"10.0"
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MIN_INTERVAL_KEY,
"1000"
)
.config(
SwingingDoorTrendingFilterProcessor.SDT_COMPRESSION_MAX_INTERVAL_KEY,
"500"
)
.build();

List<Map<String, Object>> inputEvents = new ArrayList<>();
Expand Down
Expand Up @@ -20,7 +20,6 @@

import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -31,7 +30,6 @@
import java.util.Map;
import java.util.stream.Stream;


public class TestTextFilterProcessor {

TextFilterProcessor processor;
Expand Down
25 changes: 16 additions & 9 deletions streampipes-test-utils-executors/pom.xml
Expand Up @@ -32,29 +32,36 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-pipeline-management</artifactId>
<version>0.95.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-test-utils</artifactId>
<version>0.95.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
</dependencies>
<build>
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
import org.apache.streampipes.test.generator.EventStreamGenerator;

import org.junit.jupiter.api.Assertions;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

Expand All @@ -43,8 +44,6 @@
import java.util.function.Consumer;
import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assertions.assertEquals;


public class ProcessingElementTestExecutor {

Expand Down Expand Up @@ -118,7 +117,7 @@ public void run(
Mockito.times(expectedOutputEvents.size())).collect(spOutputCollectorCaptor.capture());
var resultingEvents = spOutputCollectorCaptor.getAllValues();
IntStream.range(0, expectedOutputEvents.size())
.forEach(i -> assertEquals(
.forEach(i -> Assertions.assertEquals(
expectedOutputEvents.get(i),
resultingEvents.get(i)
.getRaw()
Expand Down

0 comments on commit 5735eee

Please sign in to comment.