Fixes CompletionSuggesterBuilderTests to test for the correct expected

error message.
This commit is contained in:
Ali Beyad 2016-03-10 10:39:46 -05:00
parent 807d085218
commit 5a8d40e44a
1 changed files with 8 additions and 3 deletions

View File

@ -20,6 +20,7 @@
package org.elasticsearch.search.suggest.completion; package org.elasticsearch.search.suggest.completion;
import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MappedFieldType;
@ -51,6 +52,10 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe
@Override @Override
protected CompletionSuggestionBuilder randomSuggestionBuilder() { protected CompletionSuggestionBuilder randomSuggestionBuilder() {
return randomCompletionSuggestionBuilder();
}
public static CompletionSuggestionBuilder randomCompletionSuggestionBuilder() {
return randomSuggestionBuilderWithContextInfo().builder; return randomSuggestionBuilderWithContextInfo().builder;
} }
@ -60,7 +65,7 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe
List<String> geoContexts = new ArrayList<>(); List<String> geoContexts = new ArrayList<>();
} }
private BuilderAndInfo randomSuggestionBuilderWithContextInfo() { private static BuilderAndInfo randomSuggestionBuilderWithContextInfo() {
final BuilderAndInfo builderAndInfo = new BuilderAndInfo(); final BuilderAndInfo builderAndInfo = new BuilderAndInfo();
CompletionSuggestionBuilder testBuilder = new CompletionSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); CompletionSuggestionBuilder testBuilder = new CompletionSuggestionBuilder(randomAsciiOfLengthBetween(2, 20));
setCommonPropertiesOnRandomBuilder(testBuilder); setCommonPropertiesOnRandomBuilder(testBuilder);
@ -190,8 +195,8 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe
try { try {
final SuggestBuilder suggestBuilder = SuggestBuilder.fromXContent(newParseContext(payload), suggesters); final SuggestBuilder suggestBuilder = SuggestBuilder.fromXContent(newParseContext(payload), suggesters);
fail("Should not have been able to create SuggestBuilder from malformed JSON: " + suggestBuilder); fail("Should not have been able to create SuggestBuilder from malformed JSON: " + suggestBuilder);
} catch (IllegalArgumentException e) { } catch (ParsingException e) {
assertThat(e.getMessage(), containsString("parsing failed")); assertThat(e.getMessage(), containsString("failed to parse field [payload]"));
} }
} }
} }