### Question:
Template { public String render(Object o) { StringBuilder result = new StringBuilder(template.length()); render(o, result); return result.toString(); } Template(final String template); static Template fromFile(final Class<?> resourceRoot, final String fileName); String render(Object o);  }### Answer:
@Test public void plainTextRenderedAsIs() { Template template = new Template("Hello World"); assertEquals("Hello World", template.render(foo)); }
@Test public void valuesSubstitutedIntoTemplate() { Template template = new Template("Hello {{value}} "); assertEquals("Hello World ", template.render(foo)); }
@Test public void valuesSubstitutedIntoTemplateDontNeedToBeStrings() { Template template = new Template("Hello {{nonStringValue}} "); assertEquals("Hello 3 ", template.render(foo)); }
@Test(expected = IllegalArgumentException.class) public void missingFieldShouldException() { Template template = new Template("Hello {{wtf}} "); template.render(foo); }
@Test public void canSubstituteMultipleValueIntoTemplate() { Template template = new Template("Hello {{nonStringValue}} {{value}}"); assertEquals("Hello 3 World", template.render(foo)); }
@Test public void canSubstituteValuesFromMethodsIntoTemplate() { Template template = new Template("Hello {{getPrivateNonStringValue}} {{getPrivateValue}}"); assertEquals("Hello 3 World", template.render(foo)); }
@Test public void canSubstituteValuesFromLists() { Template template = new Template("Hello {{#getValues}}{{toString}},{{/getValues}} "); assertEquals("Hello 1,2,3, ", template.render(foo)); }
@Test public void canSubstituteMultipleValuesFromLists() { Template template = new Template( "Hello {{#getValues}}{{toString}},{{/getValues}} {{getPrivateNonStringValue}} " + "{{#getValues}}{{toString}}.{{/getValues}} {{getPrivateValue}} "); assertEquals("Hello 1,2,3, 3 1.2.3. World ", template.render(foo)); }
@Test public void supportsFilteringTheNotLastListValue() { Template template = new Template( "Hello {{#getValues}}{{toString}}{{#notLast}},{{/notLast}}{{/getValues}} "); assertEquals("Hello 1,2,3 ", template.render(foo)); }