Search in sources :

Example 11 with IArchimateElement

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

the class ArchimateModelUtilsTests method testGetObjectByID.

@Test
public void testGetObjectByID() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    EObject element = ArchimateModelUtils.getObjectByID(model, null);
    assertNull(element);
    IArchimateElement newElement1 = IArchimateFactory.eINSTANCE.createApplicationFunction();
    model.getDefaultFolderForObject(newElement1).getElements().add(newElement1);
    IArchimateElement newElement2 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(newElement2).getElements().add(newElement2);
    element = ArchimateModelUtils.getObjectByID(model, newElement1.getId());
    assertSame(newElement1, element);
    element = ArchimateModelUtils.getObjectByID(model, newElement2.getId());
    assertSame(newElement2, element);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 12 with IArchimateElement

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

the class ArchimateModelUtilsTests method testGetAllRelationshipsForConcept_NotNull.

@Test
public void testGetAllRelationshipsForConcept_NotNull() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element1).getElements().add(element1);
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
    model.getDefaultFolderForObject(element2).getElements().add(element2);
    assertNotNull(ArchimateModelUtils.getAllRelationshipsForConcept(element1));
    assertNotNull(ArchimateModelUtils.getAllRelationshipsForConcept(element2));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 13 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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 14 with IArchimateElement

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

the class ArchimateModelDataSourceTests method testGetElementByID.

@Test
public void testGetElementByID() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createApplicationService();
    model.getDefaultFolderForObject(element).getElements().add(element);
    String id = element.getId();
    assertEquals(element, ds.getElementByID(id));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 15 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3