1+ package com .iluwatar .privateclassdata ;
2+
3+ import org .junit .Test ;
4+ import org .mockito .InOrder ;
5+
6+ import static org .mockito .Mockito .inOrder ;
7+ import static org .mockito .Mockito .verify ;
8+
9+ /**
10+ * Date: 12/27/15 - 10:46 PM
11+ *
12+ * @author Jeroen Meulemeester
13+ */
14+ public class ImmutableStewTest extends StdOutTest {
15+
16+ /**
17+ * Verify if mixing the stew doesn't change the internal state
18+ */
19+ @ Test
20+ public void testMix () {
21+ final Stew stew = new Stew (1 , 2 , 3 , 4 );
22+ final String message = "Mixing the stew we find: 1 potatoes, 2 carrots, 3 meat and 4 peppers" ;
23+
24+ final InOrder inOrder = inOrder (getStdOutMock ());
25+ for (int i = 0 ; i < 20 ; i ++) {
26+ stew .mix ();
27+ inOrder .verify (getStdOutMock ()).println (message );
28+ }
29+
30+ inOrder .verifyNoMoreInteractions ();
31+ }
32+
33+ /**
34+ * Verify if tasting the stew actually removes one of each ingredient
35+ */
36+ @ Test
37+ public void testDrink () {
38+ final Stew stew = new Stew (1 , 2 , 3 , 4 );
39+ stew .mix ();
40+
41+ verify (getStdOutMock ())
42+ .println ("Mixing the stew we find: 1 potatoes, 2 carrots, 3 meat and 4 peppers" );
43+
44+ stew .taste ();
45+ verify (getStdOutMock ()).println ("Tasting the stew" );
46+
47+ stew .mix ();
48+ verify (getStdOutMock ())
49+ .println ("Mixing the stew we find: 0 potatoes, 1 carrots, 2 meat and 3 peppers" );
50+
51+ }
52+ }
0 commit comments