use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.
the class ExpressionTest method testTrailingTMLPath.
@Test
public void testTrailingTMLPath() throws Exception {
Expression.compileExpressions = true;
ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
ImmutableMessage inner = ImmutableFactory.empty().with("innerint", 3, "integer");
ImmutableMessage combined = outer.withSubMessage("sub", inner);
Operand o = Expression.evaluateImmutable("[sub/]", null, Optional.of(combined), Optional.empty());
ImmutableMessage s = o.immutableMessageValue();
assertEquals(3, s.value("innerint").get());
}
use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.
the class ExpressionTest method testTrailingTMLPathParam.
@Test
public void testTrailingTMLPathParam() throws Exception {
Expression.compileExpressions = true;
ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
ImmutableMessage inner = ImmutableFactory.empty().with("innerint", 3, "integer");
ImmutableMessage combined = outer.withSubMessage("sub", inner);
Operand o = Expression.evaluateImmutable("[@sub/]", null, Optional.empty(), Optional.of(combined));
ImmutableMessage s = o.immutableMessageValue();
assertEquals(3, s.value("innerint").get());
}
use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.
the class TestSerializeReplicationMessage method testRepl.
@Test
public void testRepl() {
ReplicationMessageParser parser = new JSONReplicationMessageParserImpl();
ImmutableMessage m = parser.parseStream(this.getClass().getClassLoader().getResourceAsStream("person.json")).message();
StreamDocument.replicationMessageToStreamEvents("Person", m, false).compose(StreamDocument.inNavajo("TestService", Optional.empty(), Optional.empty())).lift(StreamDocument.serialize()).lift(StreamDocument.decode("UTF-8")).blockingForEach(e -> {
System.err.print(e);
});
}
use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.
the class CallRemoteSource method execute.
@Override
public Flowable<DataItem> execute(StreamScriptContext context, Optional<ImmutableMessage> current, ImmutableMessage param) {
ReactiveResolvedParameters resolved = params.resolve(context, current, ImmutableFactory.empty(), metadata);
String server = resolved.paramString("server");
String username = resolved.paramString("username");
String password = resolved.paramString("password");
final String service = resolved.paramString("service");
Flowable<NavajoStreamEvent> flow = client.callWithBodyToStream(server, e -> e.header("X-Navajo-Username", username).header("X-Navajo-Password", password).header("X-Navajo-Service", service).method(HttpMethod.POST), Flowable.<NavajoStreamEvent>empty().compose(StreamDocument.inNavajo(service, Optional.of(username), Optional.of(password))).lift(StreamDocument.serialize()), "text/xml").lift(XML.parseFlowable(10)).concatMap(e -> e).lift(StreamDocument.parse()).concatMap(e -> e).filter(e -> e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_STARTED && e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_DONE);
Flowable<DataItem> fw = Flowable.just(DataItem.ofEventStream(flow));
return fw;
}
use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.
the class CallRemoteTransformer method execute.
@Override
public FlowableTransformer<DataItem, DataItem> execute(StreamScriptContext context, Optional<ImmutableMessage> current, ImmutableMessage param) {
ReactiveResolvedParameters resolved = parameters.resolve(context, current, param, metadata);
String server = resolved.paramString("server");
String username = resolved.paramString("username");
String password = resolved.paramString("password");
final String service = resolved.paramString("service");
return flow -> {
Flowable<NavajoStreamEvent> result = client.callWithBodyToStream(server, e -> e.header("X-Navajo-Username", username).header("X-Navajo-Password", password).header("X-Navajo-Service", service), flow.map(di -> di.eventStream()).concatMap(e -> e).lift(StreamDocument.serialize()), "text/xml").lift(XML.parseFlowable(10)).concatMap(e -> e).lift(StreamDocument.parse()).concatMap(e -> e).filter(e -> e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_STARTED && e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_DONE);
return Flowable.just(DataItem.ofEventStream(result));
};
}
Aggregations