Skip to content

Commit b4211a9

Browse files
Fixes #306
1 parent 7460200 commit b4211a9

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ subprojects { proj ->
88

99
description = 'Structurizr'
1010
group = 'com.structurizr'
11-
version = '2.1.3'
11+
version = '2.1.4'
1212

1313
repositories {
1414
mavenCentral()

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Changelog
22

3+
4+
## 2.1.4 (18th June 2024)
5+
6+
- structurizr-core: Fixes https://github.com/structurizr/java/issues/306 (Workspace.trim() is not correctly removing relationships when the destination of a relationship is removed from the workspace).
7+
38
## 2.1.3 (16th June 2024)
49

5-
- structurizr-core: Fixes https://github.com/structurizr/java/issues/298 (Unknown model item type on 'element')
10+
- structurizr-core: Fixes https://github.com/structurizr/java/issues/298 (Unknown model item type on 'element').
611

712
## 2.1.2 (30th April 2024)
813

structurizr-core/src/main/java/com/structurizr/model/Model.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,12 +1149,9 @@ private void removeElement(Element element) {
11491149

11501150
// remove any relationships to/from the element
11511151
for (Relationship relationship : getRelationships()) {
1152-
if (relationship.getSource() == element) {
1152+
if (relationship.getSource() == element || relationship.getDestination() == element) {
11531153
removeRelationshipFromInternalStructures(relationship);
11541154
relationship.getSource().remove(relationship);
1155-
} else if (relationship.getDestination() == element) {
1156-
removeRelationshipFromInternalStructures(relationship);
1157-
relationship.getDestination().remove(relationship);
11581155
}
11591156
}
11601157

structurizr-core/src/test/java/com/structurizr/WorkspaceTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,19 @@ void trim_WhenSomeElementsAreUnused() {
285285
assertTrue(workspace.getModel().contains(bc));
286286
}
287287

288+
@Test
289+
void trim_WhenTheDestinationOfAnElementIsRemoved() {
290+
Workspace workspace = new Workspace("Name", "Description");
291+
SoftwareSystem a = workspace.getModel().addSoftwareSystem("A");
292+
SoftwareSystem b = workspace.getModel().addSoftwareSystem("B");
293+
a.uses(b, "Uses");
294+
295+
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
296+
view.add(a);
297+
298+
workspace.trim();
299+
300+
assertEquals(0, a.getRelationships().size());
301+
}
302+
288303
}

0 commit comments

Comments
 (0)