Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
StructurizrPlantUMLExporter: Fixes an issue with software system/cont…
Browse files Browse the repository at this point in the history
…ainer instance URLs not being output.
  • Loading branch information
simonbrowndotje committed Dec 28, 2023
1 parent 59db50a commit 2803a68
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,31 +334,27 @@ 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;
name = elementInstance.getElement().getName();
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<Default.Node.A_1>> {
BackgroundColor #dddddd
FontColor #000000
BorderColor #9a9a9a
shadowing false
}
skinparam rectangle<<Default.Node>> {
BackgroundColor #ffffff
FontColor #000000
BorderColor #888888
shadowing false
}
rectangle "Node\\n<size:10>[Deployment Node]</size>" <<Default.Node>> as Default.Node {
rectangle "==A\\n<size:10>[Software System]</size>" <<Default.Node.A_1>> 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<<Default.Node.A_1>> {
BackgroundColor #dddddd
FontColor #000000
BorderColor #9a9a9a
shadowing false
}
skinparam rectangle<<Default.Node>> {
BackgroundColor #ffffff
FontColor #000000
BorderColor #888888
shadowing false
}
rectangle "Node\\n<size:10>[Deployment Node]</size>" <<Default.Node>> as Default.Node {
rectangle "==A\\n<size:10>[Software System]</size>" <<Default.Node.A_1>> as Default.Node.A_1 [[https://example.com/url2]]
}
@enduml""", new StructurizrPlantUMLExporter().export(view).getDefinition()); }

}

0 comments on commit 2803a68

Please sign in to comment.