Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukadesu committed Nov 1, 2024
1 parent 0b99512 commit d080e5f
Showing 1 changed file with 49 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void detectAdditionOperator() {
rightOperand.setSelectedProperty("s0::value2");
// choose operation to calculate
OneOfStaticProperty operation = (OneOfStaticProperty)graph.getStaticProperties().get(2);
operation. setInternalName ("operation");
operation.setInternalName ("operation");
for (Option option : operation.getOptions()) {
if (option.getName().equals("+")) {
option.setSelected(true);
Expand All @@ -65,36 +65,36 @@ public void detectAdditionOperator() {
}

ProcessorParams params = new ProcessorParams(graph);
processor.onInvocation(params, null, null);
processor.onInvocation(params,null,null);

StoreEventCollector collector = new StoreEventCollector();

processor.onEvent(this.createTestEvent(1,2),collector);
Assertions.assertEquals(3.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(3.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(2,3),collector);
Assertions.assertEquals(5.,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(5.,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(3,4),collector);
Assertions.assertEquals(7.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(7.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(4,5),collector);
Assertions.assertEquals(9.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(9.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(5,6),collector);
Assertions.assertEquals(11.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(11.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(6,7),collector);
Assertions.assertEquals(13.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(13.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(7,8),collector);
Assertions.assertEquals(15.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(15.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();
}

Expand All @@ -113,7 +113,7 @@ public void detectSubtractionOperator() {
rightOperand.setSelectedProperty("s0::value2");

OneOfStaticProperty operation = (OneOfStaticProperty)graph.getStaticProperties().get(2);
operation. setInternalName ("operation");
operation.setInternalName ("operation");
for (Option option : operation.getOptions()) {
if (option.getName().equals("-")) {
option.setSelected(true);
Expand All @@ -122,36 +122,36 @@ public void detectSubtractionOperator() {
}

ProcessorParams params = new ProcessorParams(graph);
processor.onInvocation(params, null, null);
processor.onInvocation(params,null,null);

StoreEventCollector collector = new StoreEventCollector();

processor.onEvent(this.createTestEvent(4,1),collector);
Assertions.assertEquals(3.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(3.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(8,1),collector);
Assertions.assertEquals(7.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(7.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(9,4),collector);
Assertions.assertEquals(5.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(5.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(6,2),collector);
Assertions.assertEquals(4.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(4.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(10,3),collector);
Assertions.assertEquals(7.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(7.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(15,2),collector);
Assertions.assertEquals(13.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(13.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(19,17),collector);
Assertions.assertEquals(2.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(2.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();
}

Expand All @@ -170,7 +170,7 @@ public void detectMultiplicationOperator() {
rightOperand.setSelectedProperty("s0::value2");

OneOfStaticProperty operation = (OneOfStaticProperty)graph.getStaticProperties().get(2);
operation. setInternalName ("operation");
operation.setInternalName ("operation");
for (Option option : operation.getOptions()) {
if (option.getName().equals("*")) {
option.setSelected(true);
Expand All @@ -179,36 +179,36 @@ public void detectMultiplicationOperator() {
}

ProcessorParams params = new ProcessorParams(graph);
processor.onInvocation(params, null, null);
processor.onInvocation(params,null,null);

StoreEventCollector collector = new StoreEventCollector();

processor.onEvent(this.createTestEvent(4,1),collector);
Assertions.assertEquals(4.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(4.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(8,1),collector);
Assertions.assertEquals(8.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(8.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(9,4),collector);
Assertions.assertEquals(36.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(36.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(6,2),collector);
Assertions.assertEquals(12.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(12.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(10,3),collector);
Assertions.assertEquals(30.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(30.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(15,2),collector);
Assertions.assertEquals(30.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(30.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(19,17),collector);
Assertions.assertEquals(323.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(323.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();
}

Expand All @@ -227,7 +227,7 @@ public void detectDivisionOperator() {
rightOperand.setSelectedProperty("s0::value2");

OneOfStaticProperty operation = (OneOfStaticProperty)graph.getStaticProperties().get(2);
operation. setInternalName ("operation");
operation.setInternalName ("operation");
for (Option option : operation.getOptions()) {
if (option.getName().equals("/")) {
option.setSelected(true);
Expand All @@ -236,36 +236,36 @@ public void detectDivisionOperator() {
}

ProcessorParams params = new ProcessorParams(graph);
processor.onInvocation(params, null, null);
processor.onInvocation(params,null,null);

StoreEventCollector collector = new StoreEventCollector();

processor.onEvent(this.createTestEvent(4,1),collector);
Assertions.assertEquals(4.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(4.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(8,1),collector);
Assertions.assertEquals(8.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(8.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(16,4),collector);
Assertions.assertEquals(4.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(4.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(6,2),collector);
Assertions.assertEquals(3.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(3.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(12,3),collector);
Assertions.assertEquals(4.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(4.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(16,2),collector);
Assertions.assertEquals(8.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(8.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(34,17),collector);
Assertions.assertEquals(2.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(2.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();
}

Expand All @@ -284,7 +284,7 @@ public void detectRemainderOperator() {
rightOperand.setSelectedProperty("s0::value2");

OneOfStaticProperty operation = (OneOfStaticProperty)graph.getStaticProperties().get(2);
operation. setInternalName ("operation");
operation.setInternalName ("operation");
for (Option option : operation.getOptions()) {
if (option.getName().equals("%")) {
option.setSelected(true);
Expand All @@ -293,40 +293,40 @@ public void detectRemainderOperator() {
}

ProcessorParams params = new ProcessorParams(graph);
processor.onInvocation(params, null, null);
processor.onInvocation(params,null,null);

StoreEventCollector collector = new StoreEventCollector();

processor.onEvent(this.createTestEvent(4,1),collector);
Assertions.assertEquals(0.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(0.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(8,1),collector);
Assertions.assertEquals(0.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(0.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(9,4),collector);
Assertions.assertEquals(1.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(1.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(6,2),collector);
Assertions.assertEquals(0.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(0.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(10,3),collector);
Assertions.assertEquals(1.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(1.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(15,2),collector);
Assertions.assertEquals(1.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(1.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();

processor.onEvent(this.createTestEvent(19,17),collector);
Assertions.assertEquals(2.0,collector.getEvents() .get(0).getFieldBySelector("calculationResult").getRawValue());
Assertions.assertEquals(2.0,collector.getEvents().get(0).getFieldBySelector("calculationResult").getRawValue());
collector.getEvents().clear();
}

private Event createTestEvent(Integer value1, Integer value2) {
private Event createTestEvent(Integer value1,Integer value2) {

var eventSchema = GuessSchemaBuilder.create()
.property(PrimitivePropertyBuilder
Expand All @@ -340,9 +340,9 @@ private Event createTestEvent(Integer value1, Integer value2) {
.build().eventSchema;

Map<String, Object> map = new HashMap<>();
map.put("value1", value1);
map.put("value2", value2);
map.put("value1",value1);
map.put("value2",value2);

return EventFactory.fromMap(map, new SourceInfo("", "s0"), new SchemaInfo(eventSchema, new ArrayList<>()));
return EventFactory.fromMap(map,new SourceInfo("", "s0"),new SchemaInfo(eventSchema,new ArrayList<>()));
}
}

0 comments on commit d080e5f

Please sign in to comment.