|
61 | 61 | * @author Christoph Strobl
|
62 | 62 | * @author Mark Paluch
|
63 | 63 | * @author Dave Perryman
|
| 64 | + * @author Stefan Tirea |
64 | 65 | */
|
65 | 66 | @RunWith(Suite.class)
|
66 | 67 | @SuiteClasses({ IndexResolutionTests.class, GeoSpatialIndexResolutionTests.class, CompoundIndexResolutionTests.class,
|
@@ -699,6 +700,19 @@ public void singleIndexWithPartialFilter() {
|
699 | 700 | org.bson.Document.parse("{'value': {'$exists': true}}"));
|
700 | 701 | }
|
701 | 702 |
|
| 703 | + @Test // DATAMONGO-2133 |
| 704 | + public void compoundIndexWithCollation() { |
| 705 | + |
| 706 | + List<IndexDefinitionHolder> indexDefinitions = prepareMappingContextAndResolveIndexForType( |
| 707 | + CompoundIndexWithCollation.class); |
| 708 | + |
| 709 | + IndexDefinition indexDefinition = indexDefinitions.get(0).getIndexDefinition(); |
| 710 | + assertThat(indexDefinition.getIndexOptions()) |
| 711 | + .isEqualTo(new org.bson.Document().append("name", "compound_index_with_collation").append("collation", |
| 712 | + new org.bson.Document().append("locale", "en_US").append("strength", 2))); |
| 713 | + assertThat(indexDefinition.getIndexKeys()).isEqualTo(new org.bson.Document().append("foo", 1)); |
| 714 | + } |
| 715 | + |
702 | 716 | @Document("CompoundIndexOnLevelOne")
|
703 | 717 | class CompoundIndexOnLevelOne {
|
704 | 718 |
|
@@ -774,6 +788,11 @@ class RepeatedCompoundIndex {}
|
774 | 788 | @CompoundIndex(name = "compound_index_with_partial", def = "{'foo': 1, 'bar': -1}", background = true,
|
775 | 789 | unique = true, partialFilter = "{'value': {'$exists': true}}")
|
776 | 790 | class SingleCompoundIndexWithPartialFilter {}
|
| 791 | + |
| 792 | + @Document |
| 793 | + @CompoundIndex(name = "compound_index_with_collation", def = "{'foo': 1}", |
| 794 | + collation = "{'locale': 'en_US', 'strength': 2}") |
| 795 | + class CompoundIndexWithCollation {} |
777 | 796 | }
|
778 | 797 |
|
779 | 798 | public static class TextIndexedResolutionTests {
|
@@ -1400,6 +1419,18 @@ public void shouldSkipMapStructuresUnlessAnnotatedWithWildcardIndex() {
|
1400 | 1419 | assertThat(indexDefinitions).hasSize(1);
|
1401 | 1420 | }
|
1402 | 1421 |
|
| 1422 | + @Test // DATAMONGO-2133 |
| 1423 | + public void indexedWithCollation() { |
| 1424 | + |
| 1425 | + List<IndexDefinitionHolder> indexDefinitions = prepareMappingContextAndResolveIndexForType( |
| 1426 | + IndexedWithCollation.class); |
| 1427 | + |
| 1428 | + IndexDefinition indexDefinition = indexDefinitions.get(0).getIndexDefinition(); |
| 1429 | + assertThat(indexDefinition.getIndexOptions()).isEqualTo(new org.bson.Document().append("name", "value") |
| 1430 | + .append("unique", true) |
| 1431 | + .append("collation", new org.bson.Document().append("locale", "en_US").append("strength", 2))); |
| 1432 | + } |
| 1433 | + |
1403 | 1434 | @Document
|
1404 | 1435 | class MixedIndexRoot {
|
1405 | 1436 |
|
@@ -1717,6 +1748,12 @@ class WithComposedHashedIndexAndIndex {
|
1717 | 1748 | @ComposedHashIndexed(name = "idx-name") String value;
|
1718 | 1749 | }
|
1719 | 1750 |
|
| 1751 | + @Document |
| 1752 | + class IndexedWithCollation { |
| 1753 | + @Indexed(collation = "{'locale': 'en_US', 'strength': 2}", unique = true) // |
| 1754 | + private String value; |
| 1755 | + } |
| 1756 | + |
1720 | 1757 | @HashIndexed
|
1721 | 1758 | @Indexed
|
1722 | 1759 | @Retention(RetentionPolicy.RUNTIME)
|
|
0 commit comments