Search in sources :

Example 21 with IArchimateRelationship

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

the class DiagramModelUtilsNestedRelationsTests method testIsNestedConnectionTypeRelationship.

// =================================================================================================
@Test
public void testIsNestedConnectionTypeRelationship() {
    // Should be all relations
    for (EClass eClass : ArchimateModelUtils.getRelationsClasses()) {
        IArchimateRelationship rel = (IArchimateRelationship) IArchimateFactory.eINSTANCE.create(eClass);
        assertTrue(DiagramModelUtils.isNestedConnectionTypeRelationship(rel));
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 22 with IArchimateRelationship

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

the class DiagramModelUtilsTests method findDiagramModelConnectionsForRelation.

@Test
public void findDiagramModelConnectionsForRelation() {
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateConnection> list = DiagramModelUtils.findDiagramModelConnectionsForRelation(diagramModel, relationship);
    assertTrue(list.isEmpty());
    // Create various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel);
    // And make some connections using the relationship
    createDataForDiagramModelConnections(relationship);
    // Should be found in a dm
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(diagramModel, relationship);
    assertEquals(3, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 23 with IArchimateRelationship

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

the class ModelCheckerTests method checkRelationsHaveElements.

@Test
public void checkRelationsHaveElements() {
    IArchimateElement src = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
    IArchimateElement tgt = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
    IArchimateRelationship relation = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getAssociationRelationship());
    relation.setSource(src);
    relation.setTarget(tgt);
    List<String> messages = modelChecker.checkRelationsHaveElements();
    assertEquals(0, messages.size());
    relation.setSource(null);
    relation.setTarget(null);
    messages = modelChecker.checkRelationsHaveElements();
    assertEquals(2, messages.size());
    assertTrue(messages.get(0).startsWith("Relationship has missing referenced source element"));
    assertTrue(messages.get(1).startsWith("Relationship has missing referenced target element"));
    relation.setSource(src);
    relation.setTarget(tgt);
    model.getFolder(FolderType.BUSINESS).getElements().remove(src);
    model.getFolder(FolderType.BUSINESS).getElements().remove(tgt);
    messages = modelChecker.checkRelationsHaveElements();
    assertEquals(2, messages.size());
    assertTrue(messages.get(0).startsWith("Relationship has orphaned source element"));
    assertTrue(messages.get(1).startsWith("Relationship has orphaned target element"));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 24 with IArchimateRelationship

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

the class CommandsTests method testDeleteArchimateRelationshipCommand.

@Test
public void testDeleteArchimateRelationshipCommand() {
    IArchimateRelationship relationship = (IArchimateRelationship) tm.getObjectByID("670aa5ed");
    assertNotNull(relationship);
    assertTrue(relationship.getSource().getSourceRelationships().contains(relationship));
    assertTrue(relationship.getTarget().getTargetRelationships().contains(relationship));
    IFolder parent = (IFolder) relationship.eContainer();
    DeleteArchimateRelationshipCommand cmd = new DeleteArchimateRelationshipCommand(relationship);
    cmd.execute();
    assertNull(relationship.eContainer());
    assertFalse(parent.getElements().contains(relationship));
    assertFalse(relationship.getSource().getSourceRelationships().contains(relationship));
    assertFalse(relationship.getTarget().getTargetRelationships().contains(relationship));
    cmd.undo();
    assertEquals(11, parent.getElements().indexOf(relationship));
}
Also used : IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IFolder(com.archimatetool.model.IFolder) Test(org.junit.Test)

Example 25 with IArchimateRelationship

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

the class PropertiesLabelProviderTests method testGetImageRelation.

@Test
public void testGetImageRelation() {
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    // Image for relation
    Image image1 = provider.getImage(new StructuredSelection(relation));
    assertNotNull(image1);
    // Image for DiagramModelArchimateConnection
    IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    connection.setArchimateRelationship(relation);
    Image image2 = provider.getImage(new StructuredSelection(connection));
    assertSame(image1, image2);
    // Image for EditPart
    EditPart editPart = new ArchimateRelationshipEditPart(AssignmentConnectionFigure.class);
    editPart.setModel(connection);
    Image image3 = provider.getImage(new StructuredSelection(editPart));
    assertSame(image1, image3);
}
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) ArchimateElementEditPart(com.archimatetool.editor.diagram.editparts.ArchimateElementEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) EditPart(org.eclipse.gef.EditPart) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Image(org.eclipse.swt.graphics.Image) Test(org.junit.Test)

Aggregations

IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)74 Test (org.junit.Test)39 IArchimateElement (com.archimatetool.model.IArchimateElement)33 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)22 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)15 ArrayList (java.util.ArrayList)15 IArchimateConcept (com.archimatetool.model.IArchimateConcept)14 IDiagramModel (com.archimatetool.model.IDiagramModel)12 IArchimateModel (com.archimatetool.model.IArchimateModel)9 EObject (org.eclipse.emf.ecore.EObject)9 IIssue (com.archimatetool.hammer.validation.issues.IIssue)7 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)7 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 ErrorType (com.archimatetool.hammer.validation.issues.ErrorType)4 IFolder (com.archimatetool.model.IFolder)4 EClass (org.eclipse.emf.ecore.EClass)4 Command (org.eclipse.gef.commands.Command)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3