From ce0ab79155f580844c9b317ecb7c722aac21015b Mon Sep 17 00:00:00 2001 From: Britta Weber Date: Fri, 4 Oct 2013 14:31:53 +0200 Subject: [PATCH] move tests to unit test --- .../termvectors/GetTermVectorTests.java | 35 ------------------ .../termvectors/TermVectorUnitTests.java | 36 ++++++++++++++++++- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java b/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java index 342e3b5769b..125c8f9af28 100644 --- a/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java +++ b/src/test/java/org/elasticsearch/termvectors/GetTermVectorTests.java @@ -30,10 +30,7 @@ import org.elasticsearch.action.termvector.TermVectorResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; -import org.elasticsearch.index.mapper.core.TypeParsers; -import org.elasticsearch.index.mapper.internal.AllFieldMapper; import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; import org.hamcrest.Matchers; import org.junit.Test; @@ -379,36 +376,4 @@ public class GetTermVectorTests extends AbstractTermVectorTests { } } } - - @Test - public void testFieldTypeToTermVectorString() throws Exception { - FieldType ft = new FieldType(); - ft.setStoreTermVectorOffsets(false); - ft.setStoreTermVectorPayloads(true); - ft.setStoreTermVectors(true); - ft.setStoreTermVectorPositions(true); - String ftOpts = AbstractFieldMapper.termVectorOptionsToString(ft); - assertThat("with_positions_payloads", equalTo(ftOpts)); - AllFieldMapper.Builder builder = new AllFieldMapper.Builder(); - boolean excptiontrown = false; - try { - TypeParsers.parseTermVector("", ftOpts, builder); - } catch (MapperParsingException e) { - excptiontrown = true; - } - assertThat("TypeParsers.parseTermVector should accept string with_positions_payloads but does not.", excptiontrown, equalTo(false)); - - } - - @Test - public void testTermVectorStringGenerationIllegalState() throws Exception { - FieldType ft = new FieldType(); - ft.setStoreTermVectorOffsets(true); - ft.setStoreTermVectorPayloads(true); - ft.setStoreTermVectors(true); - ft.setStoreTermVectorPositions(false); - String ftOpts = AbstractFieldMapper.termVectorOptionsToString(ft); - assertThat(ftOpts, equalTo("with_offsets")); - } - } diff --git a/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java b/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java index 3f762c2b0c7..b87c8b3f6c3 100644 --- a/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java +++ b/src/test/java/org/elasticsearch/termvectors/TermVectorUnitTests.java @@ -38,6 +38,10 @@ import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.mapper.MapperParsingException; +import org.elasticsearch.index.mapper.core.AbstractFieldMapper; +import org.elasticsearch.index.mapper.core.TypeParsers; +import org.elasticsearch.index.mapper.internal.AllFieldMapper; import org.elasticsearch.rest.action.termvector.RestTermVectorAction; import org.elasticsearch.test.ElasticsearchLuceneTestCase; import org.hamcrest.Matchers; @@ -253,6 +257,36 @@ public class TermVectorUnitTests extends ElasticsearchLuceneTestCase { assertThat(request.routing(), equalTo(parent)); } - } + + @Test + public void testFieldTypeToTermVectorString() throws Exception { + FieldType ft = new FieldType(); + ft.setStoreTermVectorOffsets(false); + ft.setStoreTermVectorPayloads(true); + ft.setStoreTermVectors(true); + ft.setStoreTermVectorPositions(true); + String ftOpts = AbstractFieldMapper.termVectorOptionsToString(ft); + assertThat("with_positions_payloads", equalTo(ftOpts)); + AllFieldMapper.Builder builder = new AllFieldMapper.Builder(); + boolean exceptiontrown = false; + try { + TypeParsers.parseTermVector("", ftOpts, builder); + } catch (MapperParsingException e) { + exceptiontrown = true; + } + assertThat("TypeParsers.parseTermVector should accept string with_positions_payloads but does not.", exceptiontrown, equalTo(false)); + } + + @Test + public void testTermVectorStringGenerationWithoutPositions() throws Exception { + FieldType ft = new FieldType(); + ft.setStoreTermVectorOffsets(true); + ft.setStoreTermVectorPayloads(true); + ft.setStoreTermVectors(true); + ft.setStoreTermVectorPositions(false); + String ftOpts = AbstractFieldMapper.termVectorOptionsToString(ft); + assertThat(ftOpts, equalTo("with_offsets")); + } + }