diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java index 91f673bea..1639488c3 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java @@ -295,10 +295,29 @@ public class MongoPersistentEntityIndexResolverUnitTests { assertThat(indexDefinition.getIndexKeys(), equalTo(new BasicDBObjectBuilder().add("foo", 1).add("bar", -1).get())); } + /** + * @see DATAMONGO-909 + */ + @Test + public void compoundIndexOnSuperClassResolvedCorrectly() { + + List indexDefinitions = prepareMappingContextAndResolveIndexForType(IndexDefinedOnSuperClass.class); + + IndexDefinition indexDefinition = indexDefinitions.get(0).getIndexDefinition(); + assertThat(indexDefinition.getIndexOptions(), + equalTo(new BasicDBObjectBuilder().add("name", "compound_index").add("unique", true).add("dropDups", true) + .add("sparse", true).add("background", true).add("expireAfterSeconds", 10L).get())); + assertThat(indexDefinition.getIndexKeys(), equalTo(new BasicDBObjectBuilder().add("foo", 1).add("bar", -1).get())); + } + @Document(collection = "CompoundIndexOnLevelZero") @CompoundIndexes({ @CompoundIndex(name = "compound_index", def = "{'foo': 1, 'bar': -1}", background = true, dropDups = true, expireAfterSeconds = 10, sparse = true, unique = true) }) static class CompoundIndexOnLevelZero {} + + static class IndexDefinedOnSuperClass extends CompoundIndexOnLevelZero { + + } } public static class MixedIndexResolutionTests {