### Question:
CustomTagService { public void contentBeforeIndexedHandler(@Observes ContentBeforeIndexedEvent event) { log.log(Level.FINE, "contentBeforeIndexedHandler called for event {0}", event); if (event == null || event.getContentId() == null || event.getContentData() == null) { log.warning("Invalid event " + event); return; } Map<String, Object> content = event.getContentData(); updateSysTagsField(content); }  void contentDeletedEventHandler(@Observes ContentDeletedEvent event); void contentBeforeIndexedHandler(@Observes ContentBeforeIndexedEvent event); void contributorMergedEventHandler(@Observes ContributorMergedEvent event); void contributorCodeChangedEventHandler(@Observes ContributorCodeChangedEvent event); @SuppressWarnings("unchecked") void updateSysTagsField(Map<String, Object> source);  }### Answer:
@Test public void contentBeforeIndexedHandler() { CustomTagService tested = getTested(); tested.contentBeforeIndexedHandler(null); verifyZeroInteractions(tested.customTagPersistenceService); reset(tested.customTagPersistenceService); tested.contentBeforeIndexedHandler(new ContentBeforeIndexedEvent(null, null)); verifyZeroInteractions(tested.customTagPersistenceService); reset(tested.customTagPersistenceService); tested.contentBeforeIndexedHandler(new ContentBeforeIndexedEvent("id", null)); verifyZeroInteractions(tested.customTagPersistenceService); reset(tested.customTagPersistenceService); tested.contentBeforeIndexedHandler(new ContentBeforeIndexedEvent(null, new HashMap<String, Object>())); verifyZeroInteractions(tested.customTagPersistenceService); { reset(tested.customTagPersistenceService); Map<String, Object> content = new HashMap<String, Object>(); List<String> listOfLabels = new ArrayList<String>(); listOfLabels.add("label1"); listOfLabels.add("label2"); content.put(ContentObjectFields.TAGS, listOfLabels); Mockito.when(tested.customTagPersistenceService.getTagsByContent("id")).thenReturn(new ArrayList<Tag>()); tested.contentBeforeIndexedHandler(new ContentBeforeIndexedEvent("id", content)); Assert.assertEquals(listOfLabels, content.get(ContentObjectFields.SYS_TAGS)); } { reset(tested.customTagPersistenceService); Map<String, Object> content = new HashMap<String, Object>(); content.put(ContentObjectFields.TAGS, null); content.put(ContentObjectFields.SYS_ID, "contentId"); List<Tag> listOfTags = new ArrayList<Tag>(); listOfTags.add(new Tag("contentId", "contributorId", "label")); Mockito.when(tested.customTagPersistenceService.getTagsByContent("contentId")).thenReturn(listOfTags); tested.contentBeforeIndexedHandler(new ContentBeforeIndexedEvent("contentId", content)); List<String> listOfLabel = new ArrayList<String>(); listOfLabel.add("label"); Assert.assertEquals(listOfLabel, content.get(ContentObjectFields.SYS_TAGS)); } }