use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DuplicateCommandHandlerTests method testDuplicateDiagramModel_AddsConnectionsToConnections.
@Test
public void testDuplicateDiagramModel_AddsConnectionsToConnections() {
ArchimateTestModel tm = new ArchimateTestModel();
IArchimateModel model = tm.createNewModel();
IDiagramModel dm = model.getDefaultDiagramModel();
IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(element1);
dm.getChildren().add(dmo1);
IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(element2);
dm.getChildren().add(dmo2);
IArchimateElement element3 = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo3 = tm.createDiagramModelArchimateObjectAndAddToModel(element3);
dm.getChildren().add(dmo3);
IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation1.setSource(element1);
relation1.setTarget(element2);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation1);
dmc1.connect(dmo1, dmo2);
IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
relation2.setSource(element3);
relation2.setTarget(relation1);
IDiagramModelArchimateConnection dmc2 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation2);
dmc2.connect(dmo3, dmc1);
DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
handler.duplicate();
IDiagramModel dmCopy = model.getDiagramModels().get(1);
EList<IDiagramModelObject> children = dmCopy.getChildren();
assertEquals(3, children.size());
IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0);
IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1);
IDiagramModelArchimateObject dmo3Copy = (IDiagramModelArchimateObject) children.get(2);
assertSame(element1, dmo1Copy.getArchimateConcept());
assertSame(element2, dmo2Copy.getArchimateConcept());
assertSame(element3, dmo3Copy.getArchimateConcept());
IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) dmo1Copy.getSourceConnections().get(0);
assertSame(relation1, dmc1Copy.getArchimateConcept());
assertSame(dmo2Copy, dmc1Copy.getTarget());
// Connection to Connection
assertSame(dmc1Copy, dmo3Copy.getSourceConnections().get(0).getTarget());
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DiagramModelUtilsTests method hasCycle.
@Test
public void hasCycle() {
IDiagramModelObject source = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelObject target = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
;
IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
conn.connect(source, target);
assertFalse(DiagramModelUtils.hasCycle(source, target));
conn.connect(target, source);
assertTrue(DiagramModelUtils.hasCycle(source, target));
conn.disconnect();
assertFalse(DiagramModelUtils.hasCycle(source, target));
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class FixDefaultSizesHandlerTests method testGetDefaultSize.
@Test
public void testGetDefaultSize() {
IDiagramModelObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelNote();
dmo.setBounds(0, 0, -1, -1);
assertEquals(new Dimension(185, 80), handler.getDefaultSize(dmo));
dmo.setBounds(0, 0, 23, 23);
assertEquals(new Dimension(23, 23), handler.getDefaultSize(dmo));
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class FixDefaultSizesHandlerTests method testGetNewSize_ArchiMateElement.
@Test
public void testGetNewSize_ArchiMateElement() {
IDiagramModelArchimateObject parent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
parent.setBounds(0, 0, -1, -1);
IDiagramModelObject child = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
child.setBounds(300, 120, -1, -1);
parent.getChildren().add(child);
assertEquals(new Dimension(430, 185), handler.getNewSize(parent));
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class FixDefaultSizesHandlerTests method testGetNewSize_Group.
@Test
public void testGetNewSize_Group() {
IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
group.setBounds(0, 0, -1, -1);
IDiagramModelObject note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
note.setBounds(300, 114, -1, -1);
group.getChildren().add(note);
assertEquals(new Dimension(495, 204), handler.getNewSize(group));
}
Aggregations