Search in sources :

Example 71 with IArchimateElement

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

the class DiagramModelUtilsTests method findDiagramModelObjectsForElement.

@Test
public void findDiagramModelObjectsForElement() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateObject> list = DiagramModelUtils.findDiagramModelObjectsForElement(diagramModel, element);
    assertTrue(list.isEmpty());
    // Add the element to various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(element, diagramModel);
    // Should be found in a dm
    list = DiagramModelUtils.findDiagramModelObjectsForElement(diagramModel, element);
    assertEquals(4, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 72 with IArchimateElement

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

the class DiagramModelUtilsTests method findReferencedDiagramsForArchimateConcept.

@Test
public void findReferencedDiagramsForArchimateConcept() {
    IArchimateElement element = null;
    // Null element should at least return an empty list
    List<IDiagramModel> list = DiagramModelUtils.findReferencedDiagramsForArchimateConcept(element);
    assertNotNull(list);
    assertEquals(0, list.size());
    findReferencedDiagramsForArchimateConcept(data1);
    findReferencedDiagramsForArchimateConcept(data2);
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 73 with IArchimateElement

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

the class DiagramModelUtilsTests method testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram.

// =================================================================================================
@Test
public void testFindDiagramModelObjectsAndConnections_AfterDuplicateDiagram() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IDiagramModel dm = model.getDefaultDiagramModel();
    IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
    dm.getChildren().add(dmo1);
    IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
    IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
    dm.getChildren().add(dmo2);
    IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
    relation.setSource(actor);
    relation.setTarget(role);
    IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
    dmc1.connect(dmo1, dmo2);
    List<?> list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
    assertEquals(1, list.size());
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
    assertEquals(1, list.size());
    // Duplicate
    DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] { dm });
    handler.duplicate();
    list = DiagramModelUtils.findDiagramModelObjectsForElement(actor);
    assertEquals(2, list.size());
    list = DiagramModelUtils.findDiagramModelObjectsForElement(role);
    assertEquals(2, list.size());
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(relation);
    assertEquals(2, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IAssignmentRelationship(com.archimatetool.model.IAssignmentRelationship) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IArchimateModel(com.archimatetool.model.IArchimateModel) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) DuplicateCommandHandler(com.archimatetool.editor.views.tree.commands.DuplicateCommandHandler) Test(org.junit.Test)

Example 74 with IArchimateElement

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

the class ColorFactoryTests method testGetInbuiltDefaultFillColor.

@Test
public void testGetInbuiltDefaultFillColor() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    Color color = ColorFactory.getInbuiltDefaultFillColor(element);
    assertEquals(((IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(element)).getDefaultColor(), color);
    element = IArchimateFactory.eINSTANCE.createApplicationComponent();
    color = ColorFactory.getInbuiltDefaultFillColor(element);
    assertEquals(((IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(element)).getDefaultColor(), color);
    element = IArchimateFactory.eINSTANCE.createCommunicationNetwork();
    color = ColorFactory.getInbuiltDefaultFillColor(element);
    assertEquals(((IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(element)).getDefaultColor(), color);
}
Also used : Color(org.eclipse.swt.graphics.Color) IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 75 with IArchimateElement

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

the class DuplicateElementCheckerTests method testGetIssues.

@Test
public void testGetIssues() {
    List<IArchimateElement> elements = new ArrayList<IArchimateElement>();
    IArchimateElement e1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    e1.setName("fido1");
    elements.add(e1);
    IArchimateElement e2 = IArchimateFactory.eINSTANCE.createBusinessActor();
    e2.setName("fido2");
    elements.add(e2);
    DuplicateElementChecker checker = new DuplicateElementChecker(elements);
    // Should be OK
    List<IIssue> issues = checker.getIssues();
    assertTrue(issues.isEmpty());
    // Set name the same
    e2.setName("fido1");
    issues = checker.getIssues();
    assertEquals(2, issues.size());
    assertTrue(issues.get(0) instanceof WarningType);
    assertTrue(issues.get(1) instanceof WarningType);
    assertSame(e1, issues.get(0).getObject());
    assertSame(e2, issues.get(1).getObject());
}
Also used : ArrayList(java.util.ArrayList) WarningType(com.archimatetool.hammer.validation.issues.WarningType) IArchimateElement(com.archimatetool.model.IArchimateElement) 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