File tree Expand file tree Collapse file tree
mockito/src/test/java/org/baeldung/mockito Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import org .junit .Test ;
44import org .mockito .Mockito ;
5- import org .mockito .invocation .InvocationOnMock ;
6- import org .mockito .stubbing .Answer ;
75
86import static org .apache .commons .lang3 .RandomStringUtils .randomAlphabetic ;
97import static org .hamcrest .Matchers .equalTo ;
@@ -69,22 +67,17 @@ public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCall
6967 }
7068
7169 @ Test
72- public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMetehodIsCalled () {
70+ public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMethodIsCalled () {
7371 final MyList listMock = Mockito .mock (MyList .class );
7472 when (listMock .size ()).thenCallRealMethod ();
7573
7674 assertThat (listMock .size (), equalTo (1 ));
7775 }
7876
7977 @ Test
80- public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMetehodIsCalled () {
78+ public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMethodIsCalled () {
8179 final MyList listMock = Mockito .mock (MyList .class );
82- doAnswer (new Answer <String >() {
83- @ Override
84- public final String answer (final InvocationOnMock invocation ) {
85- return "Always the same" ;
86- }
87- }).when (listMock ).get (anyInt ());
80+ doAnswer (invocation -> "Always the same" ).when (listMock ).get (anyInt ());
8881
8982 final String element = listMock .get (1 );
9083 assertThat (element , is (equalTo ("Always the same" )));
Original file line number Diff line number Diff line change 302302 <ehcache .version>3.1.3</ehcache .version>
303303 <easymock .version>3.4</easymock .version>
304304 <assertj .version>3.6.1</assertj .version>
305- <jasperreports .version>6.4.0</jasperreports .version>
305+ <jasperreports .version>6.4.0</jasperreports .version>
306306
307307 </properties >
308308
You can’t perform that action at this time.
0 commit comments