File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
templateview/src/main/java/com/iluwatar/templateview Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .iluwatar .templateview ;
2+
3+ import java .io .ByteArrayOutputStream ;
4+ import java .io .PrintStream ;
5+ import static org .junit .jupiter .api .Assertions .assertTrue ;
6+
7+ public class TemplateViewRobot {
8+
9+ private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
10+ private final PrintStream originalOut = System .out ;
11+ public TemplateViewRobot render (TemplateView view ) {
12+ try {
13+ System .setOut (new PrintStream (outputStream ));
14+ view .render ();
15+ } finally {
16+ System .setOut (originalOut );
17+ }
18+ return this ;
19+ }
20+
21+ public TemplateViewRobot verifyContent (String expectedContent ) {
22+ String renderedOutput = outputStream .toString ();
23+ assertTrue (renderedOutput .contains (expectedContent ),
24+ String .format ("Expected content '%s' not found in output:\n %s" , expectedContent , renderedOutput ));
25+ return this ;
26+ }
27+
28+ public TemplateViewRobot reset () {
29+ outputStream .reset ();
30+ return this ;
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments