mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Replaced the ProcessingInstruction with Callable
This makes the concept of forwarding the results much easier to understand and cleaner.
This commit is contained in:
1 parent
8b39db5517
commit
a20e9120f8
11 files changed
+84
-175
No files matched your search
-47
@@ -1,47 +0,0 @@
|
||||
package com.sap.sse.datamining.components;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sse.datamining.impl.components.AbstractDirectForwardProcessingInstruction;
|
||||
|
||||
public class TestAbstractDirectForwardingProcessingInstruction {
|
||||
|
||||
private int calls = 0;
|
||||
|
||||
@Test
|
||||
public void testThatTheResultIsDirectlyForwarded() {
|
||||
Processor<Integer> processor = new Processor<Integer>() {
|
||||
@Override
|
||||
public void onElement(Integer element) {
|
||||
calls++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() throws InterruptedException { }
|
||||
};
|
||||
ProcessingInstruction<Integer, Integer> instruction = createInstruction(processor);
|
||||
|
||||
instruction.run();
|
||||
assertThat(calls, is(1));
|
||||
}
|
||||
|
||||
private ProcessingInstruction<Integer, Integer> createInstruction(Processor<Integer> resultReceiver) {
|
||||
Integer input = 10;
|
||||
Collection<Processor<Integer>> resultReceivers = new ArrayList<>();
|
||||
resultReceivers.add(resultReceiver);
|
||||
ProcessingInstruction<Integer, Integer> instruction = new AbstractDirectForwardProcessingInstruction<Integer, Integer>(input, resultReceivers) {
|
||||
@Override
|
||||
protected Integer doWork() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
return instruction;
|
||||
}
|
||||
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.sap.sse.datamining.test.components.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sse.datamining.components.Processor;
|
||||
import com.sap.sse.datamining.impl.components.AbstractDirectForwardProcessingInstruction;
|
||||
|
||||
public class InputForwardingInstruction<T> extends AbstractDirectForwardProcessingInstruction<T, T> {
|
||||
|
||||
public InputForwardingInstruction(T input, Collection<Processor<T>> resultReceivers) {
|
||||
super(input, resultReceivers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected T doWork() {
|
||||
return super.getInput();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user