use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class DiagramModelUtilsTests method findDiagramModelComponentsForArchimateConcept_Relationship.
@Test
public void findDiagramModelComponentsForArchimateConcept_Relationship() {
IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
// Should not be found
List<IDiagramModelArchimateComponent> list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship);
assertTrue(list.isEmpty());
// Create various IDiagramModelArchimateObject objects
createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel);
// And make some connections using the relationship
createDataForDiagramModelConnections(relationship);
// Found in diagram
list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, relationship);
assertEquals(3, list.size());
assertTrue(list.contains(conn1));
assertTrue(list.contains(conn2));
assertTrue(list.contains(conn3));
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class PropertiesLabelProviderTests method testGetTextRelation.
@Test
public void testGetTextRelation() {
// Text for relation
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
String text = provider.getText(new StructuredSelection(relation));
assertEquals("Assignment relation", text);
// Text for DiagramModelArchimateConnection
IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
connection.setArchimateRelationship(relation);
text = provider.getText(new StructuredSelection(relation));
assertEquals("Assignment relation", text);
// Text for EditPart
EditPart editPart = new ArchimateRelationshipEditPart(AssignmentConnectionFigure.class);
editPart.setModel(connection);
text = provider.getText(new StructuredSelection(editPart));
assertEquals("Assignment relation", text);
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ArchiLabelProviderTests method testGetRelationshipSentence.
@Test
public void testGetRelationshipSentence() {
// Null object
assertEquals("", ArchiLabelProvider.INSTANCE.getRelationshipSentence(null));
IBusinessActor actor = IArchimateFactory.eINSTANCE.createBusinessActor();
actor.setName("Fred");
IBusinessRole role = IArchimateFactory.eINSTANCE.createBusinessRole();
role.setName("Nobody");
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
assertEquals("Fred is assigned to Nobody", ArchiLabelProvider.INSTANCE.getRelationshipSentence(relation));
relation.setSource(role);
relation.setTarget(actor);
assertEquals("Nobody is assigned to Fred", ArchiLabelProvider.INSTANCE.getRelationshipSentence(relation));
// Junctions
IJunction j1 = IArchimateFactory.eINSTANCE.createJunction();
j1.setName("Johnny");
relation.setSource(j1);
relation.setTarget(actor);
assertEquals("Johnny connects to Fred", ArchiLabelProvider.INSTANCE.getRelationshipSentence(relation));
relation.setSource(actor);
relation.setTarget(j1);
assertEquals("Fred connects to Johnny", ArchiLabelProvider.INSTANCE.getRelationshipSentence(relation));
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ObjectUIFactoryProviderTests method testGetProvider_EObject_DiagramModelArchimateConnection.
@Test
public void testGetProvider_EObject_DiagramModelArchimateConnection() {
IObjectUIProvider provider = new AccessRelationshipUIProvider();
factory.registerProvider(provider);
IDiagramModelArchimateConnection eObject = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAccessRelationship();
eObject.setArchimateRelationship(relation);
assertEquals(provider, factory.getProvider(eObject));
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class InvalidRelationsCheckerTests method testGetIssues.
@Test
public void testGetIssues() {
List<IArchimateRelationship> relations = new ArrayList<IArchimateRelationship>();
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setName("relation");
relation.setSource(IArchimateFactory.eINSTANCE.createBusinessActor());
relation.setTarget(IArchimateFactory.eINSTANCE.createBusinessRole());
relations.add(relation);
InvalidRelationsChecker checker = new InvalidRelationsChecker(relations);
// Should be ok
List<IIssue> issues = checker.getIssues();
assertEquals(0, issues.size());
// Now set bogus relationship
relation.setTarget(IArchimateFactory.eINSTANCE.createNode());
issues = checker.getIssues();
assertEquals(1, issues.size());
assertTrue(issues.get(0) instanceof ErrorType);
assertSame(relation, issues.get(0).getObject());
}
Aggregations