use of org.opensearch.test.VersionUtils.randomVersion in project OpenSearch by opensearch-project.
the class PreBuiltAnalyzerTests method testThatInstancesAreCachedAndReused.
public void testThatInstancesAreCachedAndReused() {
assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT), PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT));
// same opensearch version should be cached
Version v = VersionUtils.randomVersion(random());
assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(v), PreBuiltAnalyzers.STANDARD.getAnalyzer(v));
assertNotSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT), PreBuiltAnalyzers.STANDARD.getAnalyzer(VersionUtils.randomPreviousCompatibleVersion(random(), Version.CURRENT)));
// Same Lucene version should be cached:
assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(LegacyESVersion.fromId(6020199)), PreBuiltAnalyzers.STOP.getAnalyzer(LegacyESVersion.fromId(6020299)));
}
use of org.opensearch.test.VersionUtils.randomVersion in project OpenSearch by opensearch-project.
the class VersionTests method testMin.
public void testMin() {
assertEquals(VersionUtils.getPreviousVersion(), Version.min(Version.CURRENT, VersionUtils.getPreviousVersion()));
assertEquals(LegacyESVersion.fromString("7.0.1"), Version.min(LegacyESVersion.fromString("7.0.1"), Version.CURRENT));
Version version = VersionUtils.randomVersion(random());
Version version1 = VersionUtils.randomVersion(random());
if (version.id <= version1.id) {
assertEquals(version, Version.min(version1, version));
} else {
assertEquals(version1, Version.min(version1, version));
}
}
use of org.opensearch.test.VersionUtils.randomVersion in project OpenSearch by opensearch-project.
the class VersionTests method testMax.
public void testMax() {
assertEquals(Version.CURRENT, Version.max(Version.CURRENT, VersionUtils.getPreviousVersion()));
assertEquals(Version.CURRENT, Version.max(Version.fromString("1.0.1"), Version.CURRENT));
Version version = VersionUtils.randomVersion(random());
Version version1 = VersionUtils.randomVersion(random());
if (version.id >= version1.id) {
assertEquals(version, Version.max(version1, version));
} else {
assertEquals(version1, Version.max(version1, version));
}
}
Aggregations