use of ru.fix.completable.reactor.runtime.dsl.Processor in project completable-reactor by ru-fix.
the class CompletableReactorHandlerArgumentsTest method arguments_test_6.
@Test
public void arguments_test_6() throws Exception {
@Reactored("Payload with string")
@Data
class Payload {
String data;
}
class Service {
@Reactored("method with 6 arguments")
public CompletableFuture<String> foo(String arg1, short arg2, boolean arg3, Object arg4, BigInteger arg5, long arg6) {
return CompletableFuture.completedFuture(arg1 + arg2 + arg3 + arg4 + arg5 + arg6);
}
}
final Service service = new Service();
class Config {
ReactorGraphBuilder graphBuilder = new ReactorGraphBuilder(this);
Processor<Payload> processor = graphBuilder.processor().forPayload(Payload.class).passArg(pld -> "1").passArg(pld -> (short) 3).passArg(pld -> true).passArg(pld -> 5).passArg(pld -> BigInteger.valueOf(6L)).passArg(pld -> 7L).withHandler(service::foo).withMerger((payload, result) -> {
payload.data = result;
return CompletableReactorTest.Status.OK;
}).buildProcessor();
ReactorGraph<Payload> graph() {
return graphBuilder.payload(Payload.class).handle(processor).mergePoint(processor).onAny().complete().coordinates().buildGraph();
}
}
val graph = new Config().graph();
reactor.registerReactorGraph(graph);
assertEquals("13true567", reactor.submit(new Payload()).getResultFuture().get(5, TimeUnit.SECONDS).getData());
}
use of ru.fix.completable.reactor.runtime.dsl.Processor in project completable-reactor by ru-fix.
the class CompletableReactorHandlerArgumentsTest method arguments_test_3.
@Test
public void arguments_test_3() throws Exception {
@Reactored("Payload with string")
@Data
class Payload {
String data;
}
class Service {
@Reactored("method with 6 arguments")
public CompletableFuture<String> foo(boolean arg1, BigInteger arg2, long arg3) {
return CompletableFuture.completedFuture("" + arg1 + arg2 + arg3);
}
}
final Service service = new Service();
class Config {
ReactorGraphBuilder graphBuilder = new ReactorGraphBuilder(this);
Processor<Payload> processor = graphBuilder.processor().forPayload(Payload.class).passArg(pld -> true).passArg(pld -> BigInteger.valueOf(6L)).passArg(pld -> 7L).withHandler(service::foo).withMerger((payload, result) -> {
payload.data = result;
return CompletableReactorTest.Status.OK;
}).buildProcessor();
ReactorGraph<Payload> graph() {
return graphBuilder.payload(Payload.class).handle(processor).mergePoint(processor).onAny().complete().coordinates().buildGraph();
}
}
reactor.registerReactorGraph(new Config().graph());
assertEquals("true67", reactor.submit(new Payload()).getResultFuture().get(5, TimeUnit.SECONDS).getData());
}
use of ru.fix.completable.reactor.runtime.dsl.Processor in project completable-reactor by ru-fix.
the class CompletableReactorHandlerArgumentsTest method arguments_test_4.
@Test
public void arguments_test_4() throws Exception {
@Reactored("Payload with string")
@Data
class Payload {
String data;
}
class Service {
@Reactored("method with 6 arguments")
public CompletableFuture<String> foo(short arg1, boolean arg2, BigInteger arg3, long arg4) {
return CompletableFuture.completedFuture("" + arg1 + arg2 + arg3 + arg4);
}
}
final Service service = new Service();
class Config {
ReactorGraphBuilder graphBuilder = new ReactorGraphBuilder(this);
Processor<Payload> processor = graphBuilder.processor().forPayload(Payload.class).passArg(pld -> (short) 3).passArg(pld -> true).passArg(pld -> BigInteger.valueOf(6L)).passArg(pld -> 7L).withHandler(service::foo).withMerger((payload, result) -> {
payload.data = result;
return CompletableReactorTest.Status.OK;
}).buildProcessor();
ReactorGraph<Payload> graph() {
return graphBuilder.payload(Payload.class).handle(processor).mergePoint(processor).onAny().complete().coordinates().buildGraph();
}
}
val graph = new Config().graph();
reactor.registerReactorGraph(graph);
assertEquals("3true67", reactor.submit(new Payload()).getResultFuture().get(5, TimeUnit.SECONDS).getData());
}
use of ru.fix.completable.reactor.runtime.dsl.Processor in project completable-reactor by ru-fix.
the class CompletableReactorHandlerArgumentsTest method arguments_test_5.
@Test
public void arguments_test_5() throws Exception {
@Reactored("Payload with string")
@Data
class Payload {
String data;
}
class Service {
@Reactored("method with 6 arguments")
public CompletableFuture<String> foo(String arg1, short arg2, boolean arg3, BigInteger arg4, long arg5) {
return CompletableFuture.completedFuture(arg1 + arg2 + arg3 + arg4 + arg5);
}
}
final Service service = new Service();
class Config {
ReactorGraphBuilder graphBuilder = new ReactorGraphBuilder(this);
Processor<Payload> processor = graphBuilder.processor().forPayload(Payload.class).passArg(pld -> "1").passArg(pld -> (short) 3).passArg(pld -> true).passArg(pld -> BigInteger.valueOf(6L)).passArg(pld -> 7L).withHandler(service::foo).withMerger((payload, result) -> {
payload.data = result;
return CompletableReactorTest.Status.OK;
}).buildProcessor();
ReactorGraph<Payload> graph() {
return graphBuilder.payload(Payload.class).handle(processor).mergePoint(processor).onAny().complete().coordinates().buildGraph();
}
}
val graph = new Config().graph();
reactor.registerReactorGraph(graph);
assertEquals("13true67", reactor.submit(new Payload()).getResultFuture().get(5, TimeUnit.SECONDS).getData());
}
use of ru.fix.completable.reactor.runtime.dsl.Processor in project completable-reactor by ru-fix.
the class CompletableReactorHandlerArgumentsTest method arguments_test_1.
@Test
public void arguments_test_1() throws Exception {
@Reactored("Payload with string")
@Data
class Payload {
String data;
}
class Service {
@Reactored("method with 6 arguments")
public CompletableFuture<String> foo(long arg) {
return CompletableFuture.completedFuture("" + arg);
}
}
final Service service = new Service();
class Config {
ReactorGraphBuilder graphBuilder = new ReactorGraphBuilder(this);
Processor<Payload> processor = graphBuilder.processor().forPayload(Payload.class).passArg(pld -> 7L).withHandler(service::foo).withMerger((payload, result) -> {
payload.data = result;
return CompletableReactorTest.Status.OK;
}).buildProcessor();
ReactorGraph<Payload> graph() {
return graphBuilder.payload(Payload.class).handle(processor).mergePoint(processor).onAny().complete().coordinates().buildGraph();
}
}
reactor.registerReactorGraph(new Config().graph());
assertEquals("7", reactor.submit(new Payload()).getResultFuture().get(5, TimeUnit.SECONDS).getData());
}
Aggregations