use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DeleteCommandHandlerTests method testDelete_DiagramModel_Deleted_Diagram_Reference.
@Test
public void testDelete_DiagramModel_Deleted_Diagram_Reference() {
IDiagramModel dm2 = model.getDiagramModels().get(1);
// Reference to dm2 in dm1
IDiagramModelReference dmRef = (IDiagramModelReference) ArchimateModelUtils.getObjectByID(model, "99a52921");
assertNotNull(dmRef);
// Zap
DeleteCommandHandler commandHandler = new DeleteCommandHandler(treeModelViewer, new Object[] { dm2 });
commandHandler.delete();
// All gone
assertNull(ArchimateModelUtils.getObjectByID(model, dm2.getId()));
assertNull(ArchimateModelUtils.getObjectByID(model, dmRef.getId()));
}
use of com.archimatetool.model.IDiagramModel 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.IDiagramModel in project archi by archimatetool.
the class DiagramModelUtilsTests method findReferencedDiagramsForArchimateConcept.
private void findReferencedDiagramsForArchimateConcept(String[][] data) {
IArchimateElement element = (IArchimateElement) tm.getObjectByID(data[0][0]);
assertNotNull(element);
List<IDiagramModel> list = DiagramModelUtils.findReferencedDiagramsForArchimateConcept(element);
assertEquals(data[1].length, list.size());
for (int i = 0; i < data[1].length; i++) {
String id = data[1][i];
assertEquals(id, list.get(i).getId());
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramModelUtilsTests method findDiagramModelObjectsForElement.
@Test
public void findDiagramModelObjectsForElement() {
IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
// Should not be found
List<IDiagramModelArchimateObject> list = DiagramModelUtils.findDiagramModelObjectsForElement(diagramModel, element);
assertTrue(list.isEmpty());
// Add the element to various IDiagramModelArchimateObject objects
createDataForDiagramModelArchimateObjects(element, diagramModel);
// Should be found in a dm
list = DiagramModelUtils.findDiagramModelObjectsForElement(diagramModel, element);
assertEquals(4, list.size());
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramModelUtilsTests method findReferencedDiagramsForArchimateConcept.
@Test
public void findReferencedDiagramsForArchimateConcept() {
IArchimateElement element = null;
// Null element should at least return an empty list
List<IDiagramModel> list = DiagramModelUtils.findReferencedDiagramsForArchimateConcept(element);
assertNotNull(list);
assertEquals(0, list.size());
findReferencedDiagramsForArchimateConcept(data1);
findReferencedDiagramsForArchimateConcept(data2);
}
Aggregations