use of org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput in project sirius-components by eclipse-sirius.
the class QueryBasedIntEventHandlerTests method handle.
private void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IQueryService queryService) {
QueryBasedIntEventHandler queryBasedIntEventHandler = new QueryBasedIntEventHandler(new ICollaborativeMessageService.NoOp(), new SimpleMeterRegistry(), queryService);
// $NON-NLS-1$
IInput input = new QueryBasedIntInput(UUID.randomUUID(), "", Map.of());
assertThat(queryBasedIntEventHandler.canHandle(new IEditingContext.NoOp(), input)).isTrue();
IEditingContext editingContext = () -> UUID.randomUUID().toString();
queryBasedIntEventHandler.handle(payloadSink, changeDescriptionSink, editingContext, input);
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput in project sirius-components by eclipse-sirius.
the class QueryBasedIntEventHandlerTests method testQueryBasedInt.
@Test
public void testQueryBasedInt() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedIntInput input) {
return new QueryBasedIntSuccessPayload(UUID.randomUUID(), EXPECTED_RESULT_10);
}
};
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(QueryBasedIntSuccessPayload.class);
assertThat(((QueryBasedIntSuccessPayload) payload).getResult()).isEqualTo(EXPECTED_RESULT_10);
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput in project sirius-components by eclipse-sirius.
the class EMFQueryServiceTests method testEMFQueryServiceContents.
@Test
public void testEMFQueryServiceContents() {
IEditingContext editingContext = this.createEditingContext();
IEditingContextEPackageService editingContextEPackageService = new IEditingContextEPackageService() {
@Override
public List<EPackage> getEPackages(String editingContextId) {
return List.of(EcorePackage.eINSTANCE);
}
};
IQueryService queryService = new EMFQueryService(editingContextEPackageService, List.of());
// $NON-NLS-1$
QueryBasedIntInput input = new QueryBasedIntInput(UUID.randomUUID(), "aql:editingContext.contents()->size()", Map.of());
IPayload payload = queryService.execute(editingContext, input);
assertTrue(payload instanceof QueryBasedIntSuccessPayload);
assertEquals(2, ((QueryBasedIntSuccessPayload) payload).getResult());
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput in project sirius-components by eclipse-sirius.
the class EMFQueryServiceTests method testEMFQueryServiceAllContents.
@Test
public void testEMFQueryServiceAllContents() {
IEditingContext editingContext = this.createEditingContext();
IEditingContextEPackageService editingContextEPackageService = new IEditingContextEPackageService() {
@Override
public List<EPackage> getEPackages(String editingContextId) {
return List.of(EcorePackage.eINSTANCE);
}
};
IQueryService queryService = new EMFQueryService(editingContextEPackageService, List.of());
// $NON-NLS-1$
QueryBasedIntInput input = new QueryBasedIntInput(UUID.randomUUID(), "aql:editingContext.allContents()->size()", Map.of());
IPayload payload = queryService.execute(editingContext, input);
assertTrue(payload instanceof QueryBasedIntSuccessPayload);
assertEquals(8, ((QueryBasedIntSuccessPayload) payload).getResult());
}
use of org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput in project sirius-components by eclipse-sirius.
the class QueryBasedIntEventHandlerTests method testQueryBasedIntFailed.
@Test
public void testQueryBasedIntFailed() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedIntInput input) {
// $NON-NLS-1$
return new ErrorPayload(UUID.randomUUID(), "An error occured");
}
};
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(ErrorPayload.class);
}
Aggregations