more fixes for tests
This commit is contained in:
parent
86be9db7b9
commit
10a559348b
|
@ -88,4 +88,34 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase<TemplateQue
|
|||
content.string());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRawEscapedTemplate() throws IOException {
|
||||
String expectedTemplateString = "{\"match_{{template}}\": {}}\"";
|
||||
String query = "{\"template\": {\"query\": \"{\\\"match_{{template}}\\\": {}}\\\"\",\"params\" : {\"template\" : \"all\"}}}";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("template", "all");
|
||||
QueryBuilder<?> expectedBuilder = new TemplateQueryBuilder(new Template(expectedTemplateString, ScriptType.INLINE, null, null,
|
||||
params));
|
||||
assertParsedQuery(query, expectedBuilder);
|
||||
}
|
||||
|
||||
// NORELEASE Can we actually test raw templates in either unit or
|
||||
// integration tests now?
|
||||
@Test
|
||||
@AwaitsFix(bugUrl = "Can we actually test raw templates in either unit or integration tests now?")
|
||||
public void testRawTemplate() throws IOException {
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.startObject("match_{{template}}");
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
String expectedTemplateString = "{\"match_{{template}}\": {}}";
|
||||
String query = "{\"template\": {\"query\": {\"match_{{template}}\": {}},\"params\" : {\"template\" : \"all\"}}}";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("template", "all");
|
||||
QueryBuilder<?> expectedBuilder = new TemplateQueryBuilder(new Template(expectedTemplateString, ScriptType.INLINE, null, null,
|
||||
params));
|
||||
assertParsedQuery(query, expectedBuilder);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,32 +136,14 @@ public class TemplateQueryIT extends ESIntegTestCase {
|
|||
assertHitCount(sr, 2);
|
||||
}
|
||||
|
||||
// NORELEASE These need to be tested in TemplateQueryBuilderTests
|
||||
// @Test
|
||||
// public void testRawEscapedTemplate() throws IOException {
|
||||
// String query =
|
||||
// "{\"template\": {\"query\": \"{\\\"match_{{template}}\\\": {}}\\\"\",\"params\" : {\"template\" : \"all\"}}}";
|
||||
//
|
||||
// SearchResponse sr = client().prepareSearch().setQuery(query).get();
|
||||
// assertHitCount(sr, 2);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testRawTemplate() throws IOException {
|
||||
// String query =
|
||||
// "{\"template\": {\"query\": {\"match_{{template}}\": {}},\"params\" : {\"template\" : \"all\"}}}";
|
||||
// SearchResponse sr = client().prepareSearch().setQuery(query).get();
|
||||
// assertHitCount(sr, 2);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testRawFSTemplate() throws IOException {
|
||||
// String query =
|
||||
// "{\"template\": {\"file\": \"storedTemplate\",\"params\" : {\"template\" : \"all\"}}}";
|
||||
//
|
||||
// SearchResponse sr = client().prepareSearch().setQuery(query).get();
|
||||
// assertHitCount(sr, 2);
|
||||
// }
|
||||
@Test
|
||||
public void testRawFSTemplate() throws IOException {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("template", "all");
|
||||
TemplateQueryBuilder builder = new TemplateQueryBuilder(new Template("storedTemplate", ScriptType.FILE, null, null, params));
|
||||
SearchResponse sr = client().prepareSearch().setQuery(builder).get();
|
||||
assertHitCount(sr, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchRequestTemplateSource() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue