Search in sources :

Example 16 with IDiagramModelArchimateObject

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

the class ModelCheckerTests method checkDiagramObjectsReferences_Connection.

@Test
public void checkDiagramObjectsReferences_Connection() {
    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.checkDiagramObjectsReferences();
    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.checkDiagramObjectsReferences();
    assertEquals(5, messages.size());
    assertTrue(messages.get(0).startsWith("Diagram Element has orphaned ArchiMate element in 'dm'"));
    assertTrue(messages.get(1).startsWith("Diagram Connection has orphaned ArchiMate relation in 'dm'"));
    assertTrue(messages.get(2).startsWith("Diagram Connection has orphaned ArchiMate source element in 'dm'"));
    assertTrue(messages.get(3).startsWith("Diagram Connection has orphaned ArchiMate target element in 'dm'"));
    assertTrue(messages.get(4).startsWith("Diagram Element has orphaned ArchiMate 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 17 with IDiagramModelArchimateObject

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

the class FixDefaultSizesHandlerTests method testGetDefaultSize_ArchimateElement.

@Test
public void testGetDefaultSize_ArchimateElement() {
    IDiagramModelArchimateObject dmo = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    dmo.setBounds(0, 0, -1, -1);
    assertEquals(new Dimension(120, 55), handler.getDefaultSize(dmo));
    dmo.setBounds(0, 0, 23, 23);
    assertEquals(new Dimension(23, 23), handler.getDefaultSize(dmo));
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Dimension(org.eclipse.draw2d.geometry.Dimension) Test(org.junit.Test)

Example 18 with IDiagramModelArchimateObject

use of com.archimatetool.model.IDiagramModelArchimateObject 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 19 with IDiagramModelArchimateObject

use of com.archimatetool.model.IDiagramModelArchimateObject 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)

Example 20 with IDiagramModelArchimateObject

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

the class ArchimateDiagramConnectionPolicyTests method testIsValidConnectionSource.

@Test
public void testIsValidConnectionSource() {
    IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    for (EClass eClass : ArchimateModelUtils.getRelationsClasses()) {
        assertTrue(ArchimateDiagramConnectionPolicy.isValidConnectionSource(dmo, eClass));
    }
    // Bogus one
    dmo.setArchimateElement(IArchimateFactory.eINSTANCE.createJunction());
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnectionSource(dmo, IArchimatePackage.eINSTANCE.getSpecializationRelationship()));
    // OK if relationshipType is null (magic connector)
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnectionSource(dmo, null));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Aggregations

IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)64 Test (org.junit.Test)34 IArchimateElement (com.archimatetool.model.IArchimateElement)28 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)19 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)14 ArrayList (java.util.ArrayList)13 IDiagramModel (com.archimatetool.model.IDiagramModel)10 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IArchimateModel (com.archimatetool.model.IArchimateModel)8 EClass (org.eclipse.emf.ecore.EClass)7 Command (org.eclipse.gef.commands.Command)7 IIssue (com.archimatetool.hammer.validation.issues.IIssue)6 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)6 EObject (org.eclipse.emf.ecore.EObject)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)4 Dimension (org.eclipse.draw2d.geometry.Dimension)4