Search in sources :

Example 1 with DiagramContext

use of org.eclipse.sirius.components.collaborative.diagrams.DiagramContext in project sirius-components by eclipse-sirius.

the class DeleteFromDiagramEventHandlerTests method testEdgeSemanticDeletionFromDiagram.

@Test
public void testEdgeSemanticDeletionFromDiagram() {
    var handler = new DeleteFromDiagramEventHandler(this.objectService, this.diagramQueryService, this.diagramDescriptionService, this.representationDescriptionSearchService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry());
    var nodeIds = List.<String>of();
    var edgeIds = List.<String>of(EDGE_ID);
    // $NON-NLS-1$ //$NON-NLS-2$
    var input = new DeleteFromDiagramInput(UUID.randomUUID(), "editingContextId", "representationId", nodeIds, edgeIds, DeletionPolicy.SEMANTIC);
    One<IPayload> payloadSink = Sinks.one();
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    assertThat(handler.canHandle(input)).isTrue();
    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(ChangeKind.SEMANTIC_CHANGE);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(DeleteFromDiagramSuccessPayload.class);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IPayload(org.eclipse.sirius.components.core.api.IPayload) DeleteFromDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.dto.DeleteFromDiagramInput) DiagramContext(org.eclipse.sirius.components.collaborative.diagrams.DiagramContext) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) TestDiagramBuilder(org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) ICollaborativeDiagramMessageService(org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Test(org.junit.jupiter.api.Test)

Example 2 with DiagramContext

use of org.eclipse.sirius.components.collaborative.diagrams.DiagramContext in project sirius-components by eclipse-sirius.

the class DeleteFromDiagramEventHandlerTests method testNodeSemanticDeletionFromDiagram.

@Test
public void testNodeSemanticDeletionFromDiagram() {
    var handler = new DeleteFromDiagramEventHandler(this.objectService, this.diagramQueryService, this.diagramDescriptionService, this.representationDescriptionSearchService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry());
    var nodeIds = List.of(NODE_ID);
    var edgeIds = List.<String>of();
    // $NON-NLS-1$ //$NON-NLS-2$
    var input = new DeleteFromDiagramInput(UUID.randomUUID(), "editingContextId", "representationId", nodeIds, edgeIds, DeletionPolicy.SEMANTIC);
    One<IPayload> payloadSink = Sinks.one();
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    assertThat(handler.canHandle(input)).isTrue();
    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(ChangeKind.SEMANTIC_CHANGE);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(DeleteFromDiagramSuccessPayload.class);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IPayload(org.eclipse.sirius.components.core.api.IPayload) DeleteFromDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.dto.DeleteFromDiagramInput) DiagramContext(org.eclipse.sirius.components.collaborative.diagrams.DiagramContext) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) TestDiagramBuilder(org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) ICollaborativeDiagramMessageService(org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Test(org.junit.jupiter.api.Test)

Example 3 with DiagramContext

use of org.eclipse.sirius.components.collaborative.diagrams.DiagramContext 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);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IPayload(org.eclipse.sirius.components.core.api.IPayload) ArrangeAllInput(org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) DiagramContext(org.eclipse.sirius.components.collaborative.diagrams.DiagramContext) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) TestDiagramBuilder(org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) ICollaborativeDiagramMessageService(org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)3 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)3 DiagramContext (org.eclipse.sirius.components.collaborative.diagrams.DiagramContext)3 IDiagramContext (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext)3 ICollaborativeDiagramMessageService (org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService)3 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)3 IPayload (org.eclipse.sirius.components.core.api.IPayload)3 TestDiagramBuilder (org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder)3 Test (org.junit.jupiter.api.Test)3 DeleteFromDiagramInput (org.eclipse.sirius.components.collaborative.diagrams.dto.DeleteFromDiagramInput)2 ArrangeAllInput (org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput)1