### Question:
KarafCapabilityProvider extends ServiceTracker<FeaturesService, FeaturesService> implements ICapabilityProvider,
    FeaturesListener { @Override public Set<ICapability> getAllCapabilities() { Set<ICapability> capabilities = new HashSet<ICapability>(); try { for ( Feature feature : featuresService.listFeatures() ) { ICapability capabilityById = this.getCapabilityById( feature.getName() ); if ( capabilityById != null ) { capabilities.add( capabilityById ); } } } catch ( Exception e ) { logger.error( "Unknown error trying to retrieve available Karaf features", e ); return capabilities; } return capabilities; } KarafCapabilityProvider( BundleContext bundleContext ); @Override FeaturesService addingService( ServiceReference<FeaturesService> reference ); @Override String getId(); @Override Set<String> listCapabilities(); @Override ICapability getCapabilityById( String id ); @Override boolean capabilityExist( String id ); @Override Set<ICapability> getAllCapabilities(); void watchForInstall( Feature feature, SettableFuture<Boolean> future ); void watchForUnInstall( Feature feature, SettableFuture<Boolean> uninstallFuture ); @Override void featureEvent( FeatureEvent featureEvent ); @Override void repositoryEvent( RepositoryEvent repositoryEvent ); static final String KARAF; }### Answer:
@Test public void testGetAllCapabilities() throws Exception { ServiceReference serviceReference = mock( ServiceReference.class ); karafCapabilityProvider = new KarafCapabilityProvider( bundleContext ); karafCapabilityProvider.addingService( serviceReference ); Set<ICapability> capabilities = karafCapabilityProvider.getAllCapabilities(); assertNotNull( capabilities ); assert( capabilities.size() > 0); assert( capabilities.iterator().next().getClass().equals( KarafCapability.class ) ); }