use of org.springframework.data.mongodb.core.query.Collation.CaseFirst in project spring-data-mongodb by spring-projects.
the class DefaultReactiveIndexOperationsTests method shouldCreateIndexWithCollationCorrectly.
// DATAMONGO-1518
@Test
public void shouldCreateIndexWithCollationCorrectly() {
IndexDefinition id = new Index().named("with-collation").on("xyz", Direction.ASC).collation(Collation.of("de_AT").caseFirst(CaseFirst.off()));
indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
Document expected = //
new Document("locale", "de_AT").append("caseLevel", //
false).append("caseFirst", //
"off").append("strength", //
3).append("numericOrdering", //
false).append("alternate", //
"non-ignorable").append("maxVariable", //
"punct").append("normalization", //
false).append("backwards", false);
//
indexOps.getIndexInfo().filter(this.indexByName("with-collation")).as(StepVerifier::create).consumeNextWith(indexInfo -> {
assertThat(indexInfo.getCollation()).isPresent();
// version is set by MongoDB server - we remove it to avoid errors when upgrading server version.
Document result = indexInfo.getCollation().get();
result.remove("version");
assertThat(result).isEqualTo(expected);
}).verifyComplete();
}
Aggregations