use of org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsSuccessPayload in project sirius-components by eclipse-sirius.
the class QueryBasedObjectsEventHandlerTests method testQueryBasedObjects.
@Test
public void testQueryBasedObjects() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedObjectsInput input) {
return new QueryBasedObjectsSuccessPayload(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(QueryBasedObjectsSuccessPayload.class);
assertThat(((QueryBasedObjectsSuccessPayload) payload).getResult()).isEqualTo(EXPECTED_RESULT);
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsSuccessPayload in project sirius-components by eclipse-sirius.
the class EMFQueryService method execute.
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedObjectsInput input) {
Result result = this.executeQuery(editingContext, input.getQuery(), input.getVariables());
Optional<List<Object>> optionalObjects = result.asObjects();
if (optionalObjects.isPresent()) {
return new QueryBasedObjectsSuccessPayload(input.getId(), optionalObjects.get());
} else {
return new ErrorPayload(input.getId(), EVALUATION_ERROR_MESSAGE + result.getStatus());
}
}
Aggregations