Search in sources :

Example 56 with IDiagramModelArchimateConnection

use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.

the class ModelCheckerTests method checkDiagramModelArchimateConnection.

@Test
public void checkDiagramModelArchimateConnection() {
    model.getDefaultDiagramModel().setName("dm");
    IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
    model.getDefaultDiagramModel().getChildren().add(dmo1);
    IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
    model.getDefaultDiagramModel().getChildren().add(dmo2);
    IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation.setSource(actor);
    relation.setTarget(role);
    IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
    dmc1.connect(dmo1, dmo2);
    List<String> messages = modelChecker.checkDiagramModelArchimateConnection(dmc1);
    assertEquals(0, messages.size());
    model.getFolder(FolderType.RELATIONS).getElements().remove(relation);
    model.getFolder(FolderType.BUSINESS).getElements().remove(actor);
    model.getFolder(FolderType.BUSINESS).getElements().remove(role);
    messages = modelChecker.checkDiagramModelArchimateConnection(dmc1);
    assertEquals(3, messages.size());
    assertTrue(messages.get(0).startsWith("Diagram Connection has orphaned ArchiMate relation in 'dm'"));
    assertTrue(messages.get(1).startsWith("Diagram Connection has orphaned ArchiMate source element in 'dm'"));
    assertTrue(messages.get(2).startsWith("Diagram Connection has orphaned ArchiMate target element in 'dm'"));
}
Also used : IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 57 with IDiagramModelArchimateConnection

use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.

the class FormatPainterToolTests method testCreateCommandForDiagramModelArchimateConnection.

@Test
public void testCreateCommandForDiagramModelArchimateConnection() throws Exception {
    // Source component
    IDiagramModelArchimateConnection sourceComponent = ArchimateTestModel.createDiagramModelArchimateConnection(IArchimateFactory.eINSTANCE.createAccessRelationship());
    // Target component
    IDiagramModelArchimateConnection targetComponent = ArchimateTestModel.createDiagramModelArchimateConnection(IArchimateFactory.eINSTANCE.createAccessRelationship());
    // Set FormatPainterInfo to Source component
    FormatPainterInfo.INSTANCE.updatePaintFormat(sourceComponent);
    PaintFormat pf = FormatPainterInfo.INSTANCE.getPaintFormat();
    // Execute command
    FormatPainterTool tool = new FormatPainterTool();
    CompoundCommand compoundCmd = tool.createCommand(pf, targetComponent);
    // Should be no commands
    assertEquals(0, compoundCmd.getCommands().size());
    // Now change some properties on the source component
    sourceComponent.setFont("Consolas");
    sourceComponent.setFontColor("#eeeeee");
    sourceComponent.setLineColor("#eeeeee");
    sourceComponent.setLineWidth(3);
    sourceComponent.setTextPosition(3);
    compoundCmd = tool.createCommand(pf, targetComponent);
    assertEquals(5, compoundCmd.getCommands().size());
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Test(org.junit.Test)

Example 58 with IDiagramModelArchimateConnection

use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.

the class CopySnapshotTests method testNestedConnectionIsCopied.

@Test
public void testNestedConnectionIsCopied() throws IOException {
    loadTestModel1();
    // Create parent object
    IDiagramModelArchimateObject dmoParent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    dmoParent.setBounds(0, 0, 200, 200);
    sourceDiagramModel.getChildren().add(dmoParent);
    // Create child object
    IDiagramModelArchimateObject dmoChild = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessRole());
    dmoChild.setBounds(0, 0, 100, 100);
    dmoParent.getChildren().add(dmoChild);
    // Create relationship
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relationship.setSource(dmoParent.getArchimateElement());
    relationship.setTarget(dmoChild.getArchimateElement());
    // Test that an explicit connection is copied
    // Create connection
    IDiagramModelArchimateConnection connection = ArchimateTestModel.createDiagramModelArchimateConnection(relationship);
    connection.connect(dmoParent, dmoChild);
    List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
    selected.add(dmoParent);
    CopySnapshot snapshot = new CopySnapshot(selected);
    Command cmd = snapshot.getPasteCommand(targetDiagramModel, null, null, false);
    assertNotNull(cmd);
    cmd.execute();
    assertEquals(1, countAllConnections(targetDiagramModel));
}
Also used : IDiagramModelComponent(com.archimatetool.model.IDiagramModelComponent) Command(org.eclipse.gef.commands.Command) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 59 with IDiagramModelArchimateConnection

use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.

the class PropertiesLabelProviderTests method testGetTextRelation.

@Test
public void testGetTextRelation() {
    // Text for relation
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation.setSource(IArchimateFactory.eINSTANCE.createBusinessActor());
    relation.setTarget(IArchimateFactory.eINSTANCE.createBusinessRole());
    relation.getSource().setName("BA1");
    relation.getTarget().setName("BR1");
    String expectedText = "Assignment relation (BA1 - BR1)";
    String text = provider.getText(new StructuredSelection(relation));
    assertEquals(expectedText, text);
    text = provider.getText(new StructuredSelection(relation));
    assertEquals(expectedText, text);
    // Text for DiagramModelArchimateConnection
    IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    connection.setArchimateRelationship(relation);
    text = provider.getText(new StructuredSelection(relation));
    assertEquals(expectedText, text);
    // Text for EditPart
    EditPart editPart = new ArchimateRelationshipEditPart(AssignmentConnectionFigure.class);
    editPart.setModel(connection);
    text = provider.getText(new StructuredSelection(editPart));
    assertEquals(expectedText, text);
}
Also used : ArchimateRelationshipEditPart(com.archimatetool.editor.diagram.editparts.ArchimateRelationshipEditPart) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArchimateRelationshipEditPart(com.archimatetool.editor.diagram.editparts.ArchimateRelationshipEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) ArchimateElementEditPart(com.archimatetool.editor.diagram.editparts.ArchimateElementEditPart) EditPart(org.eclipse.gef.EditPart) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Aggregations

IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)59 Test (org.junit.Test)31 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)29 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)27 IArchimateElement (com.archimatetool.model.IArchimateElement)20 IDiagramModel (com.archimatetool.model.IDiagramModel)10 IArchimateConcept (com.archimatetool.model.IArchimateConcept)9 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)9 IArchimateModel (com.archimatetool.model.IArchimateModel)8 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)8 ArrayList (java.util.ArrayList)8 EObject (org.eclipse.emf.ecore.EObject)8 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)7 IAssignmentRelationship (com.archimatetool.model.IAssignmentRelationship)6 IConnectable (com.archimatetool.model.IConnectable)6 Command (org.eclipse.gef.commands.Command)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 EClass (org.eclipse.emf.ecore.EClass)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3