Skip to content

Commit

Permalink
Add a PDF test
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed May 7, 2023
1 parent b5f2afe commit 241e55f
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -98,4 +99,27 @@ void should_not_use_network() throws IOException, InterruptedException {
System.clearProperty("socksProxyPort");
}
}

@Test
void should_convert_to_pdf() throws IOException, InterruptedException {
String diagram = "@startuml\n" +
"!include C4_Context.puml\n" +
"\n" +
"title System Context diagram for Internet Banking System\n" +
"\n" +
"Person(customer, \"Banking Customer\", \"A customer of the bank, with personal bank accounts.\")\n" +
"System(banking_system, \"Internet Banking System\", \"Allows customers to check their accounts.\")\n" +
"\n" +
"System_Ext(mail_system, \"E-mail system\", \"The internal Microsoft Exchange e-mail system.\")\n" +
"System_Ext(mainframe, \"Mainframe Banking System\", \"Stores all of the core banking information.\")\n" +
"\n" +
"Rel(customer, banking_system, \"Uses\")\n" +
"Rel_Back(customer, mail_system, \"Sends e-mails to\")\n" +
"Rel_Neighbor(banking_system, mail_system, \"Sends e-mails\", \"SMTP\")\n" +
"Rel(banking_system, mainframe, \"Uses\")\n" +
"@enduml";
byte[] convert = plantumlCommand.convert(Plantuml.sanitize(diagram, SafeMode.SAFE), FileFormat.PDF, new JsonObject());
assertThat(convert).isNotEmpty();
assertThat(new String(convert, StandardCharsets.UTF_8)).contains("%PDF-1.4");
}
}

0 comments on commit 241e55f

Please sign in to comment.