use of org.eclipse.sirius.components.collaborative.dto.QueryBasedStringSuccessPayload in project sirius-components by eclipse-sirius.
the class EMFQueryService method execute.
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedStringInput input) {
Result result = this.executeQuery(editingContext, input.getQuery(), input.getVariables());
Optional<String> optionalString = result.asString();
if (optionalString.isPresent()) {
return new QueryBasedStringSuccessPayload(input.getId(), optionalString.get());
} else {
return new ErrorPayload(input.getId(), EVALUATION_ERROR_MESSAGE + result.getStatus());
}
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedStringSuccessPayload in project sirius-components by eclipse-sirius.
the class QueryBasedStringEventHandlerTests method testQueryBasedString.
@Test
public void testQueryBasedString() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedStringInput input) {
return new QueryBasedStringSuccessPayload(UUID.randomUUID(), EXPECTED_RESULT);
}
};
Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
One<IPayload> payloadSink = Sinks.one();
this.handle(payloadSink, changeDescriptionSink, queryService);
ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.NOTHING);
IPayload payload = payloadSink.asMono().block();
assertThat(payload).isInstanceOf(QueryBasedStringSuccessPayload.class);
assertThat(((QueryBasedStringSuccessPayload) payload).getResult()).isEqualTo(EXPECTED_RESULT);
}
Aggregations