From 5a8d40e44a142eb8f6050914f75e1950ae12fe18 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Thu, 10 Mar 2016 10:39:46 -0500 Subject: [PATCH] Fixes CompletionSuggesterBuilderTests to test for the correct expected error message. --- .../completion/CompletionSuggesterBuilderTests.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java index 2126e6d1c81..9f854150ed4 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.suggest.completion; import com.carrotsearch.randomizedtesting.generators.RandomStrings; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.index.mapper.MappedFieldType; @@ -51,6 +52,10 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe @Override protected CompletionSuggestionBuilder randomSuggestionBuilder() { + return randomCompletionSuggestionBuilder(); + } + + public static CompletionSuggestionBuilder randomCompletionSuggestionBuilder() { return randomSuggestionBuilderWithContextInfo().builder; } @@ -60,7 +65,7 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe List geoContexts = new ArrayList<>(); } - private BuilderAndInfo randomSuggestionBuilderWithContextInfo() { + private static BuilderAndInfo randomSuggestionBuilderWithContextInfo() { final BuilderAndInfo builderAndInfo = new BuilderAndInfo(); CompletionSuggestionBuilder testBuilder = new CompletionSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); setCommonPropertiesOnRandomBuilder(testBuilder); @@ -190,8 +195,8 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe try { final SuggestBuilder suggestBuilder = SuggestBuilder.fromXContent(newParseContext(payload), suggesters); fail("Should not have been able to create SuggestBuilder from malformed JSON: " + suggestBuilder); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), containsString("parsing failed")); + } catch (ParsingException e) { + assertThat(e.getMessage(), containsString("failed to parse field [payload]")); } } }