### Question:
PdiPluginSupplementalClassMappingsTrackerForPluginRegistry extends ServiceTracker<PdiPluginSupplementalClassMappings, PdiPluginSupplementalClassMappings> { @Override public PdiPluginSupplementalClassMappings addingService( ServiceReference<PdiPluginSupplementalClassMappings> reference ) { PdiPluginSupplementalClassMappings pdiPluginSupplementalClassMappings = super.addingService( reference ); pdiPluginSupplementalClassMappings.getClassToBeanNameMap().forEach( ( Class aClass, String s ) -> { BlueprintBeanFactory blueprintBeanFactory = new BlueprintBeanFactory( s, pdiPluginSupplementalClassMappings.getContainer() ); try { getPluginRegistry() .addClassFactory( (Class) reference.getProperty( "type" ), aClass, (String) reference.getProperty( "id" ), () -> blueprintBeanFactory.create( aClass ) ); } catch ( KettlePluginException e ) { logger.error( "Unexpected error registering supplemental plugin mapping", e ); } } ); return pdiPluginSupplementalClassMappings; } PdiPluginSupplementalClassMappingsTrackerForPluginRegistry( BundleContext bundleContext ); @Override PdiPluginSupplementalClassMappings addingService(
    ServiceReference<PdiPluginSupplementalClassMappings> reference ); @Override void removedService( ServiceReference<PdiPluginSupplementalClassMappings> reference,
                                        PdiPluginSupplementalClassMappings service );  }### Answer:
@Test public void addingService() throws Exception { PluginRegistry registry = mock( PluginRegistry.class ); BundleContext bundleContext = mock( BundleContext.class ); PdiPluginSupplementalClassMappingsTrackerForPluginRegistry tracker = new PdiPluginSupplementalClassMappingsTrackerForPluginRegistry( bundleContext ); tracker.setPluginRegistry( registry ); ServiceReference<PdiPluginSupplementalClassMappings> mappingsServiceReference = mock( ServiceReference.class ); when( mappingsServiceReference.getProperty( "type" ) ).thenReturn( LoggingPluginType.class ); when( mappingsServiceReference.getProperty( "id" ) ).thenReturn( "plugin-id" ); PdiPluginSupplementalClassMappings mappings = mock( PdiPluginSupplementalClassMappings.class ); when( bundleContext.getService( mappingsServiceReference ) ).thenReturn( mappings ); when( mappings.getClassToBeanNameMap() ).thenReturn( Collections.singletonMap( String.class, "FooID" ) ); when( mappings.getContainer() ).thenReturn( mock( BlueprintContainer.class ) ); tracker.addingService( mappingsServiceReference ); verify( registry, times( 1 ) ) .addClassFactory( eq( LoggingPluginType.class ), eq( String.class ), eq( "plugin-id" ), any() ); }