SLING-10575: fill empty bundle to feature mappings
diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java b/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java
index 091450c..9cfc1f7 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java
@@ -90,7 +90,7 @@
                 {
                     features = new HashSet<>();
                 }
-                features.addAll(Arrays.asList(bundle.getFeatureOrigins()));
+                features.addAll(Arrays.asList(bundle.getFeatureOrigins(app.getId())));
                 return features;
             });
         }
diff --git a/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java b/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java
index 99cea3d..ba2a355 100644
--- a/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java
+++ b/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java
@@ -19,6 +19,9 @@
 import java.io.IOException;
 import java.util.Properties;
 
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.extension.apiregions.api.ApiRegions;
 import org.junit.Assert;
 import org.junit.Test;
@@ -61,4 +64,34 @@
         Assert.assertEquals("region3,region4", properties.getProperty("f:f2:1"));
         Assert.assertEquals("region1,region2,region3,region4,region5", properties.getProperty("__region.order__"));
     }
+
+    @Test
+    public void testGetBundleIDtoFeaturesMapWithOrigins() {
+        final ArtifactId featureId = ArtifactId.parse("g:f:1");
+        final ArtifactId artifactId = ArtifactId.parse("g:a:2");
+        final ArtifactId originId = ArtifactId.parse("g:o:5");
+
+        final Feature f = new Feature(featureId);
+        final Artifact a = new Artifact(artifactId);
+        a.setFeatureOrigins(originId);
+        f.getBundles().add(a);
+
+        final Properties prop = LauncherProperties.getBundleIDtoFeaturesMap(f);
+        Assert.assertEquals(1, prop.size());
+        Assert.assertEquals(originId.toMvnId(), prop.get(artifactId.toMvnId()));
+    }
+
+    @Test
+    public void testGetBundleIDtoFeaturesMapWithoutOrigins() {
+        final ArtifactId featureId = ArtifactId.parse("g:f:1");
+        final ArtifactId artifactId = ArtifactId.parse("g:a:2");
+
+        final Feature f = new Feature(featureId);
+        final Artifact a = new Artifact(artifactId);
+        f.getBundles().add(a);
+
+        final Properties prop = LauncherProperties.getBundleIDtoFeaturesMap(f);
+        Assert.assertEquals(1, prop.size());
+        Assert.assertEquals(featureId.toMvnId(), prop.get(artifactId.toMvnId()));
+    }
 }