### Question:
KarafFeatureWatcherImpl implements IKarafFeatureWatcher { protected List<String> getFeatures( String configPersistentId, String featuresPropertyKey ) throws IOException { Configuration configuration = this.getConfigurationAdmin().getConfiguration( configPersistentId ); Dictionary<String, Object> properties = configuration.getProperties(); if ( properties == null ) { return Collections.emptyList(); } String featuresPropertyValue = (String) properties.get( featuresPropertyKey ); if ( featuresPropertyValue == null ) { return Collections.emptyList(); } featuresPropertyValue = featuresPropertyValue.replaceAll( "[()]", "" ); if ( featuresPropertyValue.length() == 0 ) { return Collections.emptyList(); } String[] featuresArray = featuresPropertyValue.split( "," ); return Arrays.asList( featuresArray ); } KarafFeatureWatcherImpl( BundleContext bundleContext ); @Override void waitForFeatures();  }### Answer:
@Test public void testGetFeaturesNoFeatures() throws Exception { String featuresPropertyValue = ""; String featuresPropertyKey = "featuresBoot"; String configurationPid = "org.apache.features"; KarafFeatureWatcherImpl karafFeatureWatcherImpl = this.createKarafFeatureWatcherImplWithConfig( configurationPid, featuresPropertyKey, featuresPropertyValue ); List<String> actualFeatures = karafFeatureWatcherImpl.getFeatures( configurationPid, featuresPropertyKey ); assertThat( actualFeatures, is( empty() ) ); }
@Test public void testGetFeaturesWithParentesisStages() throws Exception { String featuresPropertyValue = "feature1,(feature2,feature3),feature4"; String featuresPropertyKey = "featuresBoot"; String configurationPid = "org.apache.features"; KarafFeatureWatcherImpl karafFeatureWatcherImpl = this.createKarafFeatureWatcherImplWithConfig( configurationPid, featuresPropertyKey, featuresPropertyValue ); List<String> actualFeatures = karafFeatureWatcherImpl.getFeatures( configurationPid, featuresPropertyKey ); List<String> expectedFeatures = Arrays.asList( "feature1", "feature2", "feature3", "feature4" ); assertEquals( expectedFeatures, actualFeatures ); }
@Test public void testGetFeaturesNoParentesisStages() throws Exception { String featuresPropertyValue = "feature1,feature2,feature3,feature4"; String featuresPropertyKey = "featuresBoot"; String configurationPid = "org.apache.features"; KarafFeatureWatcherImpl karafFeatureWatcherImpl = this.createKarafFeatureWatcherImplWithConfig( configurationPid, featuresPropertyKey, featuresPropertyValue ); List<String> actualFeatures = karafFeatureWatcherImpl.getFeatures( configurationPid, featuresPropertyKey ); List<String> expectedFeatures = Arrays.asList( "feature1", "feature2", "feature3", "feature4" ); Assert.assertEquals( expectedFeatures, actualFeatures ); }