use of org.eclipse.sirius.components.collaborative.api.IQueryService in project sirius-components by eclipse-sirius.
the class QueryBasedBooleanEventHandlerTests method testQueryBasedBooleanFailed.
@Test
public void testQueryBasedBooleanFailed() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedBooleanInput 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);
}
use of org.eclipse.sirius.components.collaborative.api.IQueryService 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.api.IQueryService in project sirius-components by eclipse-sirius.
the class QueryBasedObjectEventHandlerTests method testQueryBasedObjectFailed.
@Test
public void testQueryBasedObjectFailed() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedObjectInput 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);
}
use of org.eclipse.sirius.components.collaborative.api.IQueryService 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.api.IQueryService in project sirius-components by eclipse-sirius.
the class QueryBasedObjectsEventHandlerTests method testQueryBasedObjectsFailed.
@Test
public void testQueryBasedObjectsFailed() {
IQueryService queryService = new IQueryService.NoOp() {
@Override
public IPayload execute(IEditingContext editingContext, QueryBasedObjectsInput 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