diff --git a/src/main/java/com/github/ferstl/depgraph/dependency/puml/PumlDependencyEgdeRenderer.java b/src/main/java/com/github/ferstl/depgraph/dependency/puml/PumlDependencyEgdeRenderer.java index c7c4039e..d20e26cf 100644 --- a/src/main/java/com/github/ferstl/depgraph/dependency/puml/PumlDependencyEgdeRenderer.java +++ b/src/main/java/com/github/ferstl/depgraph/dependency/puml/PumlDependencyEgdeRenderer.java @@ -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; /** @@ -44,7 +43,7 @@ public String render(DependencyNode from, DependencyNode to) { switch (resolution) { case INCLUDED: - + case PARENT: edgeInfo.withBegin("-[") .withColor(INCLUDE_COLOR) .withEnd("]->") diff --git a/src/main/java/com/github/ferstl/depgraph/graph/puml/PumlGraphFormatter.java b/src/main/java/com/github/ferstl/depgraph/graph/puml/PumlGraphFormatter.java index 77ea3588..a81f4cf7 100644 --- a/src/main/java/com/github/ferstl/depgraph/graph/puml/PumlGraphFormatter.java +++ b/src/main/java/com/github/ferstl/depgraph/graph/puml/PumlGraphFormatter.java @@ -68,7 +68,7 @@ private void writeNodes(StringBuilder puml, Collection> 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(">>"); diff --git a/src/test/java/com/github/ferstl/depgraph/ReactorIntegrationTest.java b/src/test/java/com/github/ferstl/depgraph/ReactorIntegrationTest.java index 75f8531b..10d9f862 100644 --- a/src/test/java/com/github/ferstl/depgraph/ReactorIntegrationTest.java +++ b/src/test/java/com/github/ferstl/depgraph/ReactorIntegrationTest.java @@ -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"); + } } diff --git a/src/test/projects/reactor-graph/expectations/reactor.dot b/src/test/projects/reactor-graph/expectations/reactor.dot new file mode 100644 index 00000000..13285d51 --- /dev/null +++ b/src/test/projects/reactor-graph/expectations/reactor.dot @@ -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=] + "com.github.ferstl:reactor-application"[label=] + "com.github.ferstl:reactor-database"[label=] + "com.github.ferstl:reactor-service"[label=] + "com.github.ferstl:reactor-common"[label=] + "com.github.ferstl:reactor-parent"[label=] + "com.github.ferstl:reactor-api"[label=] + + // 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"] +} \ No newline at end of file diff --git a/src/test/projects/reactor-graph/expectations/reactor.gml b/src/test/projects/reactor-graph/expectations/reactor.gml new file mode 100644 index 00000000..04825c4c --- /dev/null +++ b/src/test/projects/reactor-graph/expectations/reactor.gml @@ -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" +] + +] \ No newline at end of file diff --git a/src/test/projects/reactor-graph/expectations/reactor.puml b/src/test/projects/reactor-graph/expectations/reactor.puml new file mode 100644 index 00000000..8b65f416 --- /dev/null +++ b/src/test/projects/reactor-graph/expectations/reactor.puml @@ -0,0 +1,22 @@ +@startuml +skinparam defaultTextAlignment center +skinparam rectangle { + BackgroundColor<> beige + BackgroundColor<> lightGreen + BackgroundColor<> lightBlue + BackgroundColor<> 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 \ No newline at end of file