### Question:
GithubBountyServiceImpl implements GithubBountyService, ApplicationListener<AuthenticationSuccessEvent> { @EventListener @Transactional public void onProviderLinked(UserLinkedProviderEvent event) { if (event.getProvider() == Provider.GITHUB && event.getPrincipal() != null) { UserProfile userProfile = profileService.getUserProfile(event.getPrincipal()); createBountyWhenNecessary(event.getPrincipal(), userProfile); } } GithubBountyServiceImpl(ProfileService profileService,
                                   GithubBountyRepository githubBountyRepository,
                                   BountyService bountyService,
                                   GithubGateway githubGateway,
                                   ApplicationEventPublisher eventPublisher); @EventListener @Transactional void onProviderLinked(UserLinkedProviderEvent event); @Override @Transactional void onApplicationEvent(AuthenticationSuccessEvent event); @Override @Transactional(readOnly = true) GithubVerificationDto getVerification(Principal principal);  }### Answer:
@Test public void onProviderLinked() { Authentication authentication = mock(Authentication.class, RETURNS_DEEP_STUBS); when(authentication.getName()).thenReturn("davy"); when(profileService.getUserProfile(authentication)) .thenReturn(UserProfile.builder().github(UserProfileProvider.builder().userId("id").username("davy").build()).verifiedDeveloper(true).build()); when(githubGateway.getUser("davy")).thenReturn(GithubUser.builder().createdAt(LocalDateTime.of(2017, 1, 1, 1, 1)).location("Belgium").build()); githubBountyService.onProviderLinked(UserLinkedProviderEvent.builder().principal(authentication).provider(Provider.GITHUB).build()); verifyBountiesSaved(); }