Search in sources :

Example 1 with Navigation

use of org.eclipse.sirius.diagram.description.tool.Navigation in project sirius-components by eclipse-sirius.

the class NavigationOperationHandlerTests method testMultipleChildModelOperationWithSelection.

@Test
public void testMultipleChildModelOperationWithSelection() {
    DiagramDescription firstDiagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription();
    firstDiagramDescription.setLabel(FIRST_DIAGRAM_DESCRIPTION_ID.toString());
    Navigation firstNavigation = ToolFactory.eINSTANCE.createNavigation();
    firstNavigation.setCreateIfNotExistent(false);
    firstNavigation.setDiagramDescription(firstDiagramDescription);
    DiagramDescription secondDiagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription();
    secondDiagramDescription.setLabel(SECOND_DIAGRAM_DESCRIPTION_ID.toString());
    Navigation secondNavigation = ToolFactory.eINSTANCE.createNavigation();
    secondNavigation.setCreateIfNotExistent(false);
    secondNavigation.setDiagramDescription(secondDiagramDescription);
    IStatus status = new ChildModelOperationHandler(List.of()).handle(new IObjectService.NoOp(), this.representationMetadataSearchService, this.diagramDescriptionIdentifierProvider, new AQLInterpreter(List.of(), List.of()), Map.of(IEditingContext.EDITING_CONTEXT, new IEditingContext.NoOp()), List.of(firstNavigation, secondNavigation));
    assertThat(status).isInstanceOf(Success.class);
    Success success = (Success) status;
    Object selectionParameter = success.getParameters().get(Success.NEW_SELECTION);
    assertThat(selectionParameter).isInstanceOf(WorkbenchSelection.class);
    WorkbenchSelection selection = (WorkbenchSelection) selectionParameter;
    // @formatter:off
    assertThat(selection).isEqualTo(new WorkbenchSelection(List.of(new WorkbenchSelectionEntry(FIRST_DIAGRAM_ID, FIRST_DIAGRAM_LABEL, Diagram.KIND), new WorkbenchSelectionEntry(SECOND_DIAGRAM_ID, SECOND_DIAGRAM_LABEL, Diagram.KIND), new WorkbenchSelectionEntry(THIRD_DIAGRAM_ID, THIRD_DIAGRAM_LABEL, Diagram.KIND))));
// @formatter:on
}
Also used : IStatus(org.eclipse.sirius.components.representations.IStatus) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Navigation(org.eclipse.sirius.diagram.description.tool.Navigation) WorkbenchSelectionEntry(org.eclipse.sirius.components.core.api.WorkbenchSelectionEntry) WorkbenchSelection(org.eclipse.sirius.components.core.api.WorkbenchSelection) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) DiagramDescription(org.eclipse.sirius.diagram.description.DiagramDescription) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) Success(org.eclipse.sirius.components.representations.Success) Test(org.junit.jupiter.api.Test)

Example 2 with Navigation

use of org.eclipse.sirius.diagram.description.tool.Navigation in project sirius-components by eclipse-sirius.

the class NavigationOperationHandlerTests method testChildModelOperationWithSelection.

@Test
public void testChildModelOperationWithSelection() {
    DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription();
    diagramDescription.setLabel(FIRST_DIAGRAM_DESCRIPTION_ID.toString());
    Navigation navigation = ToolFactory.eINSTANCE.createNavigation();
    navigation.setCreateIfNotExistent(false);
    navigation.setDiagramDescription(diagramDescription);
    IStatus status = new ChildModelOperationHandler(List.of()).handle(new IObjectService.NoOp(), this.representationMetadataSearchService, this.diagramDescriptionIdentifierProvider, new AQLInterpreter(List.of(), List.of()), Map.of(IEditingContext.EDITING_CONTEXT, new IEditingContext.NoOp()), List.of(navigation));
    assertThat(status).isInstanceOf(Success.class);
    Success success = (Success) status;
    Object selectionParameter = success.getParameters().get(Success.NEW_SELECTION);
    assertThat(selectionParameter).isInstanceOf(WorkbenchSelection.class);
    WorkbenchSelection selection = (WorkbenchSelection) selectionParameter;
    // @formatter:off
    assertThat(selection).isEqualTo(new WorkbenchSelection(List.of(new WorkbenchSelectionEntry(FIRST_DIAGRAM_ID, FIRST_DIAGRAM_LABEL, Diagram.KIND), new WorkbenchSelectionEntry(SECOND_DIAGRAM_ID, SECOND_DIAGRAM_LABEL, Diagram.KIND))));
// @formatter:on
}
Also used : IStatus(org.eclipse.sirius.components.representations.IStatus) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Navigation(org.eclipse.sirius.diagram.description.tool.Navigation) WorkbenchSelectionEntry(org.eclipse.sirius.components.core.api.WorkbenchSelectionEntry) WorkbenchSelection(org.eclipse.sirius.components.core.api.WorkbenchSelection) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) DiagramDescription(org.eclipse.sirius.diagram.description.DiagramDescription) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) Success(org.eclipse.sirius.components.representations.Success) Test(org.junit.jupiter.api.Test)

Aggregations

IObjectService (org.eclipse.sirius.components.core.api.IObjectService)2 WorkbenchSelection (org.eclipse.sirius.components.core.api.WorkbenchSelection)2 WorkbenchSelectionEntry (org.eclipse.sirius.components.core.api.WorkbenchSelectionEntry)2 ChildModelOperationHandler (org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler)2 AQLInterpreter (org.eclipse.sirius.components.interpreter.AQLInterpreter)2 IStatus (org.eclipse.sirius.components.representations.IStatus)2 Success (org.eclipse.sirius.components.representations.Success)2 DiagramDescription (org.eclipse.sirius.diagram.description.DiagramDescription)2 Navigation (org.eclipse.sirius.diagram.description.tool.Navigation)2 Test (org.junit.jupiter.api.Test)2