Skip to content

Commit

Permalink
Merge pull request #580 from Mogztter/issue-578-plantuml-stdlib
Browse files Browse the repository at this point in the history
resolves #578 preserve PlantUML stdlib: archimate, logos and elastic
  • Loading branch information
ggrossetie authored Feb 5, 2021
2 parents b6bd6eb + 7c94dbb commit 849d9fb
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/src/main/java/io/kroki/server/service/Plantuml.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ public class Plantuml implements DiagramService {
private final DiagramResponse diagramResponse;
private final List<Pattern> includeWhitelist;
private static final List<String> STDLIB = Arrays.asList(
"archimate",
"aws",
"awslib",
"azure",
"c4",
"cloudinsight",
"cloudogu",
"elastic",
"kubernetes",
"logos",
"material",
"office",
"osa",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,92 @@ void should_return_a_diagram() {
assertThat(convert).isNotEmpty();
}

@Test
void should_preserve_archimate_stdlib_include() throws IOException {
String diagram = "@startuml\n" +
"!include <archimate/Archimate>\n" +
"\n" +
"title Archimate Sample - Internet Browser\n" +
"\n" +
"' Elements\n" +
"Business_Object(businessObject, \"A Business Object\")\n" +
"Business_Process(someBusinessProcess,\"Some Business Process\")\n" +
"Business_Service(itSupportService, \"IT Support for Business (Application Service)\")\n" +
"\n" +
"Application_DataObject(dataObject, \"Web Page Data \\n 'on the fly'\")\n" +
"Application_Function(webpageBehaviour, \"Web page behaviour\")\n" +
"Application_Component(ActivePartWebPage, \"Active Part of the web page \\n 'on the fly'\")\n" +
"\n" +
"Technology_Artifact(inMemoryItem,\"in memory / 'on the fly' html/javascript\")\n" +
"Technology_Service(internetBrowser, \"Internet Browser Generic & Plugin\")\n" +
"Technology_Service(internetBrowserPlugin, \"Some Internet Browser Plugin\")\n" +
"Technology_Service(webServer, \"Some web server\")\n" +
"\n" +
"'Relationships\n" +
"Rel_Flow_Left(someBusinessProcess, businessObject, \"\")\n" +
"Rel_Serving_Up(itSupportService, someBusinessProcess, \"\")\n" +
"Rel_Specialization_Up(webpageBehaviour, itSupportService, \"\")\n" +
"Rel_Flow_Right(dataObject, webpageBehaviour, \"\")\n" +
"Rel_Specialization_Up(dataObject, businessObject, \"\")\n" +
"Rel_Assignment_Left(ActivePartWebPage, webpageBehaviour, \"\")\n" +
"Rel_Specialization_Up(inMemoryItem, dataObject, \"\")\n" +
"Rel_Realization_Up(inMemoryItem, ActivePartWebPage, \"\")\n" +
"Rel_Specialization_Right(inMemoryItem,internetBrowser, \"\")\n" +
"Rel_Serving_Up(internetBrowser, webpageBehaviour, \"\")\n" +
"Rel_Serving_Up(internetBrowserPlugin, webpageBehaviour, \"\")\n" +
"Rel_Aggregation_Right(internetBrowser, internetBrowserPlugin, \"\")\n" +
"Rel_Access_Up(webServer, inMemoryItem, \"\")\n" +
"Rel_Serving_Up(webServer, internetBrowser, \"\")\n" +
"@enduml";
byte[] convert = Plantuml.convert(Plantuml.sanitize(diagram, SafeMode.SAFE), FileFormat.SVG);
assertThat(convert).isNotEmpty();
}

@Test
void should_preserve_elastic_stdlib_include() throws IOException {
String diagram = "@startuml\n" +
"!include <elastic/common>\n" +
"!include <elastic/elasticsearch/elasticsearch>\n" +
"!include <elastic/logstash/logstash>\n" +
"!include <elastic/kibana/kibana>\n" +
"\n" +
"ELASTICSEARCH(ElasticSearch, \"Search and Analyze\",database)\n" +
"LOGSTASH(Logstash, \"Parse and Transform\",node)\n" +
"KIBANA(Kibana, \"Visualize\",agent) \n" +
"\n" +
"Logstash -right-> ElasticSearch: Transformed Data\n" +
"ElasticSearch -right-> Kibana: Data to View\n" +
"@enduml";
byte[] convert = Plantuml.convert(Plantuml.sanitize(diagram, SafeMode.SAFE), FileFormat.SVG);
assertThat(convert).isNotEmpty();
}


@Test
void should_preserve_logos_stdlib_include() throws IOException {
String diagram = "@startuml\n" +
"!include <logos/kafka>\n" +
"!include <logos/cassandra>\n" +
"!include <logos/flask>\n" +
"!include <logos/kotlin>\n" +
"\n" +
"title Gil Barbara's logos example\n" +
"\n" +
"skinparam monochrome true\n" +
"\n" +
"rectangle \"<$flask>\\nwebapp\" as webapp\n" +
"queue \"<$kafka>\" as kafka\n" +
"rectangle \"<$kotlin>\\ndaemon\" as daemon\n" +
"database \"<$cassandra>\" as cassandra\n" +
"\n" +
"webapp -> kafka\n" +
"kafka -> daemon\n" +
"daemon --> cassandra\n" +
"@enduml";
byte[] convert = Plantuml.convert(Plantuml.sanitize(diagram, SafeMode.SAFE), FileFormat.SVG);
assertThat(convert).isNotEmpty();
}

@Test
void should_preserve_stdlib_include() throws IOException {
String diagram = "@startuml\n" +
Expand Down

0 comments on commit 849d9fb

Please sign in to comment.