use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ModelCheckerTests method checkDiagramModelArchimateConnection.
@Test
public void checkDiagramModelArchimateConnection() {
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.checkDiagramModelArchimateConnection(dmc1);
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.checkDiagramModelArchimateConnection(dmc1);
assertEquals(3, messages.size());
assertTrue(messages.get(0).startsWith("Diagram Connection has orphaned ArchiMate relation in 'dm'"));
assertTrue(messages.get(1).startsWith("Diagram Connection has orphaned ArchiMate source element in 'dm'"));
assertTrue(messages.get(2).startsWith("Diagram Connection has orphaned ArchiMate target element in 'dm'"));
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class FormatPainterToolTests method testCreateCommandForDiagramModelArchimateConnection.
@Test
public void testCreateCommandForDiagramModelArchimateConnection() throws Exception {
// Source component
IDiagramModelArchimateConnection sourceComponent = ArchimateTestModel.createDiagramModelArchimateConnection(IArchimateFactory.eINSTANCE.createAccessRelationship());
// Target component
IDiagramModelArchimateConnection targetComponent = ArchimateTestModel.createDiagramModelArchimateConnection(IArchimateFactory.eINSTANCE.createAccessRelationship());
// Set FormatPainterInfo to Source component
FormatPainterInfo.INSTANCE.updatePaintFormat(sourceComponent);
PaintFormat pf = FormatPainterInfo.INSTANCE.getPaintFormat();
// Execute command
FormatPainterTool tool = new FormatPainterTool();
CompoundCommand compoundCmd = tool.createCommand(pf, targetComponent);
// Should be no commands
assertEquals(0, compoundCmd.getCommands().size());
// Now change some properties on the source component
sourceComponent.setFont("Consolas");
sourceComponent.setFontColor("#eeeeee");
sourceComponent.setLineColor("#eeeeee");
sourceComponent.setLineWidth(3);
sourceComponent.setTextPosition(3);
compoundCmd = tool.createCommand(pf, targetComponent);
assertEquals(5, compoundCmd.getCommands().size());
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class CopySnapshotTests method testNestedConnectionIsCopied.
@Test
public void testNestedConnectionIsCopied() throws IOException {
loadTestModel1();
// Create parent object
IDiagramModelArchimateObject dmoParent = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessActor());
dmoParent.setBounds(0, 0, 200, 200);
sourceDiagramModel.getChildren().add(dmoParent);
// Create child object
IDiagramModelArchimateObject dmoChild = ArchimateTestModel.createDiagramModelArchimateObject(IArchimateFactory.eINSTANCE.createBusinessRole());
dmoChild.setBounds(0, 0, 100, 100);
dmoParent.getChildren().add(dmoChild);
// Create relationship
IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relationship.setSource(dmoParent.getArchimateElement());
relationship.setTarget(dmoChild.getArchimateElement());
// Test that an explicit connection is copied
// Create connection
IDiagramModelArchimateConnection connection = ArchimateTestModel.createDiagramModelArchimateConnection(relationship);
connection.connect(dmoParent, dmoChild);
List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
selected.add(dmoParent);
CopySnapshot snapshot = new CopySnapshot(selected);
Command cmd = snapshot.getPasteCommand(targetDiagramModel, null, null, false);
assertNotNull(cmd);
cmd.execute();
assertEquals(1, countAllConnections(targetDiagramModel));
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class PropertiesLabelProviderTests method testGetTextRelation.
@Test
public void testGetTextRelation() {
// Text for relation
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship();
relation.setSource(IArchimateFactory.eINSTANCE.createBusinessActor());
relation.setTarget(IArchimateFactory.eINSTANCE.createBusinessRole());
relation.getSource().setName("BA1");
relation.getTarget().setName("BR1");
String expectedText = "Assignment relation (BA1 - BR1)";
String text = provider.getText(new StructuredSelection(relation));
assertEquals(expectedText, text);
text = provider.getText(new StructuredSelection(relation));
assertEquals(expectedText, text);
// Text for DiagramModelArchimateConnection
IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
connection.setArchimateRelationship(relation);
text = provider.getText(new StructuredSelection(relation));
assertEquals(expectedText, text);
// Text for EditPart
EditPart editPart = new ArchimateRelationshipEditPart(AssignmentConnectionFigure.class);
editPart.setModel(connection);
text = provider.getText(new StructuredSelection(editPart));
assertEquals(expectedText, text);
}
Aggregations