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