Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukadesu committed Nov 12, 2024
1 parent ef20d02 commit 96027d9
Showing 1 changed file with 95 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,103 +20,102 @@
import org.apache.streampipes.test.executors.ProcessingElementTestExecutor;
import org.apache.streampipes.test.executors.TestConfiguration;

import java.util.List;
import java.util.Map;

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

public class MathOpProcessorTest {

private MathOpProcessor processor;

@BeforeEach
public void setup() {
processor = new MathOpProcessor();
}

@Test
public void detectAdditionOperator() {
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "+").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 10.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectSubtractionOperator() {
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "-").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 0.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectMultiplicationOperator() {
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "*").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 25.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectDivisionOperator() {
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "/").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 1.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectModulusOperator() {
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "%").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 0.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}
import java.util.List;
import java.util.Map;

public class MathOpProcessorTest{
private MathOpProcessor processor;

@BeforeEach
public void setup(){
processor = new MathOpProcessor();
}

@Test
public void detectAdditionOperator(){
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "+").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 10.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectSubtractionOperator(){
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "-").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 0.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectMultiplicationOperator(){
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "*").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 25.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectDivisionOperator(){
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "/").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 1.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}

@Test
public void detectModulusOperator(){
TestConfiguration leftOperandConfiguration = TestConfiguration.builder()
.configWithDefaultPrefix(MathOpProcessor.LEFT_OPERAND, "leftOperand")
.configWithDefaultPrefix(MathOpProcessor.RIGHT_OPERAND, "rightOperand")
.config(MathOpProcessor.OPERATION, "%").build();

List<Map<String, Object>> inputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d));
List<Map<String, Object>> outputEvents = List.of(
Map.of("leftOperand", 5.0d, "rightOperand", 5.0d, "calculationResult", 0.0d));
ProcessingElementTestExecutor testExecutor = new ProcessingElementTestExecutor(
processor, leftOperandConfiguration);

testExecutor.run(inputEvents, outputEvents);
}
}

0 comments on commit 96027d9

Please sign in to comment.