diff --git a/docs/changelog.md b/docs/changelog.md index c1b4f93..dbbf46d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,7 @@ ## 1.19.0 (unreleased) - C4PlantUMLExporter: Added `$descr` field in deployment nodes. +- StructurizrPlantUMLExporter: Fixes an issue with software system/container instance URLs not being output. - Updated dependencies. ## 1.18.0 (26th November 2023) diff --git a/src/main/java/com/structurizr/export/plantuml/StructurizrPlantUMLExporter.java b/src/main/java/com/structurizr/export/plantuml/StructurizrPlantUMLExporter.java index e7d7afe..97d92a8 100644 --- a/src/main/java/com/structurizr/export/plantuml/StructurizrPlantUMLExporter.java +++ b/src/main/java/com/structurizr/export/plantuml/StructurizrPlantUMLExporter.java @@ -334,13 +334,7 @@ protected void writeElement(ModelView view, Element element, IndentingWriter wri String description = element.getDescription(); String type = typeOf(view, element, true); String icon = ""; - String url = element.getUrl(); - if (!StringUtils.isNullOrEmpty(url)) { - url = " [[" + url + "]]"; - } else { - url = ""; - } if (element instanceof StaticStructureElementInstance) { StaticStructureElementInstance elementInstance = (StaticStructureElementInstance) element; @@ -348,17 +342,19 @@ protected void writeElement(ModelView view, Element element, IndentingWriter wri description = elementInstance.getElement().getDescription(); type = typeOf(view, elementInstance.getElement(), true); shape = plantUMLShapeOf(view, elementInstance.getElement()); + url = elementInstance.getUrl(); if (StringUtils.isNullOrEmpty(url)) { - url = element.getUrl(); - if (!StringUtils.isNullOrEmpty(url)) { - url = " [[" + url + "]]"; - } else { - url = ""; - } + url = elementInstance.getElement().getUrl(); } } + if (!StringUtils.isNullOrEmpty(url)) { + url = " [[" + url + "]]"; + } else { + url = ""; + } + if (StringUtils.isNullOrEmpty(description) || false == elementStyle.getDescription()) { description = ""; } else { diff --git a/src/test/java/com/structurizr/export/plantuml/StructurizrPlantUMLDiagramExporterTests.java b/src/test/java/com/structurizr/export/plantuml/StructurizrPlantUMLDiagramExporterTests.java index 90aee50..4b28ab4 100644 --- a/src/test/java/com/structurizr/export/plantuml/StructurizrPlantUMLDiagramExporterTests.java +++ b/src/test/java/com/structurizr/export/plantuml/StructurizrPlantUMLDiagramExporterTests.java @@ -947,4 +947,85 @@ public void deploymentView_WithGroups() { assertEquals(expectedResult, diagram.getDefinition()); } + @Test + public void test_ElementInstanceUrl() { + Workspace workspace = new Workspace("Name", "Description"); + SoftwareSystem a = workspace.getModel().addSoftwareSystem("A"); + a.setUrl("https://example.com/url1"); + SoftwareSystemInstance aInstance = workspace.getModel().addDeploymentNode("Node").add(a); + + DeploymentView view = workspace.getViews().createDeploymentView("deployment", "Default"); + view.add(aInstance); + + assertEquals(""" +@startuml +set separator none +title Deployment - Default + +top to bottom direction + +skinparam { + arrowFontSize 10 + defaultTextAlignment center + wrapWidth 200 + maxMessageSize 100 +} + +hide stereotype + +skinparam rectangle<> { + BackgroundColor #dddddd + FontColor #000000 + BorderColor #9a9a9a + shadowing false +} +skinparam rectangle<> { + BackgroundColor #ffffff + FontColor #000000 + BorderColor #888888 + shadowing false +} + +rectangle "Node\\n[Deployment Node]" <> as Default.Node { + rectangle "==A\\n[Software System]" <> as Default.Node.A_1 [[https://example.com/url1]] +} + +@enduml""", new StructurizrPlantUMLExporter().export(view).getDefinition()); + + aInstance.setUrl("https://example.com/url2"); + assertEquals(""" +@startuml +set separator none +title Deployment - Default + +top to bottom direction + +skinparam { + arrowFontSize 10 + defaultTextAlignment center + wrapWidth 200 + maxMessageSize 100 +} + +hide stereotype + +skinparam rectangle<> { + BackgroundColor #dddddd + FontColor #000000 + BorderColor #9a9a9a + shadowing false +} +skinparam rectangle<> { + BackgroundColor #ffffff + FontColor #000000 + BorderColor #888888 + shadowing false +} + +rectangle "Node\\n[Deployment Node]" <> as Default.Node { + rectangle "==A\\n[Software System]" <> as Default.Node.A_1 [[https://example.com/url2]] +} + +@enduml""", new StructurizrPlantUMLExporter().export(view).getDefinition()); } + } \ No newline at end of file