use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ArchimateDiagramModelFactoryTests method testGetNewObjectArchimateConnection.
@Test
public void testGetNewObjectArchimateConnection() {
IPreferenceStore store = ArchiPlugin.PREFERENCES;
store.setValue(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR, true);
store.setValue(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR, "#ababab");
ICreationFactory factory = new ArchimateDiagramModelFactory(IArchimatePackage.eINSTANCE.getAssignmentRelationship());
IDiagramModelArchimateConnection connection = (IDiagramModelArchimateConnection) factory.getNewObject();
assertTrue(connection.getArchimateRelationship() instanceof IAssignmentRelationship);
assertEquals("#ababab", connection.getLineColor());
assertEquals("", connection.getName());
store.setToDefault(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR);
store.setToDefault(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR);
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_ArchimateDiagramModelConnection_To_Another.
@Test
public void testIsValidConnection_ArchimateDiagramModelConnection_To_Another() {
EClass relationshipType = IArchimatePackage.eINSTANCE.getAssociationRelationship();
IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmao1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
IDiagramModelArchimateConnection conn1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
conn1.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
IDiagramModelArchimateConnection conn2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
conn2.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
// OK from object to connection
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, conn1, relationshipType));
// OK from connection to object
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(conn1, dmao1, relationshipType));
// OK if relationshipType is null (magic connector)
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, conn1, null));
// Not OK from Conn -> Conn
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(conn1, conn2, relationshipType));
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(conn2, conn1, relationshipType));
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class DiagramModelUtilsNestedRelationsTests method testShouldBeHiddenConnection.
@Test
public void testShouldBeHiddenConnection() {
IDiagramModelArchimateConnection connection = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
connection.setArchimateRelationship(relationship1);
connection.connect(dmo1, dmo2);
assertTrue(DiagramModelUtils.shouldBeHiddenConnection(connection));
// swap
connection.connect(dmo2, dmo1);
assertTrue(DiagramModelUtils.shouldBeHiddenConnection(connection));
// Set prefs to say no
ArchiPlugin.PREFERENCES.setValue(IPreferenceConstants.USE_NESTED_CONNECTIONS, false);
connection.connect(dmo3, dmo4);
assertFalse(DiagramModelUtils.shouldBeHiddenConnection(connection));
// Set prefs to say yes
ArchiPlugin.PREFERENCES.setValue(IPreferenceConstants.USE_NESTED_CONNECTIONS, true);
assertTrue(DiagramModelUtils.shouldBeHiddenConnection(connection));
// Another one to be sure - association
connection.setArchimateRelationship(relationship2);
connection.connect(dmo4, dmo5);
assertTrue(DiagramModelUtils.shouldBeHiddenConnection(connection));
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class DiagramModelArchimateConnectionTests method testGetCopy.
@Override
@Test
public void testGetCopy() {
super.testGetCopy();
connection.setName("name");
IDiagramModelArchimateConnection copy = (IDiagramModelArchimateConnection) connection.getCopy();
assertNotSame(copy, connection);
assertEquals("name", connection.getName());
assertNotNull(copy.getArchimateRelationship());
assertNotSame(copy.getArchimateRelationship(), connection.getArchimateRelationship());
assertNull(copy.getArchimateRelationship().getSource());
assertNull(copy.getArchimateRelationship().getTarget());
}
use of com.archimatetool.model.IDiagramModelArchimateConnection in project archi by archimatetool.
the class ViewpointManagerTests method testIsAllowedDiagramModelComponent.
@Test
public void testIsAllowedDiagramModelComponent() {
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
dm.setViewpoint("organization");
IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
dm.getChildren().add(dmo1);
assertTrue(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(dmo1));
IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createNode());
dm.getChildren().add(dmo2);
assertFalse(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(dmo2));
IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
conn.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
conn.connect(dmo1, dmo2);
assertFalse(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(conn));
IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo3.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessRole());
dm.getChildren().add(dmo3);
conn.connect(dmo1, dmo3);
assertTrue(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(conn));
}
Aggregations