use of org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput in project sirius-components by eclipse-sirius.
the class ArrangeAllEventHandlerTests method testArrangeAll.
@Test
public void testArrangeAll() {
var handler = new ArrangeAllEventHandler(new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry());
// $NON-NLS-1$//$NON-NLS-2$
var input = new ArrangeAllInput(UUID.randomUUID(), "editingContextId", "representationId");
assertThat(handler.canHandle(input)).isTrue();
One<IPayload> payloadSink = Sinks.one();
Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
IDiagramContext diagramContext = new DiagramContext(new TestDiagramBuilder().getDiagram(UUID.randomUUID().toString()));
handler.handle(payloadSink, changeDescriptionSink, new IEditingContext.NoOp(), diagramContext, input);
ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
assertThat(changeDescription.getKind()).isEqualTo(DiagramChangeKind.DIAGRAM_LAYOUT_CHANGE);
IPayload payload = payloadSink.asMono().block();
assertThat(payload).isInstanceOf(ArrangeAllSuccessPayload.class);
assertThat(diagramContext.getDiagramEvent()).isInstanceOf(ArrangeAllEvent.class);
}
use of org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput in project sirius-components by eclipse-sirius.
the class ArrangeAllEventHandler method handle.
@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IDiagramContext diagramContext, IDiagramInput diagramInput) {
this.counter.increment();
String message = this.messageService.invalidInput(diagramInput.getClass().getSimpleName(), InvokeSingleClickOnDiagramElementToolInput.class.getSimpleName());
IPayload payload = new ErrorPayload(diagramInput.getId(), message);
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, diagramInput.getRepresentationId(), diagramInput);
if (diagramInput instanceof ArrangeAllInput) {
diagramContext.setDiagramEvent(new ArrangeAllEvent());
payload = new ArrangeAllSuccessPayload(diagramInput.getId());
changeDescription = new ChangeDescription(DiagramChangeKind.DIAGRAM_LAYOUT_CHANGE, diagramInput.getRepresentationId(), diagramInput);
}
payloadSink.tryEmitValue(payload);
changeDescriptionSink.tryEmitNext(changeDescription);
}
Aggregations