// 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.ASSOCIATION_EDGE_STYLE;
import static org.livingdocumentation.dotdiagram.DotStyles.IMPLEMENTS_EDGE_STYLE;
import java.lang.reflect.Field;
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.Cluster;
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;
		// then wire them together
		domain = allClasses.stream().filter(filter(prefix, "domain"));
		domain.forEach(new Consumer<ClassInfo>() {
			public void accept(ClassInfo ci) {
				final Class clazz = ci.load();
				for (Field field : clazz.getDeclaredFields()) {
					final Class<?> type = field.getType();
					if (!type.isPrimitive()) {
						digraph.addExistingAssociation(clazz.getName(), type.getName(), null, null,
								ASSOCIATION_EDGE_STYLE);
					}
				}

				for (Class intf : clazz.getInterfaces()) {
					digraph.addExistingAssociation(intf.getName(), clazz.getName(), null, null, IMPLEMENTS_EDGE_STYLE);
				}
			}
		});

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

		String title = "Living Diagram";
		final String content = graph.render().trim();
		final String text = evaluate(template, title, content);
		write("", "livinggdiagram.html", text);
	}

	private Predicate<ClassInfo> filter(final String prefix, final String layer) {
		return new Predicate<ClassInfo>() {
// 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/LivingDiagramTest.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.ASSOCIATION_EDGE_STYLE;
import static org.livingdocumentation.dotdiagram.DotStyles.IMPLEMENTS_EDGE_STYLE;
import java.lang.reflect.Field;
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.Cluster;
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;

		// then wire them together
		domain = allClasses.stream().filter(filter(prefix, "domain"));
		domain.forEach(new Consumer<ClassInfo>() {
			public void accept(ClassInfo ci) {
				final Class clazz = ci.load();
				for (Field field : clazz.getDeclaredFields()) {
					final Class<?> type = field.getType();
					if (!type.isPrimitive()) {
						digraph.addExistingAssociation(clazz.getName(), type.getName(), null, null,
								ASSOCIATION_EDGE_STYLE);
					}
				}

				for (Class intf : clazz.getInterfaces()) {
					digraph.addExistingAssociation(intf.getName(), clazz.getName(), null, null, IMPLEMENTS_EDGE_STYLE);
				}
			}
		});

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

		String title = "Living Diagram";
		final String content = graph.render().trim();
		final String text = evaluate(template, title, content);
		write("", "livinggdiagram.html", text);
	}

	private Predicate<ClassInfo> filter(final String prefix, final String layer) {
		return new Predicate<ClassInfo>() {
			public boolean test(ClassInfo ci) {