use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class DiagramModelUtilsNestedRelationsTests method testIsNestedConnectionTypeRelationship.
// =================================================================================================
@Test
public void testIsNestedConnectionTypeRelationship() {
// Should be all relations
for (EClass eClass : ArchimateModelUtils.getRelationsClasses()) {
IArchimateRelationship rel = (IArchimateRelationship) IArchimateFactory.eINSTANCE.create(eClass);
assertTrue(DiagramModelUtils.isNestedConnectionTypeRelationship(rel));
}
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class DiagramModelUtilsTests method findDiagramModelConnectionsForRelation.
@Test
public void findDiagramModelConnectionsForRelation() {
IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
// Should not be found
List<IDiagramModelArchimateConnection> list = DiagramModelUtils.findDiagramModelConnectionsForRelation(diagramModel, relationship);
assertTrue(list.isEmpty());
// Create various IDiagramModelArchimateObject objects
createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel);
// And make some connections using the relationship
createDataForDiagramModelConnections(relationship);
// Should be found in a dm
list = DiagramModelUtils.findDiagramModelConnectionsForRelation(diagramModel, relationship);
assertEquals(3, list.size());
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ModelCheckerTests method checkRelationsHaveElements.
@Test
public void checkRelationsHaveElements() {
IArchimateElement src = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
IArchimateElement tgt = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
IArchimateRelationship relation = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getAssociationRelationship());
relation.setSource(src);
relation.setTarget(tgt);
List<String> messages = modelChecker.checkRelationsHaveElements();
assertEquals(0, messages.size());
relation.setSource(null);
relation.setTarget(null);
messages = modelChecker.checkRelationsHaveElements();
assertEquals(2, messages.size());
assertTrue(messages.get(0).startsWith("Relationship has missing referenced source element"));
assertTrue(messages.get(1).startsWith("Relationship has missing referenced target element"));
relation.setSource(src);
relation.setTarget(tgt);
model.getFolder(FolderType.BUSINESS).getElements().remove(src);
model.getFolder(FolderType.BUSINESS).getElements().remove(tgt);
messages = modelChecker.checkRelationsHaveElements();
assertEquals(2, messages.size());
assertTrue(messages.get(0).startsWith("Relationship has orphaned source element"));
assertTrue(messages.get(1).startsWith("Relationship has orphaned target element"));
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CommandsTests method testDeleteArchimateRelationshipCommand.
@Test
public void testDeleteArchimateRelationshipCommand() {
IArchimateRelationship relationship = (IArchimateRelationship) tm.getObjectByID("670aa5ed");
assertNotNull(relationship);
assertTrue(relationship.getSource().getSourceRelationships().contains(relationship));
assertTrue(relationship.getTarget().getTargetRelationships().contains(relationship));
IFolder parent = (IFolder) relationship.eContainer();
DeleteArchimateRelationshipCommand cmd = new DeleteArchimateRelationshipCommand(relationship);
cmd.execute();
assertNull(relationship.eContainer());
assertFalse(parent.getElements().contains(relationship));
assertFalse(relationship.getSource().getSourceRelationships().contains(relationship));
assertFalse(relationship.getTarget().getTargetRelationships().contains(relationship));
cmd.undo();
assertEquals(11, parent.getElements().indexOf(relationship));
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class PropertiesLabelProviderTests method testGetImageRelation.
@Test
public void testGetImageRelation() {
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
// Image for relation
Image image1 = provider.getImage(new StructuredSelection(relation));
assertNotNull(image1);
// Image for DiagramModelArchimateConnection
IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
connection.setArchimateRelationship(relation);
Image image2 = provider.getImage(new StructuredSelection(connection));
assertSame(image1, image2);
// Image for EditPart
EditPart editPart = new ArchimateRelationshipEditPart(AssignmentConnectionFigure.class);
editPart.setModel(connection);
Image image3 = provider.getImage(new StructuredSelection(editPart));
assertSame(image1, image3);
}
Aggregations