11package com .googlecode .totallylazy .template ;
22
33import com .googlecode .totallylazy .Strings ;
4+ import com .googlecode .totallylazy .predicates .Predicates ;
45import org .junit .Test ;
56
67import java .io .PrintWriter ;
78
89import static com .googlecode .totallylazy .Assert .assertThat ;
910import static com .googlecode .totallylazy .Maps .map ;
11+ import static com .googlecode .totallylazy .Strings .contains ;
1012import static com .googlecode .totallylazy .Strings .startsWith ;
1113import static com .googlecode .totallylazy .predicates .Predicates .contains ;
1214import static com .googlecode .totallylazy .predicates .Predicates .instanceOf ;
1315import static com .googlecode .totallylazy .predicates .Predicates .is ;
16+ import static com .googlecode .totallylazy .predicates .Predicates .not ;
1417import static com .googlecode .totallylazy .template .Templates .templates ;
1518
1619public class TemplatesTest {
@@ -57,10 +60,12 @@ public void canUseTemplatesFromClassPathAndDefaultTemplates() throws Exception {
5760
5861 @ Test
5962 public void doesNotThrowWhenASubTemplateIsNotFoundButReturnsEmptyStringAndLogs () throws Exception {
60- StringBuilder log = new StringBuilder ();
61- Templates templates = templates (getClass ()).logger (log ).extension ("st" );
63+ StringBuilder builder = new StringBuilder ();
64+ Templates templates = templates (getClass ()).logger (builder ).extension ("st" ). add ( "works" , ignore -> "Other templates still work " );
6265 String result = templates .get ("error" ).render (map ());
63- assertThat (result , is ("Sub template returned ''" ));
64- assertThat (log .toString (), startsWith ("Unable to load template 'foo.st' because: " ));
66+ assertThat (result , is ("Other templates still work\n Sub template returned ''" ));
67+ String log = builder .toString ();
68+ assertThat (log , startsWith ("Unable to load template 'foo.st' because: " ));
69+ assertThat (log , not (contains ("Unable to load template 'works' because: " )));
6570 }
6671}
0 commit comments