From d4a23c64c32392b2a3a5033460cbcfeb3dc99d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Osipiuk?= Date: Mon, 24 Jan 2022 09:21:17 +0100 Subject: [PATCH] Simplify extensability of BaseHiveConnectorTest --- .../java/io/trino/plugin/hive/BaseHiveConnectorTest.java | 7 ++----- .../hive/TestHiveFaultTolerantExecutionConnectorTest.java | 7 +++++-- .../hive/TestHivePipelinedExecutionConnectorTest.java | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index 94b31ed4263f..e576b13c6d1b 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -177,17 +177,14 @@ public abstract class BaseHiveConnectorTest private static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS"); private final String catalog; private final Session bucketedSession; - private final Map extraProperties; - protected BaseHiveConnectorTest(Map extraProperties) + protected BaseHiveConnectorTest() { this.catalog = HIVE_CATALOG; this.bucketedSession = createBucketedSession(Optional.of(new SelectedRole(ROLE, Optional.of("admin")))); - this.extraProperties = ImmutableMap.copyOf(requireNonNull(extraProperties, "extraProperties is null")); } - @Override - protected final QueryRunner createQueryRunner() + protected static QueryRunner createHiveQueryRunner(Map extraProperties) throws Exception { DistributedQueryRunner queryRunner = HiveQueryRunner.builder() diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveFaultTolerantExecutionConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveFaultTolerantExecutionConnectorTest.java index 668c78da3f5d..0468f3b0d7eb 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveFaultTolerantExecutionConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveFaultTolerantExecutionConnectorTest.java @@ -14,15 +14,18 @@ package io.trino.plugin.hive; import io.trino.testing.FaultTolerantExecutionConnectorTestHelper; +import io.trino.testing.QueryRunner; import static org.assertj.core.api.Assertions.assertThatThrownBy; public class TestHiveFaultTolerantExecutionConnectorTest extends BaseHiveConnectorTest { - public TestHiveFaultTolerantExecutionConnectorTest() + @Override + protected QueryRunner createQueryRunner() + throws Exception { - super(FaultTolerantExecutionConnectorTestHelper.getExtraProperties()); + return BaseHiveConnectorTest.createHiveQueryRunner(FaultTolerantExecutionConnectorTestHelper.getExtraProperties()); } @Override diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHivePipelinedExecutionConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHivePipelinedExecutionConnectorTest.java index c91071a260c1..c379f9cd3804 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHivePipelinedExecutionConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHivePipelinedExecutionConnectorTest.java @@ -14,12 +14,15 @@ package io.trino.plugin.hive; import com.google.common.collect.ImmutableMap; +import io.trino.testing.QueryRunner; public class TestHivePipelinedExecutionConnectorTest extends BaseHiveConnectorTest { - public TestHivePipelinedExecutionConnectorTest() + @Override + protected QueryRunner createQueryRunner() + throws Exception { - super(ImmutableMap.of()); + return BaseHiveConnectorTest.createHiveQueryRunner(ImmutableMap.of()); } }