Search in sources :

Example 1 with SourceConnectorTemplate

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);
        }
    });
}
Also used : Graph(guru.nidi.graphviz.model.Graph) File(java.io.File) SourceConnectorTemplate(com.github.jcustenborder.kafka.connect.utils.templates.SourceConnectorTemplate) Writer(java.io.Writer) StringWriter(java.io.StringWriter) ConnectorTemplate(com.github.jcustenborder.kafka.connect.utils.templates.ConnectorTemplate) Template(freemarker.template.Template) TransformationTemplate(com.github.jcustenborder.kafka.connect.utils.templates.TransformationTemplate) PluginTemplate(com.github.jcustenborder.kafka.connect.utils.templates.PluginTemplate) SourceConnectorTemplate(com.github.jcustenborder.kafka.connect.utils.templates.SourceConnectorTemplate)

Aggregations

ConnectorTemplate (com.github.jcustenborder.kafka.connect.utils.templates.ConnectorTemplate)1 PluginTemplate (com.github.jcustenborder.kafka.connect.utils.templates.PluginTemplate)1 SourceConnectorTemplate (com.github.jcustenborder.kafka.connect.utils.templates.SourceConnectorTemplate)1 TransformationTemplate (com.github.jcustenborder.kafka.connect.utils.templates.TransformationTemplate)1 Template (freemarker.template.Template)1 Graph (guru.nidi.graphviz.model.Graph)1 File (java.io.File)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1