Search in sources :

Example 56 with IArchimateRelationship

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));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 57 with IArchimateRelationship

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);
}
Also used : ArchimateRelationshipEditPart(com.archimatetool.editor.diagram.editparts.ArchimateRelationshipEditPart) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArchimateRelationshipEditPart(com.archimatetool.editor.diagram.editparts.ArchimateRelationshipEditPart) ArchimateElementEditPart(com.archimatetool.editor.diagram.editparts.ArchimateElementEditPart) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) EditPart(org.eclipse.gef.EditPart) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 58 with IArchimateRelationship

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));
}
Also used : IBusinessActor(com.archimatetool.model.IBusinessActor) IBusinessRole(com.archimatetool.model.IBusinessRole) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IJunction(com.archimatetool.model.IJunction) Test(org.junit.Test)

Example 59 with IArchimateRelationship

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));
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) AccessRelationshipUIProvider(com.archimatetool.editor.ui.factory.relationships.AccessRelationshipUIProvider) Test(org.junit.Test)

Example 60 with IArchimateRelationship

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());
}
Also used : ErrorType(com.archimatetool.hammer.validation.issues.ErrorType) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IIssue(com.archimatetool.hammer.validation.issues.IIssue) Test(org.junit.Test)

Aggregations

IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)74 Test (org.junit.Test)39 IArchimateElement (com.archimatetool.model.IArchimateElement)33 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)22 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)15 ArrayList (java.util.ArrayList)15 IArchimateConcept (com.archimatetool.model.IArchimateConcept)14 IDiagramModel (com.archimatetool.model.IDiagramModel)12 IArchimateModel (com.archimatetool.model.IArchimateModel)9 EObject (org.eclipse.emf.ecore.EObject)9 IIssue (com.archimatetool.hammer.validation.issues.IIssue)7 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)7 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)5 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)5 ErrorType (com.archimatetool.hammer.validation.issues.ErrorType)4 IFolder (com.archimatetool.model.IFolder)4 EClass (org.eclipse.emf.ecore.EClass)4 Command (org.eclipse.gef.commands.Command)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3