### Question:
SignInEventListener implements ApplicationListener<SignInEvent> { @Override public void onApplicationEvent(SignInEvent event) { userService.addDefaultHabit(event.getUser().getId(), "en"); } @Autowired  SignInEventListener(UserService userService); @Override void onApplicationEvent(SignInEvent event);  }### Answer:
@Test public void onApplicationEvent() { doNothing().when(userService).addDefaultHabit(anyLong(), anyString()); signInEventListener.onApplicationEvent(new SignInEvent(User.builder().id(1L).build())); verify(userService, times(1)).addDefaultHabit(anyLong(), anyString()); }
@Test(expected = ClassCastException.class) public void onApplicationEventWithInvalidEvent() { signInEventListener.onApplicationEvent(new SignInEvent("I'm a User")); }