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

Commit

Permalink
Merge pull request #45 from djjlewis/c4plantuml-deployment-node-prope…
Browse files Browse the repository at this point in the history
…rties

Add C4-PlantUML Properties to Deployment_Nodes
  • Loading branch information
simonbrowndotje committed Feb 13, 2023
2 parents 0a16b47 + cd439ff commit 318cb85
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ protected void startDeploymentNodeBoundary(DeploymentView view, DeploymentNode d
url = "";
}

if (Boolean.TRUE.toString().equalsIgnoreCase(view.getViewSet().getConfiguration().getProperties().getOrDefault(C4PLANTUML_ELEMENT_PROPERTIES_PROPERTY, Boolean.FALSE.toString()))) {
addProperties(view, writer, deploymentNode);
}

if (StringUtils.isNullOrEmpty(deploymentNode.getTechnology())) {
writer.writeLine(
format("Deployment_Node(%s, \"%s\", $tags=\"%s\")%s {",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,26 @@ public void test_printProperties() throws Exception {
assertEquals(expected, diagram.getDefinition());
}

@Test
public void test_deploymentViewPrintProperties() throws Exception {
Workspace workspace = new Workspace("Name", "Description");

DeploymentNode deploymentNode = workspace.getModel().addDeploymentNode("Deployment node");
deploymentNode.addProperty("Prop1", "Value1");

InfrastructureNode infraNode = deploymentNode.addInfrastructureNode("Infrastructure node", "description", "technology");
infraNode.addProperty("Prop2", "Value2");

workspace.getViews().getConfiguration().addProperty(C4PlantUMLExporter.C4PLANTUML_ELEMENT_PROPERTIES_PROPERTY, Boolean.TRUE.toString());
DeploymentView deploymentView = workspace.getViews().createDeploymentView("deploymentView", "");
deploymentView.addDefaultElements();

Diagram diagram = new C4PlantUMLExporter().export(deploymentView);

String expected = readFile(new File("./src/test/java/com/structurizr/export/plantuml/c4plantuml/printProperties-deploymentView.puml"));
assertEquals(expected, diagram.getDefinition());
}

@Test
public void test_legendAndStereotypes() {
Workspace workspace = new Workspace("Name", "Description");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@startuml
title Deployment - Default

top to bottom direction

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml

WithoutPropertyHeader()
AddProperty("Prop1","Value1")
Deployment_Node(Default.Deploymentnode, "Deployment node", $tags="") {
WithoutPropertyHeader()
AddProperty("Prop2","Value2")
Deployment_Node(Default.Deploymentnode.Infrastructurenode, "Infrastructure node", "technology", "description", $tags="")
}


SHOW_LEGEND(true)
@enduml

0 comments on commit 318cb85

Please sign in to comment.