// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SimpleTemplate.java
// public static String evaluate(final String template, String title, String content) {
// 	return template.replace("{0}", title).replace("{1}", content);
// }
// 
// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SimpleTemplate.java
// public static String readTestResource(final String filename) {
// 	String lineSep = String.format("%n");
// 	final StringBuffer buffer = new StringBuffer();
// 	try {
// 		BufferedReader in = new BufferedReader(new InputStreamReader(
// 				DummyTemplatingTest.class.getResourceAsStream(filename)));
// 		String str = null;
// 		while ((str = in.readLine()) != null) {
// 			buffer.append(lineSep);
// 			buffer.append(str);
// 		}
// 		in.close();
// 	} catch (IOException e) {
// 		e.printStackTrace();
// 	}
// 	return buffer.toString();
// }
// 
// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SimpleTemplate.java
// public static void write(String path, String filename, String content) throws UnsupportedEncodingException,
// 		FileNotFoundException {
// 	final String outputFileName = path + filename;
// 	final String outputEncoding = "ISO-8859-1";
// 	final FileOutputStream fos = new FileOutputStream(outputFileName);
// 	final PrintWriter w = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fos, outputEncoding)));
// 
// 	w.println(content);
// 	w.flush();
// 	w.close();
// }


import static flottio.livingdocumentation.SimpleTemplate.evaluate;
import static flottio.livingdocumentation.SimpleTemplate.readTestResource;
import static flottio.livingdocumentation.SimpleTemplate.write;
import static org.livingdocumentation.dotdiagram.DotStyles.NOTE_EDGE_STYLE;
import static org.livingdocumentation.dotdiagram.DotStyles.STUB_NODE_OPTIONS;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.junit.Test;
import org.livingdocumentation.dotdiagram.DotGraph;
import org.livingdocumentation.dotdiagram.DotGraph.Digraph;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import com.thoughtworks.qdox.JavaProjectBuilder;
import com.thoughtworks.qdox.model.JavaAnnotatedElement;
import flottio.annotations.BoundedContext;
import flottio.annotations.ExternalActor;
import flottio.annotations.ExternalActor.ActorType;

		// render into image
		final String template = readTestResource("viz-template.html");

		String title = "Context Diagram";
		final String content = graph.render().trim();
		final String text = evaluate(template, title, content);
		write("", "context-diagram.html", text);
	}

	private static String firstImageIn(String[] strings) {
		for (String link : strings) {
			if (link.toLowerCase().endsWith(".png")) {
				return link;
			}
		}
		return null;
	}

	private BoundedContext findBoundedContext(ClassInfo ci) {
		BoundedContext first = null;
		final BoundedContext[] bc = ci.load().getAnnotationsByType(BoundedContext.class);
		for (BoundedContext boundedContext : bc) {
			first = boundedContext;
		}
		return first;
	}

	private final static String wrap(String words, final int length) {
		final StringBuilder sb = new StringBuilder(words);
// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SimpleTemplate.java
// public static String evaluate(final String template, String title, String content) {
// 	return template.replace("{0}", title).replace("{1}", content);
// }
// 
// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SimpleTemplate.java
// public static String readTestResource(final String filename) {
// 	String lineSep = String.format("%n");
// 	final StringBuffer buffer = new StringBuffer();
// 	try {
// 		BufferedReader in = new BufferedReader(new InputStreamReader(
// 				DummyTemplatingTest.class.getResourceAsStream(filename)));
// 		String str = null;
// 		while ((str = in.readLine()) != null) {
// 			buffer.append(lineSep);
// 			buffer.append(str);
// 		}
// 		in.close();
// 	} catch (IOException e) {
// 		e.printStackTrace();
// 	}
// 	return buffer.toString();
// }
// 
// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SimpleTemplate.java
// public static void write(String path, String filename, String content) throws UnsupportedEncodingException,
// 		FileNotFoundException {
// 	final String outputFileName = path + filename;
// 	final String outputEncoding = "ISO-8859-1";
// 	final FileOutputStream fos = new FileOutputStream(outputFileName);
// 	final PrintWriter w = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fos, outputEncoding)));
// 
// 	w.println(content);
// 	w.flush();
// 	w.close();
// }


// Path: living-documentation-workshop/src/test/java/flottio/livingdocumentation/SystemDiagramTest.java
import static flottio.livingdocumentation.SimpleTemplate.evaluate;
import static flottio.livingdocumentation.SimpleTemplate.readTestResource;
import static flottio.livingdocumentation.SimpleTemplate.write;
import static org.livingdocumentation.dotdiagram.DotStyles.NOTE_EDGE_STYLE;
import static org.livingdocumentation.dotdiagram.DotStyles.STUB_NODE_OPTIONS;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.junit.Test;
import org.livingdocumentation.dotdiagram.DotGraph;
import org.livingdocumentation.dotdiagram.DotGraph.Digraph;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import com.thoughtworks.qdox.JavaProjectBuilder;
import com.thoughtworks.qdox.model.JavaAnnotatedElement;
import flottio.annotations.BoundedContext;
import flottio.annotations.ExternalActor;
import flottio.annotations.ExternalActor.ActorType;


		// render into image
		final String template = readTestResource("viz-template.html");

		String title = "Context Diagram";
		final String content = graph.render().trim();
		final String text = evaluate(template, title, content);
		write("", "context-diagram.html", text);
	}

	private static String firstImageIn(String[] strings) {
		for (String link : strings) {
			if (link.toLowerCase().endsWith(".png")) {
				return link;
			}
		}
		return null;
	}

	private BoundedContext findBoundedContext(ClassInfo ci) {
		BoundedContext first = null;
		final BoundedContext[] bc = ci.load().getAnnotationsByType(BoundedContext.class);
		for (BoundedContext boundedContext : bc) {
			first = boundedContext;
		}
		return first;
	}

	private final static String wrap(String words, final int length) {
		final StringBuilder sb = new StringBuilder(words);
		int i = 0;