From 47f9c4caaea5e4acbe351535564687e8b40fbad0 Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Tue, 30 Oct 2018 22:31:29 +0100 Subject: [PATCH] SQL: [tests] Remove AbstractBuilderTestCase dep (#35099) Extend directly from `EsTestCase` to speed up execution. Fixes: #35098 --- .../xpack/sql/planner/QueryFolderTests.java | 4 ++-- .../xpack/sql/planner/QueryTranslatorTests.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryFolderTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryFolderTests.java index 94d03845395d0..77606ab1390dd 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryFolderTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryFolderTests.java @@ -5,7 +5,7 @@ */ package org.elasticsearch.xpack.sql.planner; -import org.elasticsearch.test.AbstractBuilderTestCase; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.sql.analysis.analyzer.Analyzer; import org.elasticsearch.xpack.sql.analysis.index.EsIndex; import org.elasticsearch.xpack.sql.analysis.index.IndexResolution; @@ -26,7 +26,7 @@ import static org.hamcrest.Matchers.startsWith; -public class QueryFolderTests extends AbstractBuilderTestCase { +public class QueryFolderTests extends ESTestCase { private static SqlParser parser; private static Analyzer analyzer; diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java index c1e5a0d2dafad..b0a15f22226ea 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/planner/QueryTranslatorTests.java @@ -5,7 +5,7 @@ */ package org.elasticsearch.xpack.sql.planner; -import org.elasticsearch.test.AbstractBuilderTestCase; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.sql.SqlIllegalArgumentException; import org.elasticsearch.xpack.sql.analysis.analyzer.Analyzer; import org.elasticsearch.xpack.sql.analysis.index.EsIndex; @@ -29,13 +29,12 @@ import org.junit.AfterClass; import org.junit.BeforeClass; -import java.io.IOException; import java.util.Map; import java.util.TimeZone; import static org.hamcrest.core.StringStartsWith.startsWith; -public class QueryTranslatorTests extends AbstractBuilderTestCase { +public class QueryTranslatorTests extends ESTestCase { private static SqlParser parser; private static Analyzer analyzer; @@ -160,7 +159,7 @@ public void testLikeConstructsNotSupported() { assertEquals("Scalar function (LTRIM(keyword)) not allowed (yet) as arguments for LIKE", ex.getMessage()); } - public void testTranslateInExpression_WhereClause() throws IOException { + public void testTranslateInExpression_WhereClause() { LogicalPlan p = plan("SELECT * FROM test WHERE keyword IN ('foo', 'bar', 'lala', 'foo', concat('la', 'la'))"); assertTrue(p instanceof Project); assertTrue(p.children().get(0) instanceof Filter); @@ -170,10 +169,11 @@ public void testTranslateInExpression_WhereClause() throws IOException { Query query = translation.query; assertTrue(query instanceof TermsQuery); TermsQuery tq = (TermsQuery) query; - assertEquals("keyword:(bar foo lala)", tq.asBuilder().toQuery(createShardContext()).toString()); + assertEquals("{\"terms\":{\"keyword\":[\"foo\",\"bar\",\"lala\"],\"boost\":1.0}}", + tq.asBuilder().toString().replaceAll("\\s", "")); } - public void testTranslateInExpression_WhereClauseAndNullHandling() throws IOException { + public void testTranslateInExpression_WhereClauseAndNullHandling() { LogicalPlan p = plan("SELECT * FROM test WHERE keyword IN ('foo', null, 'lala', null, 'foo', concat('la', 'la'))"); assertTrue(p instanceof Project); assertTrue(p.children().get(0) instanceof Filter); @@ -183,7 +183,8 @@ public void testTranslateInExpression_WhereClauseAndNullHandling() throws IOExce Query query = translation.query; assertTrue(query instanceof TermsQuery); TermsQuery tq = (TermsQuery) query; - assertEquals("keyword:(foo lala)", tq.asBuilder().toQuery(createShardContext()).toString()); + assertEquals("{\"terms\":{\"keyword\":[\"foo\",\"lala\"],\"boost\":1.0}}", + tq.asBuilder().toString().replaceAll("\\s", "")); } public void testTranslateInExpressionInvalidValues_WhereClause() {