From d49f099fdb7c2568c3adc8a212e0ef92f5b953cc Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 22 Jan 2014 11:25:36 +0100 Subject: [PATCH] Added tests that ensures all version are in the Version#fromId(int) switch statement --- src/test/java/org/elasticsearch/VersionTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/org/elasticsearch/VersionTests.java b/src/test/java/org/elasticsearch/VersionTests.java index de377aa3532..5ed9143ce2e 100644 --- a/src/test/java/org/elasticsearch/VersionTests.java +++ b/src/test/java/org/elasticsearch/VersionTests.java @@ -24,8 +24,10 @@ import org.junit.Test; import static org.elasticsearch.Version.V_0_20_0; import static org.elasticsearch.Version.V_0_90_0; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; public class VersionTests extends ElasticsearchTestCase { @@ -48,4 +50,16 @@ public class VersionTests extends ElasticsearchTestCase { assertThat(V_0_90_0.onOrAfter(V_0_20_0), is(true)); } + @Test + public void testVersionConstantPresent() { + assertThat(Version.CURRENT, sameInstance(Version.fromId(Version.CURRENT.id))); + assertThat(Version.CURRENT.luceneVersion.ordinal(), equalTo(org.apache.lucene.util.Version.LUCENE_CURRENT.ordinal() - 1)); + final int iters = atLeast(20); + for (int i = 0; i < iters; i++) { + Version version = randomVersion(); + assertThat(version, sameInstance(Version.fromId(version.id))); + assertThat(version.luceneVersion, sameInstance(Version.fromId(version.id).luceneVersion)); + } + } + } \ No newline at end of file