Search in sources :

Example 26 with IArchimateRelationship

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

the class PropertiesLabelProviderTests method testGetArchimateConceptText.

@Test
public void testGetArchimateConceptText() {
    // Type of element
    IArchimateElement element = IArchimateFactory.eINSTANCE.createArtifact();
    assertEquals("Artifact", provider.getArchimateConceptText(element));
    // Type of relation
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    assertEquals("Assignment relation", provider.getArchimateConceptText(relation));
    // Name + type
    relation.setName("Hello");
    assertEquals("Hello (Assignment relation)", provider.getArchimateConceptText(relation));
    // Null is OK
    relation.setName(null);
    assertEquals("Assignment relation", provider.getArchimateConceptText(relation));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 27 with IArchimateRelationship

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

the class DeleteCommandHandlerTests method testDelete_Elements_Deleted_Attached_Relations.

@Test
public void testDelete_Elements_Deleted_Attached_Relations() {
    // Element 1
    IArchimateElement businessActor = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "31a27739");
    assertNotNull(businessActor);
    // Element 2
    IArchimateElement businessRole = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "8ab84e91");
    assertNotNull(businessRole);
    // Connecting relationship
    IArchimateRelationship relationship = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "3bede7f0");
    assertNotNull(relationship);
    // Relationship is there on a diagram
    assertTrue(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(relationship));
    // Zap
    DeleteCommandHandler commandHandler = new DeleteCommandHandler(treeModelViewer, new Object[] { businessActor, businessRole });
    commandHandler.delete();
    // All gone
    assertNull(ArchimateModelUtils.getObjectByID(model, relationship.getId()));
    assertFalse(DiagramModelUtils.isArchimateConceptReferencedInDiagrams(relationship));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 28 with IArchimateRelationship

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

the class DuplicateCommandHandlerTests method testDuplicateDiagramModel.

@Test
public void testDuplicateDiagramModel() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IDiagramModel dm = model.getDefaultDiagramModel();
    IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
    dmo1.setName("dm");
    dm.getChildren().add(dmo1);
    IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
    dm.getChildren().add(dmo2);
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation.setSource(actor);
    relation.setTarget(role);
    IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
    dmc1.connect(dmo1, dmo2);
    DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
    handler.duplicate();
    assertEquals(2, model.getDiagramModels().size());
    IDiagramModel dmCopy = model.getDiagramModels().get(1);
    assertNotSame(dm, dmCopy);
    assertEquals(dm.getName() + " (copy)", dmCopy.getName());
    EList<IDiagramModelObject> children = dmCopy.getChildren();
    assertEquals(2, children.size());
    IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0);
    IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1);
    assertNotSame(dmo1, dmo1Copy);
    assertNotSame(dmo2, dmo2Copy);
    assertSame(actor, dmo1Copy.getArchimateConcept());
    assertSame(role, dmo2Copy.getArchimateConcept());
    EList<IDiagramModelConnection> connections = dmo1Copy.getSourceConnections();
    assertEquals(1, connections.size());
    IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) connections.get(0);
    assertNotSame(dmc1, dmc1Copy);
    assertSame(relation, dmc1Copy.getArchimateConcept());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Example 29 with IArchimateRelationship

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

the class ArchimateDiagramEditPartFactoryTests method testArchimateConnectionEditPart.

@Test
public void testArchimateConnectionEditPart() {
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAccessRelationship();
    IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    conn.setArchimateRelationship(relation);
    EditPart editPart = editPartFactory.createEditPart(null, conn);
    assertTrue(editPart instanceof ArchimateRelationshipEditPart);
    assertEquals(conn, editPart.getModel());
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) GroupEditPart(com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) EditPart(org.eclipse.gef.EditPart) EmptyEditPart(com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 30 with IArchimateRelationship

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

the class CSVImporterTests method testFindReferencedConcept_IsRelationship.

@Test
public void testFindReferencedConcept_IsRelationship() throws Exception {
    importer.doImport(elements1File);
    IArchimateConcept concept = importer.findReferencedConcept("5854f8a3");
    assertTrue(concept instanceof IArchimateRelationship);
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) 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