Skip to content

Commit

Permalink
Fixes #298
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed May 30, 2024
1 parent e509974 commit f5780f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## unreleased

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

## 2.1.2 (30th April 2024)

- structurizr-core: Adds better backwards compatibility to deal with old workspaces and those created by third party tooling that are missing view `order` property on views.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public String findTerminology(ModelItem modelItem) {
return !StringUtils.isNullOrEmpty(getDeploymentNode()) ? getDeploymentNode() : "Deployment Node";
} else if (modelItem instanceof InfrastructureNode) {
return !StringUtils.isNullOrEmpty(getInfrastructureNode()) ? getInfrastructureNode() : "Infrastructure Node";
} else if (modelItem instanceof CustomElement) {
String terminology = ((CustomElement)modelItem).getMetadata();
return !StringUtils.isNullOrEmpty(terminology) ? terminology : "Element";
}

throw new IllegalArgumentException("Unknown model item type.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class TerminologyTests {
void findTerminology() {
Workspace workspace = new Workspace("Name", "Description");
Terminology terminology = workspace.getViews().getConfiguration().getTerminology();
CustomElement element = workspace.getModel().addCustomElement("Element", "Hardware Device", "Description");
Person person = workspace.getModel().addPerson("Name");
SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name");
Container container = softwareSystem.addContainer("Container");
Expand All @@ -22,6 +23,7 @@ void findTerminology() {
ContainerInstance containerInstance = deploymentNode.add(container);
Relationship relationship = person.uses(softwareSystem, "Uses");

assertEquals("Hardware Device", terminology.findTerminology(element));
assertEquals("Person", terminology.findTerminology(person));
assertEquals("Software System", terminology.findTerminology(softwareSystem));
assertEquals("Container", terminology.findTerminology(container));
Expand Down

0 comments on commit f5780f2

Please sign in to comment.