[TEST] Fixes to failing watcher tests

Original commit: elastic/x-pack-elasticsearch@4d592b9c92
This commit is contained in:
Colin Goodheart-Smithe 2015-10-16 10:09:13 +01:00
parent 7a5fe13c34
commit acec3c9216
3 changed files with 14 additions and 10 deletions

View File

@ -177,10 +177,8 @@ public final class WatcherUtils {
}
indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandOpen, expandClosed, DEFAULT_INDICES_OPTIONS);
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, TEMPLATE_FIELD)) {
XContentBuilder builder = XContentBuilder.builder(parser.contentType().xContent());
builder.copyCurrentStructure(parser);
String templateBody = builder.string();
searchRequest.template(new Template(templateBody, ScriptType.INLINE, null, builder.contentType(), null));
Template template = Template.parse(parser, ParseFieldMatcher.STRICT);
searchRequest.template(template);
} else {
throw new ElasticsearchParseException("could not read search request. unexpected object field [" + currentFieldName + "]");
}

View File

@ -23,6 +23,7 @@ import org.elasticsearch.index.query.MatchAllQueryParser;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.script.Template;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESTestCase;
@ -32,7 +33,11 @@ import org.elasticsearch.watcher.support.text.TextTemplate;
import org.joda.time.DateTime;
import java.io.IOException;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
@ -117,12 +122,12 @@ public class WatcherUtilsTests extends ESTestCase {
}
}
String text = randomAsciiOfLengthBetween(1, 5);
TextTemplate template = randomFrom(
TextTemplate.inline(text).params(params).build(),
TextTemplate.file(text).params(params).build(),
TextTemplate.indexed(text).params(params).build()
Template template = randomFrom(
new Template(text, ScriptType.INLINE, null, null, params),
new Template(text, ScriptType.FILE, null, null, params),
new Template(text, ScriptType.INDEXED, null, null, params)
);
expectedRequest.template(new Template(template.getTemplate(), template.getType(), null, template.getContentType(), template.getParams()));
expectedRequest.template(template);
}
XContentBuilder builder = jsonBuilder();

View File

@ -159,6 +159,7 @@ public class SearchTransformTests extends ESIntegTestCase {
assertThat(resultData, equalTo(expectedData));
}
@AwaitsFix(bugUrl = "Need to find out a way of testing a bad query following the search request refactoring")
@Test
public void testExecute_Failure() throws Exception {