/** * Creates method instrumentation configuration for the given {@link MethodType} or returns * existing one. * * @param methodType * {@link MethodType} to get {@link MethodInstrumentationConfig} for. * @return Existing or new {@link MethodInstrumentationConfig}. */ private MethodInstrumentationConfig getOrCreateMethodInstrumentationConfig(MethodType methodType) { // check for existing MethodInstrumentationConfig methodInstrumentationConfig = methodType.getMethodInstrumentationConfig(); // if not create new one if (null == methodInstrumentationConfig) { methodInstrumentationConfig = new MethodInstrumentationConfig(methodType); methodType.setMethodInstrumentationConfig(methodInstrumentationConfig); } return methodInstrumentationConfig; }
@Test public void hasInstrumentationPoints() { String fqn1 = "fqn1"; test = new ClassType(fqn1); MethodInstrumentationConfig config = new MethodInstrumentationConfig(); MethodType m = new MethodType(); m.setMethodInstrumentationConfig(config); test.addMethod(m); Collection<MethodInstrumentationConfig> instrumentationPoints = test.getInstrumentationPoints(); assertThat(instrumentationPoints, hasSize(1)); assertThat(instrumentationPoints, hasItem(config)); } }
@Test public void hasInstrumentationPoints() { String fqn1 = "fqn1"; test = new ClassType(fqn1); MethodInstrumentationConfig config = new MethodInstrumentationConfig(); MethodType m = new MethodType(); m.setMethodInstrumentationConfig(config); test.addMethod(m); boolean hasInstrumentationPoints = test.hasInstrumentationPoints(); assertThat(hasInstrumentationPoints, is(true)); } }
@Test public void equalsContract() { MethodInstrumentationConfig c1 = new MethodInstrumentationConfig(); c1.setTargetClassFqn("c1"); MethodInstrumentationConfig c2 = new MethodInstrumentationConfig(); c2.setTargetClassFqn("c2"); EqualsVerifier.forClass(MethodType.class).usingGetClass().withPrefabValues(MethodInstrumentationConfig.class, c1, c2).suppress(Warning.NONFINAL_FIELDS).verify(); }