@Test
public void shouldServiceTriggerHookWhenPrerequisitesAreSatisfied() {

  // GIVEN
  EasyMock.expect(configurationMock.isUserHookEnabled()).andReturn(Boolean.TRUE);
  EasyMock.expect(clustersMap.isEmpty()).andReturn(Boolean.FALSE);
  EasyMock.expect(clustersMock.getClusters()).andReturn(clustersMap);
  Capture<HookContext> contextCapture = EasyMock.newCapture();
  EasyMock.expect(eventFactoryMock.newUserCreatedEvent(EasyMock.capture(contextCapture))).andReturn(userCreatedEvent);
  Capture<UserCreatedEvent> userCreatedEventCapture = EasyMock.newCapture();
  ambariEventPublisherMock.publish(EasyMock.capture(userCreatedEventCapture));
  replayAll();
  // WHEN
  Boolean triggered = hookService.execute(hookContext);
  //THEN
  Assert.assertTrue("The hook must be triggered if prerequisites satisfied!", triggered);
  Assert.assertEquals("The hook context the event is generated from is not as expected ", hookContext, contextCapture.getValue());
  Assert.assertEquals("The user created event is not the expected ", userCreatedEvent, userCreatedEventCapture.getValue());
}