Changeset 2430
- Timestamp:
- 10/11/08 05:06:16 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/branches/ports/gaphor/adapters/classes/tests/test_interfaceconnect.py
r2428 r2430 68 68 69 69 LINES = (items.ImplementationItem, 70 items.DependencyItem, 70 71 items.GeneralizationItem, 71 72 items.AssociationItem, … … 73 74 items.ExtendItem) 74 75 75 class FoldedInterface WithImplementationTestCase(TestCase):76 class FoldedInterfaceMultipleLinesTestCase(TestCase): 76 77 """ 77 78 Test connection of additional diagram lines to folded interface, 78 which has already implementation connected.79 which has already usage depenendency or implementation connected. 79 80 """ 80 81 def setUp(self): 81 super(FoldedInterface WithImplementationTestCase, self).setUp()82 super(FoldedInterfaceMultipleLinesTestCase, self).setUp() 82 83 83 84 self.iface = self.create(items.InterfaceItem, UML.Interface) 84 85 self.iface.folded = self.iface.FOLDED_PROVIDED 86 87 88 def test_interface_with_implementation(self): 89 """Test glueing different lines to folded interface with implementation 90 """ 85 91 impl = self.create(items.ImplementationItem) 86 87 92 self.connect(impl, impl.head, self.iface) 88 93 89 90 def test_any_line(self):91 """Test glueing different lines to folded interface with implementation92 """93 94 for cls in LINES: 94 95 line = self.create(cls) … … 98 99 99 100 100 def test_ dependency_glue(self):101 """Test glueing d ependency to folded interface with implementation101 def test_interface_with_dependency(self): 102 """Test glueing different lines to folded interface with dependency 102 103 """ 103 104 dep = self.create(items.DependencyItem) 104 glued = self.glue(dep, dep.head, self.iface)105 # dependency can be glued...106 self.assertTrue(glued)107 # ... but it cannot be usage dependency108 self.assertFalse(dep.is_usage(self.iface.subject))109 110 111 112 class FoldedInterfaceWithDependency(TestCase):113 """114 Test connection of additional diagram lines to folded interface,115 which has already dependency connected.116 """117 def setUp(self):118 super(FoldedInterfaceWithDependency, self).setUp()119 120 self.iface = self.create(items.InterfaceItem, UML.Interface)121 self.iface.folded = self.iface.FOLDED_PROVIDED122 dep = self.create(items.DependencyItem)123 124 105 self.connect(dep, dep.head, self.iface) 125 106 126 127 def test_any_line(self):128 """Test glueing different lines to folded interface with dependency129 """130 107 for cls in LINES: 131 108 line = self.create(cls) … … 135 112 136 113 137 def test_dependency_glue(self):138 """Test glueing dependency to folded interface with dependency139 """140 dep = self.create(items.DependencyItem)141 glued = self.glue(dep, dep.head, self.iface)142 # dependency can be glued...143 self.assertTrue(glued)144 # ... but it cannot be usage dependency145 self.assertFalse(dep.is_usage(self.iface.subject))146 147 148 114 149 115 # vim:sw=4:et:ai gaphor/branches/ports/gaphor/diagram/classes/interface.py
r2429 r2430 14 14 - only an implementation can be connected (ball - provided interface) 15 15 - or only usage dependency can be connected (socket - required interface) 16 - normal dependencies can be connected as well17 16 18 17 Above means that interface cannot be folded when 19 18 20 19 - both, usage dependency and implementation are connected 21 - any other lines, beside normal dependecies, are connected 22 23 For examples, see http://martinfowler.com/bliki/BallAndSocket.html. 20 - any other lines are connected 21 22 Dependencies 23 ------------ 24 Dependencies between folded interfaces are *not supported* 25 26 +---------------------+---------------------+ 27 | *Supported* | *Unsupported* | 28 +=====================+=====================+ 29 | :: | :: | 30 | | | 31 | |A|--( O--|B| | |A|--(--->O--|B| | 32 | Z Z | Z Z | 33 +---------------------+---------------------+ 34 35 A requires interface Z and B provides interface Z, Z is connected to itself 36 with dependency. 37 38 There is no need for additional dependency 39 40 - UML data model provides information, that Z is common for A and B 41 (A requires Z, B provides Z) 42 - on a diagram, both folded interface items (required and provided) 43 represent the same interface, which is easily identifiable with its 44 name 45 46 Even more, adding a dependency between folded interfaces provides 47 information (on UML data model level) that an interface depenends on itself 48 but it is not the intention of this (*unsupported*) notation. 49 50 For more examples of non-supported by Gaphor notation, see 51 http://martinfowler.com/bliki/BallAndSocket.html. 52 24 53 25 54 Folding and Connecting … … 32 61 - when interface is folded, allow only one implementation or depenedency 33 62 usage to be connected 34 - when interface is folded, allow normal dependencies to be connected as35 well36 63 37 64 Above solution is bit restrictive, for example we could allow folding when
