Skip to content

Commit

Permalink
Merge pull request #145 from ferstl/bugfix/#144-fix-puml-reactor-graph
Browse files Browse the repository at this point in the history
Bugfix/#144 fix puml reactor graph
  • Loading branch information
ferstl authored Mar 6, 2022
2 parents a8d8fb4 + e242365 commit 3a27533
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.github.ferstl.depgraph.dependency.DependencyNode;
import com.github.ferstl.depgraph.dependency.NodeResolution;
import com.github.ferstl.depgraph.graph.EdgeRenderer;

import static com.github.ferstl.depgraph.dependency.VersionAbbreviator.abbreviateVersion;

/**
Expand All @@ -44,7 +43,7 @@ public String render(DependencyNode from, DependencyNode to) {

switch (resolution) {
case INCLUDED:

case PARENT:
edgeInfo.withBegin("-[")
.withColor(INCLUDE_COLOR)
.withEnd("]->")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void writeNodes(StringBuilder puml, Collection<Node<?>> nodes) {
.append(escape(node.getNodeId()));


if (!nodeInfo.getStereotype().equals(SCOPE_COMPILE)) {
if (nodeInfo.getStereotype() != null && !nodeInfo.getStereotype().equals(SCOPE_COMPILE)) {
puml.append("<<")
.append(nodeInfo.getStereotype())
.append(">>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,44 @@ public void reactorText() throws Exception {

assertFileContents(basedir, "expectations/reactor.txt", "target/dependency-graph.txt");
}

@Test
public void reactorDot() throws Exception {
File basedir = this.resources.getBasedir("reactor-graph");
MavenExecutionResult result = this.mavenRuntime
.forProject(basedir)
.withCliOption("-DgraphFormat=dot")
.execute("clean", "depgraph:reactor");

result.assertErrorFreeLog();

assertFileContents(basedir, "expectations/reactor.dot", "target/dependency-graph.dot");
}

// Issue #144
@Test
public void reactorPuml() throws Exception {
File basedir = this.resources.getBasedir("reactor-graph");
MavenExecutionResult result = this.mavenRuntime
.forProject(basedir)
.withCliOption("-DgraphFormat=puml")
.execute("clean", "depgraph:reactor");

result.assertErrorFreeLog();

assertFileContents(basedir, "expectations/reactor.puml", "target/dependency-graph.puml");
}

@Test
public void reactorGml() throws Exception {
File basedir = this.resources.getBasedir("reactor-graph");
MavenExecutionResult result = this.mavenRuntime
.forProject(basedir)
.withCliOption("-DgraphFormat=gml")
.execute("clean", "depgraph:reactor");

result.assertErrorFreeLog();

assertFileContents(basedir, "expectations/reactor.gml", "target/dependency-graph.gml");
}
}
21 changes: 21 additions & 0 deletions src/test/projects/reactor-graph/expectations/reactor.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
digraph "G" {
node [shape="box",style="rounded",fontname="Helvetica",fontsize="14"]
edge [fontsize="10",fontname="Helvetica"]

// Node Definitions:
"com.github.ferstl:reactor-ui"[label=<reactor-ui>]
"com.github.ferstl:reactor-application"[label=<reactor-application>]
"com.github.ferstl:reactor-database"[label=<reactor-database>]
"com.github.ferstl:reactor-service"[label=<reactor-service>]
"com.github.ferstl:reactor-common"[label=<reactor-common>]
"com.github.ferstl:reactor-parent"[label=<reactor-parent>]
"com.github.ferstl:reactor-api"[label=<reactor-api>]

// Edge Definitions:
"com.github.ferstl:reactor-ui" -> "com.github.ferstl:reactor-application"[style="solid"]
"com.github.ferstl:reactor-database" -> "com.github.ferstl:reactor-service"[style="solid"]
"com.github.ferstl:reactor-common" -> "com.github.ferstl:reactor-database"[style="solid"]
"com.github.ferstl:reactor-common" -> "com.github.ferstl:reactor-ui"[style="solid"]
"com.github.ferstl:reactor-parent" -> "com.github.ferstl:reactor-api"[style="solid"]
"com.github.ferstl:reactor-parent" -> "com.github.ferstl:reactor-common"[style="solid"]
}
67 changes: 67 additions & 0 deletions src/test/projects/reactor-graph/expectations/reactor.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
graph [
node [
id "com.github.ferstl:reactor-ui"
label "reactor-ui"
]

node [
id "com.github.ferstl:reactor-application"
label "reactor-application"
]

node [
id "com.github.ferstl:reactor-database"
label "reactor-database"
]

node [
id "com.github.ferstl:reactor-service"
label "reactor-service"
]

node [
id "com.github.ferstl:reactor-common"
label "reactor-common"
]

node [
id "com.github.ferstl:reactor-parent"
label "reactor-parent"
]

node [
id "com.github.ferstl:reactor-api"
label "reactor-api"
]

edge [
source "com.github.ferstl:reactor-ui"
target "com.github.ferstl:reactor-application"
]

edge [
source "com.github.ferstl:reactor-database"
target "com.github.ferstl:reactor-service"
]

edge [
source "com.github.ferstl:reactor-common"
target "com.github.ferstl:reactor-database"
]

edge [
source "com.github.ferstl:reactor-common"
target "com.github.ferstl:reactor-ui"
]

edge [
source "com.github.ferstl:reactor-parent"
target "com.github.ferstl:reactor-api"
]

edge [
source "com.github.ferstl:reactor-parent"
target "com.github.ferstl:reactor-common"
]

]
22 changes: 22 additions & 0 deletions src/test/projects/reactor-graph/expectations/reactor.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
skinparam defaultTextAlignment center
skinparam rectangle {
BackgroundColor<<optional>> beige
BackgroundColor<<test>> lightGreen
BackgroundColor<<runtime>> lightBlue
BackgroundColor<<provided>> lightGray
}
rectangle "reactor-ui" as com_github_ferstl_reactor_ui
rectangle "reactor-application" as com_github_ferstl_reactor_application
rectangle "reactor-database" as com_github_ferstl_reactor_database
rectangle "reactor-service" as com_github_ferstl_reactor_service
rectangle "reactor-common" as com_github_ferstl_reactor_common
rectangle "reactor-parent" as com_github_ferstl_reactor_parent
rectangle "reactor-api" as com_github_ferstl_reactor_api
com_github_ferstl_reactor_ui -[#000000]-> com_github_ferstl_reactor_application
com_github_ferstl_reactor_database -[#000000]-> com_github_ferstl_reactor_service
com_github_ferstl_reactor_common -[#000000]-> com_github_ferstl_reactor_database
com_github_ferstl_reactor_common -[#000000]-> com_github_ferstl_reactor_ui
com_github_ferstl_reactor_parent -[#000000]-> com_github_ferstl_reactor_api
com_github_ferstl_reactor_parent -[#000000]-> com_github_ferstl_reactor_common
@enduml

0 comments on commit 3a27533

Please sign in to comment.