Search in sources :

Example 6 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.

the class RelationshipsMatrixTests method testIsValidRelationshipStart_Element.

@Test
public void testIsValidRelationshipStart_Element() {
    IArchimateElement sourceElement = IArchimateFactory.eINSTANCE.createJunction();
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createFlowRelationship();
    assertTrue(matrix.isValidRelationshipStart(sourceElement.eClass(), relationship.eClass()));
    relationship = IArchimateFactory.eINSTANCE.createTriggeringRelationship();
    assertTrue(matrix.isValidRelationshipStart(sourceElement.eClass(), relationship.eClass()));
    relationship = IArchimateFactory.eINSTANCE.createSpecializationRelationship();
    assertFalse(matrix.isValidRelationshipStart(sourceElement.eClass(), relationship.eClass()));
    sourceElement = IArchimateFactory.eINSTANCE.createSystemSoftware();
    relationship = IArchimateFactory.eINSTANCE.createFlowRelationship();
    assertTrue(matrix.isValidRelationshipStart(sourceElement.eClass(), relationship.eClass()));
    relationship = IArchimateFactory.eINSTANCE.createAccessRelationship();
    assertTrue(matrix.isValidRelationshipStart(sourceElement.eClass(), relationship.eClass()));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 7 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.

the class FieldDataFactoryTests method testGetFieldValue_RelationTarget.

@Test
public void testGetFieldValue_RelationTarget() {
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createServingRelationship();
    IArtifact target = IArchimateFactory.eINSTANCE.createArtifact();
    target.setName("target");
    relation.setTarget(target);
    Object o = FieldDataFactory.getFieldValue(relation, "relation_target");
    assertEquals("target", o);
}
Also used : IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IArtifact(com.archimatetool.model.IArtifact) Test(org.junit.Test)

Example 8 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.

the class ArchimateRelationshipTests method testGetCopy_SourceAndTargetComponentsAreNull.

@Test
public void testGetCopy_SourceAndTargetComponentsAreNull() {
    relationship.connect(sourceElement, targetElement);
    IArchimateRelationship copy = (IArchimateRelationship) relationship.getCopy();
    assertNull(copy.getSource());
    assertNull(copy.getTarget());
}
Also used : IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 9 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.

the class JunctionsCheckerTests method testGetIssues.

@Test
public void testGetIssues() {
    List<IArchimateElement> elements = new ArrayList<IArchimateElement>();
    IArchimateElement e1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    elements.add(e1);
    IArchimateElement junction = IArchimateFactory.eINSTANCE.createJunction();
    elements.add(junction);
    IArchimateElement e2 = IArchimateFactory.eINSTANCE.createBusinessActor();
    elements.add(e2);
    IArchimateRelationship rel1 = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    rel1.connect(e1, junction);
    IArchimateRelationship rel2 = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    rel2.connect(junction, e2);
    JunctionsChecker checker = new JunctionsChecker(elements);
    // Should be OK
    List<IIssue> issues = checker.getIssues();
    assertEquals(0, issues.size());
    // Add a different relationship
    IArchimateRelationship rel3 = IArchimateFactory.eINSTANCE.createTriggeringRelationship();
    rel3.connect(junction, e2);
    issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertSame(junction, issues.get(0).getObject());
}
Also used : ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IIssue(com.archimatetool.hammer.validation.issues.IIssue) Test(org.junit.Test)

Example 10 with IArchimateRelationship

use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.

the class NestedElementsCheckerTests method testGetIssues.

@Test
public void testGetIssues() {
    List<IArchimateDiagramModel> views = new ArrayList<IArchimateDiagramModel>();
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    dm.setName("view");
    views.add(dm);
    IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createGrouping());
    dm.getChildren().add(dmo1);
    IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
    dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createLocation());
    dmo1.getChildren().add(dmo2);
    NestedElementsChecker checker = new NestedElementsChecker(views);
    // Should not be ok
    List<IIssue> issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertSame(dmo2, issues.get(0).getObject());
    // With this relationship should also not be OK
    IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
    IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    relation.connect(dmo1.getArchimateElement(), dmo2.getArchimateElement());
    conn.setArchimateRelationship(relation);
    conn.connect(dmo1, dmo2);
    issues = checker.getIssues();
    assertEquals(1, issues.size());
    assertSame(dmo2, issues.get(0).getObject());
    // With a valid relationship should be OK
    relation = IArchimateFactory.eINSTANCE.createCompositionRelationship();
    relation.connect(dmo1.getArchimateElement(), dmo2.getArchimateElement());
    conn.setArchimateRelationship(relation);
    issues = checker.getIssues();
    assertEquals(0, issues.size());
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) ArrayList(java.util.ArrayList) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) 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