Search in sources :

Example 1 with EdgeMappingConverter

use of org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter in project sirius-components by eclipse-sirius.

the class EdgeMappingConverterTests method testEdgeFromNodeToContainer.

/**
 * Non-regression test for the create edges issue. This test will ensure that a container description can be used as
 * a valid target for an edge.
 */
@Test
public void testEdgeFromNodeToContainer() {
    EdgeMapping edgeMapping = DescriptionFactory.eINSTANCE.createEdgeMapping();
    NodeMapping nodeMapping = DescriptionFactory.eINSTANCE.createNodeMapping();
    // $NON-NLS-1$
    nodeMapping.setName("nodeMapping");
    ContainerMapping containerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    containerMapping.setName("containerMapping");
    edgeMapping.getSourceMapping().add(nodeMapping);
    edgeMapping.getTargetMapping().add(containerMapping);
    // @formatter:off
    UUID nodeMappingUUID = UUID.nameUUIDFromBytes(nodeMapping.getName().getBytes());
    UUID containerMappingUUID = UUID.nameUUIDFromBytes(containerMapping.getName().getBytes());
    Map<UUID, NodeDescription> id2NodeDescriptions = Map.of(nodeMappingUUID, this.createNodeDescription(nodeMappingUUID), containerMappingUUID, this.createNodeDescription(containerMappingUUID));
    // @formatter:on
    IObjectService objectService = new IObjectService.NoOp();
    IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp();
    IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() {

        @Override
        public String getIdentifier(Object element) {
            return containerMappingUUID.toString();
        }
    };
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new;
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, List.of(), interpeter);
    EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(new IObjectService.NoOp(), new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
    EdgeDescription edgeDescription = edgeMappingConverter.convert(edgeMapping, new AQLInterpreter(List.of(), List.of()), id2NodeDescriptions);
    assertThat(edgeDescription.getTargetNodeDescriptions()).contains(id2NodeDescriptions.get(containerMappingUUID));
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Size(org.eclipse.sirius.components.diagrams.Size) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) IEditService(org.eclipse.sirius.components.core.api.IEditService) SemanticCandidatesProvider(org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Optional(java.util.Optional) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) IEditService(org.eclipse.sirius.components.core.api.IEditService) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 2 with EdgeMappingConverter

use of org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter in project sirius-components by eclipse-sirius.

the class EdgeMappingConverterTests method testEdgeFromContainerToContainer.

/**
 * Non-regression test for the create edges issue. This test will ensure that a container description can be used as
 * both a valid source and a valid target for an edge.
 */
@Test
public void testEdgeFromContainerToContainer() {
    EdgeMapping edgeMapping = DescriptionFactory.eINSTANCE.createEdgeMapping();
    ContainerMapping sourceContainerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    sourceContainerMapping.setName("sourceContainerMapping");
    ContainerMapping targetContainerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    targetContainerMapping.setName("targetContainerMapping");
    edgeMapping.getSourceMapping().add(sourceContainerMapping);
    edgeMapping.getTargetMapping().add(targetContainerMapping);
    // @formatter:off
    UUID sourceContainerMappingUUID = UUID.nameUUIDFromBytes(sourceContainerMapping.getName().getBytes());
    UUID targetContainerMappingUUID = UUID.nameUUIDFromBytes(targetContainerMapping.getName().getBytes());
    Map<UUID, NodeDescription> id2NodeDescriptions = Map.of(sourceContainerMappingUUID, this.createNodeDescription(sourceContainerMappingUUID), targetContainerMappingUUID, this.createNodeDescription(targetContainerMappingUUID));
    // @formatter:on
    IObjectService objectService = new IObjectService.NoOp();
    IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp();
    IIdentifierProvider identifierProvider = new IIdentifierProvider() {

        @Override
        public String getIdentifier(Object element) {
            return targetContainerMappingUUID.toString();
        }

        @Override
        public Optional<String> findVsmElementId(UUID id) {
            return Optional.empty();
        }
    };
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new;
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, List.of(), interpeter);
    EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(objectService, new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
    EdgeDescription edgeDescription = edgeMappingConverter.convert(edgeMapping, new AQLInterpreter(List.of(), List.of()), id2NodeDescriptions);
    edgeDescription.getSourceNodeDescriptions().contains(id2NodeDescriptions.get(sourceContainerMappingUUID));
    assertThat(edgeDescription.getTargetNodeDescriptions()).contains(id2NodeDescriptions.get(targetContainerMappingUUID));
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Size(org.eclipse.sirius.components.diagrams.Size) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) IEditService(org.eclipse.sirius.components.core.api.IEditService) SemanticCandidatesProvider(org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Optional(java.util.Optional) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) IEditService(org.eclipse.sirius.components.core.api.IEditService) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 3 with EdgeMappingConverter

