@Test
public void dispatchOneSpecialHook() {
long sensorTypeId = 7L;
IMethodSensor methodSensor = mock(IMethodSensor.class);
ISpecialHook specialHook = mock(ISpecialHook.class);
MethodSensorTypeConfig methodSensorConfig = mock(MethodSensorTypeConfig.class);
when(methodSensor.getHook()).thenReturn(specialHook);
when(methodSensor.getSensorTypeConfig()).thenReturn(methodSensorConfig);
when(methodSensorConfig.getId()).thenReturn(sensorTypeId);
SpecialSensorConfig specialSensorConfig = mock(SpecialSensorConfig.class);
when(specialSensorConfig.getSensor()).thenReturn(methodSensor);
int methodId = 3;
Object object = mock(Object.class);
Object[] parameters = new Object[0];
Object returnValue = mock(Object.class);
hookDispatcher.addMapping(methodId, specialSensorConfig);
Object result = hookDispatcher.dispatchSpecialMethodBeforeBody(methodId, object, parameters);
verify(specialSensorConfig, times(1)).getSensor();
verify(specialHook, times(1)).beforeBody(methodId, object, parameters, specialSensorConfig);
assertThat(result, is(nullValue()));
result = hookDispatcher.dispatchSpecialMethodAfterBody(methodId, object, parameters, returnValue);
verify(specialSensorConfig, times(2)).getSensor();
verify(specialHook, times(1)).afterBody(methodId, object, parameters, returnValue, specialSensorConfig);
assertThat(result, is(nullValue()));
verifyZeroInteractions(object, coreService, returnValue);
verifyNoMoreInteractions(specialSensorConfig, specialHook);
}