Search in sources :

Example 21 with IDiagramModelArchimateObject

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

the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_DiagramModelConnection.

@Test
public void testIsValidConnection_DiagramModelConnection() {
    EClass relationshipType = IArchimatePackage.eINSTANCE.getDiagramModelConnection();
    IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
    IDiagramModelNote note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelArchimateObject dmao2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    IDiagramModelReference dmRef = IArchimateFactory.eINSTANCE.createDiagramModelReference();
    // Source == Target
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(group, group, relationshipType));
    // Both ArchiMate types
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, relationshipType));
    // Target ArchiMate type
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(group, dmao2, relationshipType));
    // Target ArchiMate type
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(dmRef, dmao2, relationshipType));
    // Source ArchiMate type to Note
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, note, relationshipType));
    // OK
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(note, group, relationshipType));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote) Test(org.junit.Test)

Example 22 with IDiagramModelArchimateObject

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

the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_ArchimateDiagramModelConnection_To_Another.

@Test
public void testIsValidConnection_ArchimateDiagramModelConnection_To_Another() {
    EClass relationshipType = IArchimatePackage.eINSTANCE.getAssociationRelationship();
    IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmao1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
    IDiagramModelArchimateConnection conn1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    conn1.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
    IDiagramModelArchimateConnection conn2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    conn2.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
    // OK from object to connection
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, conn1, relationshipType));
    // OK from connection to object
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(conn1, dmao1, relationshipType));
    // OK if relationshipType is null (magic connector)
    assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, conn1, null));
    // Not OK from Conn -> Conn
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(conn1, conn2, relationshipType));
    assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(conn2, conn1, relationshipType));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 23 with IDiagramModelArchimateObject

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

the class FormatPainterInfoTests method testIsFat.

@Test
public void testIsFat() {
    assertFalse(info.isFat());
    IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    info.updatePaintFormat(sourceComponent);
    assertTrue(info.isFat());
}
Also used : IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 24 with IDiagramModelArchimateObject

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

the class FormatPainterInfoTests method testReset.

@Test
public void testReset() {
    PaintFormat pf = info.getPaintFormat();
    assertNull(pf);
    IDiagramModelArchimateObject sourceComponent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    info.updatePaintFormat(sourceComponent);
    pf = info.getPaintFormat();
    assertNotNull(pf);
    info.reset();
    pf = info.getPaintFormat();
    assertNull(pf);
}
Also used : PaintFormat(com.archimatetool.editor.diagram.tools.FormatPainterInfo.PaintFormat) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 25 with IDiagramModelArchimateObject

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

the class FormatPainterToolTests method isPaintableObject.

@Test
public void isPaintableObject() {
    FormatPainterTool tool = new FormatPainterTool();
    assertTrue(tool.isPaintableObject(IArchimateFactory.eINSTANCE.createDiagramModelConnection()));
    assertTrue(tool.isPaintableObject(IArchimateFactory.eINSTANCE.createDiagramModelNote()));
    assertTrue(tool.isPaintableObject(IArchimateFactory.eINSTANCE.createDiagramModelGroup()));
    assertFalse(tool.isPaintableObject(IArchimateFactory.eINSTANCE.createDiagramModelImage()));
    IDiagramModelArchimateObject dmao = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
    assertTrue(tool.isPaintableObject(dmao));
    dmao = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createJunction());
    assertFalse(tool.isPaintableObject(dmao));
}
Also used : 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