### Question:
ContributorProfileService { public void contributorMergedEventHandler(@Observes ContributorMergedEvent event) { if (event != null && event.getContributorCodeFrom() != null) { deleteByContributorCode(event.getContributorCodeFrom()); } else { log.warning("Invalid event " + event); } }  boolean isContributorCodeTypesSupported(String contributorCodeType); String getContributorId(String contributorCodeType, String contributorCodeValue, boolean forceCreate); String createOrUpdateProfile(String contributorCodeType, String contributorCodeValue, boolean forceUpdate); SearchResponse findByContributorCode(String contributorCode); boolean deleteByContributorCode(String code); @TransactionAttribute(TransactionAttributeType.NEVER) int fullSynContributorsAndProfiles(String contributorCodeType, Integer start, Integer size); @TransactionAttribute(TransactionAttributeType.NEVER) int createOrUpdateAllProfiles(String contributorCodeType); void contributorDeletedEventHandler(@Observes ContributorDeletedEvent event); void contributorMergedEventHandler(@Observes ContributorMergedEvent event); void contributorCodeChangedEventHandler(@Observes ContributorCodeChangedEvent event); static final String FIELD_TSC_JBOSSORG_USERNAME; static final String FIELD_TSC_GITHUB_USERNAME; static final String SEARCH_INDEX_NAME; static final String SEARCH_INDEX_TYPE; }### Answer:
@Test public void contributorMergedEventHandler() throws Exception { Client client = prepareESClientForUnitTest("ContributorProfileServiceTest_5"); ContributorProfileService tested = getTested(client); try { initIndex(client); Thread.sleep(100); indexInsertDocument(ContributorProfileService.SEARCH_INDEX_NAME, ContributorProfileService.SEARCH_INDEX_TYPE, "20", "{\"" + ContentObjectFields.SYS_CONTRIBUTORS + "\":[\"" + CODE_1 + "\"],\"displayName\":\"John Doe\"}"); indexInsertDocument(ContributorProfileService.SEARCH_INDEX_NAME, ContributorProfileService.SEARCH_INDEX_TYPE, "30", "{\"" + ContentObjectFields.SYS_CONTRIBUTORS + "\":[\"" + CODE_2 + "\"],\"displayName\":\"John Doe 2\"}"); tested.contributorMergedEventHandler(null); tested.contributorMergedEventHandler(new ContributorMergedEvent(null, null)); indexFlushAndRefresh(ContributorProfileService.SEARCH_INDEX_NAME); Assert.assertEquals(1, tested.findByContributorCode(CODE_1).getHits().getTotalHits()); Assert.assertEquals(1, tested.findByContributorCode(CODE_2).getHits().getTotalHits()); tested.contributorMergedEventHandler(new ContributorMergedEvent(CODE_1, CODE_2)); indexFlushAndRefresh(ContributorProfileService.SEARCH_INDEX_NAME); Assert.assertEquals(0, tested.findByContributorCode(CODE_1).getHits().getTotalHits()); Assert.assertEquals(1, tested.findByContributorCode(CODE_2).getHits().getTotalHits()); } finally { indexDelete(ContributorProfileService.SEARCH_INDEX_NAME); finalizeESClientForUnitTest(); } }