List<String> parameterTypes = instrumentationConfig.getParameterTypes();
protected void prepareConfigurationMockConstructor(MethodInstrumentationConfig point, Class<?> clazz, boolean staticConstructor, Class<?>... parameterTypes) throws SecurityException, NoSuchMethodException { clazz.getDeclaredConstructor(parameterTypes); when(point.getTargetClassFqn()).thenReturn(clazz.getName()); when(point.getTargetMethodName()).thenReturn(staticConstructor ? "<clinit>" : "<init>"); when(point.getReturnType()).thenReturn("void"); if (ArrayUtils.isNotEmpty(parameterTypes)) { List<String> params = new ArrayList<String>(); for (Class<?> paramType : parameterTypes) { if (paramType.isArray()) { params.add(paramType.getComponentType().getName() + "[]"); } else { params.add(paramType.getName()); } } when(point.getParameterTypes()).thenReturn(params); } }
protected void prepareConfigurationMockMethod(MethodInstrumentationConfig point, Class<?> clazz, String methodName, Class<?>... parameterTypes) throws SecurityException, NoSuchMethodException { Method method = clazz.getDeclaredMethod(methodName, parameterTypes); when(point.getTargetClassFqn()).thenReturn(clazz.getName()); when(point.getTargetMethodName()).thenReturn(methodName); if (method.getReturnType().isArray()) { when(point.getReturnType()).thenReturn(method.getReturnType().getComponentType().getName() + "[]"); } else { when(point.getReturnType()).thenReturn(method.getReturnType().getName()); } if (ArrayUtils.isNotEmpty(parameterTypes)) { List<String> params = new ArrayList<String>(); for (Class<?> paramType : parameterTypes) { if (paramType.isArray()) { params.add(paramType.getComponentType().getName() + "[]"); } else { params.add(paramType.getName()); } } when(point.getParameterTypes()).thenReturn(params); } }
when(methodInstrumentationConfig.getTargetMethodName()).thenReturn("<init>"); when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getParameterTypes()).thenReturn(Collections.<String> emptyList()); when(methodInstrumentationConfig.getSensorInstrumentationPoint()).thenReturn(sensorInstrumentationPoint); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sensorInstrumentationPoint));
when(methodInstrumentationConfig.getTargetMethodName()).thenReturn("<init>"); when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getParameterTypes()).thenReturn(Collections.<String> emptyList()); when(methodInstrumentationConfig.getSensorInstrumentationPoint()).thenReturn(sensorInstrumentationPoint); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sensorInstrumentationPoint));
when(methodInstrumentationConfig.getTargetMethodName()).thenReturn("<init>"); when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getParameterTypes()).thenReturn(Collections.<String> emptyList()); when(methodInstrumentationConfig.getSensorInstrumentationPoint()).thenReturn(sensorInstrumentationPoint); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sensorInstrumentationPoint));
assertThat(instrumentationConfig.getTargetMethodName(), is(methodName)); assertThat(instrumentationConfig.getReturnType(), is(returnType)); assertThat(instrumentationConfig.getParameterTypes(), is(parameters)); assertThat(instrumentationConfig.getAllInstrumentationPoints(), hasSize(2)); SensorInstrumentationPoint rsc = instrumentationConfig.getSensorInstrumentationPoint();
when(methodInstrumentationConfig.getTargetMethodName()).thenReturn("<init>"); when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getParameterTypes()).thenReturn(Collections.<String> emptyList()); when(methodInstrumentationConfig.getSensorInstrumentationPoint()).thenReturn(sensorInstrumentationPoint); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sensorInstrumentationPoint));
assertThat(instrumentationConfig.getTargetMethodName(), is(methodName)); assertThat(instrumentationConfig.getReturnType(), is(returnType)); assertThat(instrumentationConfig.getParameterTypes(), is(parameters)); assertThat(instrumentationConfig.getAllInstrumentationPoints(), hasSize(1)); assertThat(rsc.getId(), is(methodId));
when(methodInstrumentationConfig.getTargetMethodName()).thenReturn("<init>"); when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getParameterTypes()).thenReturn(Collections.<String> emptyList()); when(methodInstrumentationConfig.getSensorInstrumentationPoint()).thenReturn(sensorInstrumentationPoint); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sensorInstrumentationPoint));
/** * Copies all the class/method information from the {@link MethodInstrumentationConfig} to the * {@link AbstractSensorConfig}. * * @param asc * {@link AbstractSensorConfig} * @param config * {@link MethodInstrumentationConfig} */ private void copyInfo(AbstractSensorConfig asc, MethodInstrumentationConfig config) { asc.setTargetClassFqn(config.getTargetClassFqn()); asc.setTargetMethodName(config.getTargetMethodName()); asc.setReturnType(config.getReturnType()); asc.setParameterTypes(config.getParameterTypes()); }
assertThat(instrumentationConfig.getTargetMethodName(), is(methodName)); assertThat(instrumentationConfig.getReturnType(), is(returnType)); assertThat(instrumentationConfig.getParameterTypes(), is(parameters)); assertThat(instrumentationConfig.getAllInstrumentationPoints(), hasSize(2)); SensorInstrumentationPoint rsc = instrumentationConfig.getSensorInstrumentationPoint();
assertThat(instrumentationConfig.getTargetMethodName(), is(methodName)); assertThat(instrumentationConfig.getReturnType(), is(returnType)); assertThat(instrumentationConfig.getParameterTypes(), is(parameters)); assertThat(instrumentationConfig.getAllInstrumentationPoints(), hasSize(1)); assertThat(rsc.getId(), is(methodId));
assertThat(instrumentationConfig.getTargetMethodName(), is(methodName)); assertThat(instrumentationConfig.getReturnType(), is(returnType)); assertThat(instrumentationConfig.getParameterTypes(), is(parameters)); assertThat(instrumentationConfig.getAllInstrumentationPoints(), hasSize(1)); SpecialInstrumentationPoint ssc = instrumentationConfig.getSpecialInstrumentationPoint();
when(methodInstrumentationConfig.getTargetMethodName()).thenReturn("<init>"); when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getParameterTypes()).thenReturn(Collections.<String> emptyList()); when(methodInstrumentationConfig.getSensorInstrumentationPoint()).thenReturn(sensorInstrumentationPoint); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sensorInstrumentationPoint));