Search in sources :

Example 26 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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 27 with IArchimateElement

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

the class CommandsTests method testDeleteArchimateElementCommand.

@Test
public void testDeleteArchimateElementCommand() {
    IArchimateElement element = (IArchimateElement) tm.getObjectByID("1544");
    assertNotNull(element);
    IFolder parent = (IFolder) element.eContainer();
    DeleteArchimateElementCommand cmd = new DeleteArchimateElementCommand(element);
    cmd.execute();
    assertNull(element.eContainer());
    assertFalse(parent.getElements().contains(element));
    cmd.undo();
    assertEquals(0, parent.getElements().indexOf(element));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IFolder(com.archimatetool.model.IFolder) Test(org.junit.Test)

Example 28 with IArchimateElement

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

the class PropertiesLabelProviderTests method testGetTextElement.

@Test
public void testGetTextElement() {
    // Text for element
    IArchimateElement element = IArchimateFactory.eINSTANCE.createArtifact();
    String text = provider.getText(new StructuredSelection(element));
    assertEquals("Artifact", text);
    // Text for DiagramModelArchimateObject
    IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo.setArchimateElement(element);
    text = provider.getText(new StructuredSelection(dmo));
    assertEquals("Artifact", text);
    // Text for EditPart
    EditPart editPart = new ArchimateElementEditPart();
    editPart.setModel(dmo);
    text = provider.getText(new StructuredSelection(editPart));
    assertEquals("Artifact", text);
}
Also used : 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) ArchimateElementEditPart(com.archimatetool.editor.diagram.editparts.ArchimateElementEditPart) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 29 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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 30 with IArchimateElement

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

the class PropertiesLabelProviderTests method testGetImageElement.

@Test
public void testGetImageElement() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createArtifact();
    // Image for element
    Image image1 = provider.getImage(new StructuredSelection(element));
    assertNotNull(image1);
    // Image for DiagramModelArchimateObject
    IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo.setArchimateElement(element);
    Image image2 = provider.getImage(new StructuredSelection(dmo));
    assertSame(image1, image2);
    // Image for EditPart
    EditPart editPart = new ArchimateElementEditPart();
    editPart.setModel(dmo);
    Image image3 = provider.getImage(new StructuredSelection(editPart));
    assertSame(image1, image3);
}
Also used : 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) ArchimateElementEditPart(com.archimatetool.editor.diagram.editparts.ArchimateElementEditPart) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Image(org.eclipse.swt.graphics.Image) Test(org.junit.Test)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3