use of org.springframework.data.util.Version in project spring-data-mongodb by spring-projects.
the class MongoVersionRule method apply.
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (!getCurrentVersion().equals(ANY)) {
Version minVersion = MongoVersionRule.this.minVersion.equals(ANY) ? DEFAULT_LOW : MongoVersionRule.this.minVersion;
Version maxVersion = MongoVersionRule.this.maxVersion.equals(ANY) ? DEFAULT_HIGH : MongoVersionRule.this.maxVersion;
if (MongoVersionRule.this.minVersion.equals(ANY) && MongoVersionRule.this.maxVersion.equals(ANY)) {
MongoVersion version = description.getAnnotation(MongoVersion.class);
if (version != null) {
minVersion = Version.parse(version.asOf());
maxVersion = Version.parse(version.until());
}
}
validateVersion(minVersion, maxVersion);
}
base.evaluate();
}
};
}
use of org.springframework.data.util.Version in project spring-data-mongodb by spring-projects.
the class DefaultReactiveIndexOperationsTests method shouldCreateIndexWithCollationCorrectly.
// DATAMONGO-1518
@Test
public void shouldCreateIndexWithCollationCorrectly() {
assumeTrue(mongoVersion.isGreaterThanOrEqualTo(THREE_DOT_FOUR));
IndexDefinition id = new Index().named("with-collation").on("xyz", Direction.ASC).collation(Collation.of("de_AT").caseFirst(CaseFirst.off()));
StepVerifier.create(indexOps.ensureIndex(id)).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);
//
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("with-collation"))).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