ConsumerConstructorInterceptor implements InstanceConstructorInterceptor { @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { PulsarClientImpl pulsarClient = (PulsarClientImpl) allArguments[0]; String topic = (String) allArguments[1]; ConsumerConfigurationData consumerConfigurationData = (ConsumerConfigurationData) allArguments[2]; ConsumerEnhanceRequiredInfo requireInfo = new ConsumerEnhanceRequiredInfo(); requireInfo.setServiceUrl(pulsarClient.getLookup().getServiceUrl()); requireInfo.setTopic(topic); requireInfo.setSubscriptionName(consumerConfigurationData.getSubscriptionName()); objInst.setSkyWalkingDynamicField(requireInfo); }  @Override void onConstruct(EnhancedInstance objInst, Object[] allArguments);  }
@Test public void testOnConsumer() { constructorInterceptor.onConstruct(enhancedInstance, new Object[] { pulsarClient, TOPIC_NAME, consumerConfigurationData }); ConsumerEnhanceRequiredInfo requiredInfo = (ConsumerEnhanceRequiredInfo) enhancedInstance.getSkyWalkingDynamicField(); assertThat(requiredInfo.getServiceUrl(), is(SERVICE_URL)); assertThat(requiredInfo.getTopic(), is(TOPIC_NAME)); assertThat(requiredInfo.getSubscriptionName(), is(SUBSCRIPTION_NAME)); }