use of com.github.jcustenborder.kafka.connect.utils.templates.SourceConnectorTemplate in project connect-utils by jcustenborder.
the class BaseDocumentationTest method connectorRstTest.
DynamicTest connectorRstTest(ConnectorTemplate connectorTemplate, final String templateName, final File parentDirectory) {
if (!parentDirectory.isDirectory()) {
parentDirectory.mkdirs();
}
return dynamicTest(connectorTemplate.getSimpleName(), () -> {
final File graphOutputFile = new File(parentDirectory, connectorTemplate.getDiagramFileName());
final Graph g;
if (connectorTemplate instanceof SourceConnectorTemplate) {
g = graph().graphAttr().with(RankDir.LEFT_TO_RIGHT).directed().with(node(connectorTemplate.getSimpleName()).with(Shape.RECTANGLE).link(to(node("Kafka Connect").with(Shape.RECTANGLE).link(to(node("Kafka").with(Shape.RECTANGLE)).with(Label.of("Writes messages to")))).with(Label.of("Hosted by"))));
} else {
g = graph().graphAttr().with(RankDir.LEFT_TO_RIGHT).directed().with(node("Kafka").with(Shape.RECTANGLE).link(to(node("Kafka Connect").with(Shape.RECTANGLE).link(to(node(connectorTemplate.getSimpleName()).with(Shape.RECTANGLE)).with(Label.of("Writes data to")))).with(Label.of("Pulls Data from"))));
}
Graphviz.fromGraph(g).width(350).render(Format.SVG_STANDALONE).toFile(graphOutputFile);
final File outputFile = new File(parentDirectory, connectorTemplate.getSimpleName() + ".rst");
Template template = configuration.getTemplate(templateName);
log.info("Writing {}", outputFile);
try (Writer writer = Files.newWriter(outputFile, Charsets.UTF_8)) {
process(writer, template, connectorTemplate);
}
});
}
Aggregations