use of org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder in project sirius-components by eclipse-sirius.
the class ChildModelOperationHandlerTests method testChildModelOperationWithoutSelection.
@Test
public void testChildModelOperationWithoutSelection() {
CreateView createView = ToolFactory.eINSTANCE.createCreateView();
// $NON-NLS-1$
createView.setContainerViewExpression("");
// $NON-NLS-1$
createView.setVariableName("");
createView.setMapping(DescriptionFactory.eINSTANCE.createNodeMapping());
IObjectService objectService = new IObjectService.NoOp() {
@Override
public String getId(Object object) {
// $NON-NLS-1$
return "";
}
};
IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() {
@Override
public String getIdentifier(Object element) {
// $NON-NLS-1$
return UUID.nameUUIDFromBytes("node".getBytes()).toString();
}
};
AQLInterpreter interpreter = new AQLInterpreter(List.of(), List.of()) {
@Override
public Result evaluateExpression(Map<String, Object> variables, String expressionBody) {
// $NON-NLS-1$
Object value = new TestDiagramBuilder().getDiagram("diagramId");
return new Result(Optional.of(value), Status.OK);
}
};
IStatus status = new ChildModelOperationHandler(List.of()).handle(objectService, new IRepresentationMetadataSearchService.NoOp(), identifierProvider, interpreter, Map.of(), List.of(createView));
assertThat(status).isInstanceOf(Success.class);
Success success = (Success) status;
Object selectionParameter = success.getParameters().get(Success.NEW_SELECTION);
assertThat(selectionParameter).isNull();
}
use of org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder 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);
}
use of org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder 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);
}
use of org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder in project sirius-components by eclipse-sirius.
the class NodeSizeProviderTests method createNodeLayoutData.
private NodeLayoutData createNodeLayoutData(Size size) {
TestDiagramBuilder testDiagramBuilder = new TestDiagramBuilder();
NodeLayoutData nodeLayoutData = new NodeLayoutData();
nodeLayoutData.setId(UUID.randomUUID().toString());
nodeLayoutData.setSize(size);
nodeLayoutData.setNodeType(NodeType.NODE_RECTANGLE);
nodeLayoutData.setStyle(testDiagramBuilder.getRectangularNodeStyle());
return nodeLayoutData;
}
use of org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder in project sirius-components by eclipse-sirius.
the class DiagramConverterTests method testDiagramOneNodeAndOneBorderNode.
@Test
public void testDiagramOneNodeAndOneBorderNode() {
ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
ELKDiagramConverter diagramConverter = new ELKDiagramConverter(this.textBoundsService, imageSizeProvider);
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node borderNode = Node.newNode(diagramBuilder.getNode(FIRST_NODE_ID)).style(diagramBuilder.getRectangularNodeStyle()).build();
Node node = Node.newNode(diagramBuilder.getNode(SECOND_NODE_ID)).style(diagramBuilder.getImageNodeStyle()).borderNodes(List.of(borderNode)).build();
Diagram diagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = diagramConverter.convert(diagram);
ElkNode elkDiagram = convertedDiagram.getElkDiagram();
assertThat(elkDiagram.getChildren().size()).isEqualTo(1);
ElkNode elkNode = elkDiagram.getChildren().get(0);
assertThat(elkNode.getPorts().size()).isEqualTo(1);
ElkPort elkPort = elkNode.getPorts().get(0);
assertThat(elkPort.getIdentifier()).isEqualTo(borderNode.getId().toString());
imageSizeProvider.dispose();
}
Aggregations