Complete the code to create a mock object using Mockito.
UserService userService = Mockito.[1](UserService.class);
Mockito.mock() creates a mock object that simulates the behavior of the real class.
Complete the code to stub a method call on the mock to return a specific value.
Mockito.[1](userService.getUserName()).thenReturn("Alice");
Mockito.when() is used to specify what a mock should return when a method is called.
Fix the error in the verification statement to check if getUserName() was called once.
Mockito.verify(userService, Mockito.[1]()).getUserName();Mockito.times(1) verifies that the method was called exactly once.
Fill both blanks to stub a method and verify it was called with a specific argument.
Mockito.[1](userService.getUserById([2])).thenReturn(new User("Bob")); Mockito.verify(userService).getUserById(5);
Use when() to stub the method call with argument 5, then verify it was called with 5.
Fill all three blanks to create a mock, stub a method, and verify the call.
UserRepository repo = Mockito.[1](UserRepository.class); Mockito.[2](repo.findUserByEmail([3])).thenReturn(new User("Eve")); Mockito.verify(repo).findUserByEmail("eve@example.com");
First, create a mock with mock(), then stub the method with when(), passing the email string as argument.