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()));
}
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);
}
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());
}
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());
}
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());
}
Aggregations