use of org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter in project sirius-components by eclipse-sirius.

the class EdgeMappingConverterTests method testEdgeFromContainerToNode.

/**
 * Non-regression test for the create edges issue. This test will ensure that a container description can be used as
 * a valid source for an edge.
 */
@Test
public void testEdgeFromContainerToNode() {
    EdgeMapping edgeMapping = DescriptionFactory.eINSTANCE.createEdgeMapping();
    NodeMapping nodeMapping = DescriptionFactory.eINSTANCE.createNodeMapping();
    // $NON-NLS-1$
    nodeMapping.setName("nodeMapping");
    ContainerMapping containerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    containerMapping.setName("containerMapping");
    edgeMapping.getSourceMapping().add(containerMapping);
    edgeMapping.getTargetMapping().add(nodeMapping);
    // @formatter:off
    UUID nodeMappingUUID = UUID.nameUUIDFromBytes(nodeMapping.getName().getBytes());
    UUID containerMappingUUID = UUID.nameUUIDFromBytes(containerMapping.getName().getBytes());
    Map<UUID, NodeDescription> id2NodeDescriptions = Map.of(nodeMappingUUID, this.createNodeDescription(nodeMappingUUID), containerMappingUUID, this.createNodeDescription(containerMappingUUID));
    // @formatter:on
    IObjectService objectService = new IObjectService.NoOp();
    IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp();
    IIdentifierProvider identifierProvider = new IIdentifierProvider() {

        @Override
        public String getIdentifier(Object element) {
            return containerMappingUUID.toString();
        }

        @Override
        public Optional<String> findVsmElementId(UUID id) {
            return Optional.empty();
        }
    };
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new;
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, List.of(), interpeter);
    EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(objectService, new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
    EdgeDescription edgeDescription = edgeMappingConverter.convert(edgeMapping, new AQLInterpreter(List.of(), List.of()), id2NodeDescriptions);
    assertThat(edgeDescription.getSourceNodeDescriptions()).contains(id2NodeDescriptions.get(containerMappingUUID));
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Size(org.eclipse.sirius.components.diagrams.Size) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) IEditService(org.eclipse.sirius.components.core.api.IEditService) SemanticCandidatesProvider(org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Optional(java.util.Optional) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) IEditService(org.eclipse.sirius.components.core.api.IEditService) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

List (java.util.List)3 Map (java.util.Map)3 Optional (java.util.Optional)3 UUID (java.util.UUID)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 IIdentifierProvider (org.eclipse.sirius.components.compatibility.api.IIdentifierProvider)3 IModelOperationHandlerSwitchProvider (org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider)3 ISemanticCandidatesProviderFactory (org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory)3 EdgeMappingConverter (org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter)3 IEditService (org.eclipse.sirius.components.core.api.IEditService)3 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)3 IRepresentationMetadataSearchService (org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService)3 Size (org.eclipse.sirius.components.diagrams.Size)3 EdgeDescription (org.eclipse.sirius.components.diagrams.description.EdgeDescription)3 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)3 LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)3 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)3 SemanticCandidatesProvider (org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider)3 ModelOperationHandlerSwitch (org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch)3 AQLInterpreter (org.eclipse.sirius.components.interpreter.AQLInterpreter)3