Skip to content

Commit

Permalink
Fixes #306
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Jun 18, 2024
1 parent 7460200 commit b4211a9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subprojects { proj ->

description = 'Structurizr'
group = 'com.structurizr'
version = '2.1.3'
version = '2.1.4'

repositories {
mavenCentral()
Expand Down
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Changelog


## 2.1.4 (18th June 2024)

- 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).

## 2.1.3 (16th June 2024)

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

## 2.1.2 (30th April 2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,12 +1149,9 @@ private void removeElement(Element element) {

// remove any relationships to/from the element
for (Relationship relationship : getRelationships()) {
if (relationship.getSource() == element) {
if (relationship.getSource() == element || relationship.getDestination() == element) {
removeRelationshipFromInternalStructures(relationship);
relationship.getSource().remove(relationship);
} else if (relationship.getDestination() == element) {
removeRelationshipFromInternalStructures(relationship);
relationship.getDestination().remove(relationship);
}
}

Expand Down
15 changes: 15 additions & 0 deletions structurizr-core/src/test/java/com/structurizr/WorkspaceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,19 @@ void trim_WhenSomeElementsAreUnused() {
assertTrue(workspace.getModel().contains(bc));
}

@Test
void trim_WhenTheDestinationOfAnElementIsRemoved() {
Workspace workspace = new Workspace("Name", "Description");
SoftwareSystem a = workspace.getModel().addSoftwareSystem("A");
SoftwareSystem b = workspace.getModel().addSoftwareSystem("B");
a.uses(b, "Uses");

SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
view.add(a);

workspace.trim();

assertEquals(0, a.getRelationships().size());
}

}

0 comments on commit b4211a9

Please sign in to comment.