Update mock injection example to make the behavior clear

This commit is contained in:
David Morley 2016-01-19 06:13:36 -06:00
parent db1c78cb79
commit a0ee0ccabc
2 changed files with 3 additions and 3 deletions

View File

@ -5,6 +5,6 @@ import org.springframework.stereotype.Service;
@Service
public class NameService {
public String getUserName(String id) {
return "Baeldung";
return "Real user name";
}
}

View File

@ -22,10 +22,10 @@ public class UserServiceTest {
@Test
public void whenUserIdIsProvided_thenRetrievedNameIsCorrect() {
Mockito.when(nameService.getUserName("SomeId")).thenReturn("Baeldung");
Mockito.when(nameService.getUserName("SomeId")).thenReturn("Mock user name");
String testName = userService.getUserName("SomeId");
Assert.assertEquals("Baeldung", testName);
Assert.assertEquals("Mock user name", testName);
}
}