use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ModelCheckerTests method checkDiagramObjectsReferences_Connection.
@Test
public void checkDiagramObjectsReferences_Connection() {
model.getDefaultDiagramModel().setName("dm");
IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor();
IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor);
model.getDefaultDiagramModel().getChildren().add(dmo1);
IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole();
IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role);
model.getDefaultDiagramModel().getChildren().add(dmo2);
IAssignmentRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(actor);
relation.setTarget(role);
IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation);
dmc1.connect(dmo1, dmo2);
List<String> messages = modelChecker.checkDiagramObjectsReferences();
assertEquals(0, messages.size());
model.getFolder(FolderType.RELATIONS).getElements().remove(relation);
model.getFolder(FolderType.BUSINESS).getElements().remove(actor);
model.getFolder(FolderType.BUSINESS).getElements().remove(role);
messages = modelChecker.checkDiagramObjectsReferences();
assertEquals(5, messages.size());
assertTrue(messages.get(0).startsWith("Diagram Element has orphaned ArchiMate element in 'dm'"));
assertTrue(messages.get(1).startsWith("Diagram Connection has orphaned ArchiMate relation in 'dm'"));
assertTrue(messages.get(2).startsWith("Diagram Connection has orphaned ArchiMate source element in 'dm'"));
assertTrue(messages.get(3).startsWith("Diagram Connection has orphaned ArchiMate target element in 'dm'"));
assertTrue(messages.get(4).startsWith("Diagram Element has orphaned ArchiMate element in 'dm'"));
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class FixDefaultSizesHandlerTests method testGetDefaultSize_ArchimateElement.
@Test
public void testGetDefaultSize_ArchimateElement() {
IDiagramModelArchimateObject dmo = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
dmo.setBounds(0, 0, -1, -1);
assertEquals(new Dimension(120, 55), handler.getDefaultSize(dmo));
dmo.setBounds(0, 0, 23, 23);
assertEquals(new Dimension(23, 23), handler.getDefaultSize(dmo));
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class PropertiesLabelProviderTests method testGetTextElement.
@Test
public void testGetTextElement() {
// Text for element
IArchimateElement element = IArchimateFactory.eINSTANCE.createArtifact();
String text = provider.getText(new StructuredSelection(element));
assertEquals("Artifact", text);
// Text for DiagramModelArchimateObject
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setArchimateElement(element);
text = provider.getText(new StructuredSelection(dmo));
assertEquals("Artifact", text);
// Text for EditPart
EditPart editPart = new ArchimateElementEditPart();
editPart.setModel(dmo);
text = provider.getText(new StructuredSelection(editPart));
assertEquals("Artifact", text);
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class PropertiesLabelProviderTests method testGetImageElement.
@Test
public void testGetImageElement() {
IArchimateElement element = IArchimateFactory.eINSTANCE.createArtifact();
// Image for element
Image image1 = provider.getImage(new StructuredSelection(element));
assertNotNull(image1);
// Image for DiagramModelArchimateObject
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setArchimateElement(element);
Image image2 = provider.getImage(new StructuredSelection(dmo));
assertSame(image1, image2);
// Image for EditPart
EditPart editPart = new ArchimateElementEditPart();
editPart.setModel(dmo);
Image image3 = provider.getImage(new StructuredSelection(editPart));
assertSame(image1, image3);
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ArchimateDiagramConnectionPolicyTests method testIsValidConnectionSource.
@Test
public void testIsValidConnectionSource() {
IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
for (EClass eClass : ArchimateModelUtils.getRelationsClasses()) {
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnectionSource(dmo, eClass));
}
// Bogus one
dmo.setArchimateElement(IArchimateFactory.eINSTANCE.createJunction());
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnectionSource(dmo, IArchimatePackage.eINSTANCE.getSpecializationRelationship()));
// OK if relationshipType is null (magic connector)
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnectionSource(dmo, null));
}
Aggregations