use of org.eclipse.sirius.components.collaborative.dto.QueryBasedBooleanSuccessPayload in project sirius-components by eclipse-sirius.
the class EMFQueryService method execute.
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedBooleanInput input) {
Result result = this.executeQuery(editingContext, input.getQuery(), input.getVariables());
Optional<Boolean> optionalBoolean = result.asBoolean();
if (optionalBoolean.isPresent()) {
return new QueryBasedBooleanSuccessPayload(input.getId(), optionalBoolean.get().booleanValue());
} else {
return new ErrorPayload(input.getId(), EVALUATION_ERROR_MESSAGE + result.getStatus());
}
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedBooleanSuccessPayload in project sirius-components by eclipse-sirius.
the class QueryBasedBooleanEventHandlerTests method testQueryBasedBoolean.
@Test
public void testQueryBasedBoolean() {
// The EMFQueryService implementation is already tested by another class.
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedBooleanInput input) {
return new QueryBasedBooleanSuccessPayload(UUID.randomUUID(), EXPECTED_RESULT_FALSE);
}
};
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(QueryBasedBooleanSuccessPayload.class);
assertThat(((QueryBasedBooleanSuccessPayload) payload).getResult()).isEqualTo(EXPECTED_RESULT_FALSE);
}
Aggregations