use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ModelCheckerTests method checkRelationsHaveElements.
@Test
public void checkRelationsHaveElements() {
IArchimateElement src = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
IArchimateElement tgt = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
IArchimateRelationship relation = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getAssociationRelationship());
relation.setSource(src);
relation.setTarget(tgt);
List<String> messages = modelChecker.checkRelationsHaveElements();
assertEquals(0, messages.size());
relation.setSource(null);
relation.setTarget(null);
messages = modelChecker.checkRelationsHaveElements();
assertEquals(2, messages.size());
assertTrue(messages.get(0).startsWith("Relationship has missing referenced source element"));
assertTrue(messages.get(1).startsWith("Relationship has missing referenced target element"));
relation.setSource(src);
relation.setTarget(tgt);
model.getFolder(FolderType.BUSINESS).getElements().remove(src);
model.getFolder(FolderType.BUSINESS).getElements().remove(tgt);
messages = modelChecker.checkRelationsHaveElements();
assertEquals(2, messages.size());
assertTrue(messages.get(0).startsWith("Relationship has orphaned source element"));
assertTrue(messages.get(1).startsWith("Relationship has orphaned target element"));
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class CommandsTests method testDeleteArchimateElementCommand.
@Test
public void testDeleteArchimateElementCommand() {
IArchimateElement element = (IArchimateElement) tm.getObjectByID("1544");
assertNotNull(element);
IFolder parent = (IFolder) element.eContainer();
DeleteArchimateElementCommand cmd = new DeleteArchimateElementCommand(element);
cmd.execute();
assertNull(element.eContainer());
assertFalse(parent.getElements().contains(element));
cmd.undo();
assertEquals(0, parent.getElements().indexOf(element));
}
use of com.archimatetool.model.IArchimateElement 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.IArchimateElement in project archi by archimatetool.
the class PropertiesLabelProviderTests method testGetArchimateConceptText.
@Test
public void testGetArchimateConceptText() {
// Type of element
IArchimateElement element = IArchimateFactory.eINSTANCE.createArtifact();
assertEquals("Artifact", provider.getArchimateConceptText(element));
// Type of relation
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
assertEquals("Assignment relation", provider.getArchimateConceptText(relation));
// Name + type
relation.setName("Hello");
assertEquals("Hello (Assignment relation)", provider.getArchimateConceptText(relation));
// Null is OK
relation.setName(null);
assertEquals("Assignment relation", provider.getArchimateConceptText(relation));
}
use of com.archimatetool.model.IArchimateElement 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);
}
Aggregations