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

Add C4-PlantUML Properties to Deployment_Nodes #45

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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