use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ArchimateModelTests method testIDAddedToElement.
@Test
public void testIDAddedToElement() {
IArchimateElement element = IArchimateFactory.eINSTANCE.createApplicationService();
assertNull(element.getId());
model.getDefaultFolderForObject(element).getElements().add(element);
String id = element.getId();
assertNotNull(id);
assertEquals(36, id.length());
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class DiagramModelExtraTests method testDiagramModelArchimateConnection_eInverseAdd_Relationship_getReferencingDiagramObjects.
/**
* See {@link DiagramModelArchimateConnection#eInverseAdd(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
* See {@link DiagramModelArchimateConnection#eInverseRemove(org.eclipse.emf.ecore.InternalEObject, int, Class, org.eclipse.emf.common.notify.NotificationChain)}
*/
@Test
public void testDiagramModelArchimateConnection_eInverseAdd_Relationship_getReferencingDiagramObjects() {
IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateElement element3 = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateElement element4 = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
IArchimateRelationship relation3 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
relation1.setSource(element1);
relation1.setTarget(element2);
relation2.setSource(element2);
relation2.setTarget(element3);
relation3.setSource(element3);
relation3.setTarget(element4);
IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
IDiagramModelArchimateObject dmo4 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo1.setArchimateElement(element1);
dmo2.setArchimateElement(element2);
dmo3.setArchimateElement(element3);
dmo4.setArchimateElement(element4);
IDiagramModelArchimateConnection conn1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
IDiagramModelArchimateConnection conn2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
IDiagramModelArchimateConnection conn3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
// conn3a shares a relationship with conn3
IDiagramModelArchimateConnection conn3a = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
conn1.setArchimateRelationship(relation1);
conn2.setArchimateRelationship(relation2);
conn3.setArchimateRelationship(relation3);
// same
conn3a.setArchimateRelationship(relation3);
// Set up model and diagram model
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
model.setDefaults();
IDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
model.getDefaultFolderForObject(dm).getElements().add(dm);
// Add some parents
IDiagramModelGroup parent1 = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
dm.getChildren().add(parent1);
IDiagramModelArchimateObject parent2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
parent1.getChildren().add(parent2);
// Add the dmos
dm.getChildren().add(dmo1);
parent1.getChildren().add(dmo2);
parent2.getChildren().add(dmo3);
dm.getChildren().add(dmo4);
// Starts at sizes
assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
// Connect
conn1.connect(dmo1, dmo2);
assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
conn2.connect(dmo2, dmo3);
assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
conn3.connect(dmo3, dmo4);
assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
conn3a.connect(dmo3, dmo4);
assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
// Remove diagram model, should be the same
((IFolder) dm.eContainer()).getElements().remove(dm);
assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
// Add diagram model back again
model.getDefaultFolderForObject(dm).getElements().add(dm);
assertEquals(1, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(1, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(2, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
// Disconnect
conn1.disconnect();
conn2.disconnect();
conn3.disconnect();
conn3a.disconnect();
assertEquals(0, conn1.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(0, conn2.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(0, conn3.getArchimateRelationship().getReferencingDiagramConnections().size());
assertEquals(0, conn3a.getArchimateRelationship().getReferencingDiagramConnections().size());
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ArchimateModelUtilsTests method testGetAllRelationshipsForConcept.
@Test
public void testGetAllRelationshipsForConcept() {
IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
relation1.setSource(element1);
relation1.setTarget(element2);
assertEquals(1, ArchimateModelUtils.getAllRelationshipsForConcept(element1).size());
assertEquals(1, ArchimateModelUtils.getAllRelationshipsForConcept(element2).size());
IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship();
relation2.setSource(element1);
relation2.setTarget(element2);
assertEquals(2, ArchimateModelUtils.getAllRelationshipsForConcept(element1).size());
assertEquals(2, ArchimateModelUtils.getAllRelationshipsForConcept(element2).size());
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetSource_Element.
@Test
public void testGetSource_Element() {
IArchimateElement inputElement = (IArchimateElement) tm.getObjectByID("521");
Object source = provider.getSource(inputElement);
assertNull(source);
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetElements_Element.
@Test
public void testGetElements_Element() {
IArchimateElement inputElement = (IArchimateElement) tm.getObjectByID("521");
Object[] elements = provider.getElements(inputElement);
assertEquals(17, elements.length);
for (Object object : elements) {
assertTrue(object instanceof IArchimateRelationship);
}
}
Aggregations