/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.trino.plugin.kudu;

import org.testng.annotations.Test;

import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

public abstract class AbstractKuduWithDisabledInferSchemaConnectorTest
        extends AbstractKuduConnectorTest
{
    @Override
    protected Optional<String> getKuduSchemaEmulationPrefix()
    {
        return Optional.empty();
    }

    @Test
    public void testListingOfTableForDefaultSchema()
    {
        assertQuery("SHOW TABLES FROM default", "VALUES ('customer'), ('nation'), ('orders'), ('region')");
    }

    @Test
    @Override
    public void testCreateSchema()
    {
        assertThatThrownBy(super::testCreateSchema)
                .hasMessage("Creating schema in Kudu connector not allowed if schema emulation is disabled.");
    }

    @Test
    @Override
    public void testRenameTableAcrossSchema()
    {
        assertThatThrownBy(super::testRenameTableAcrossSchema)
                .hasMessage("Creating schema in Kudu connector not allowed if schema emulation is disabled.");
    }

    @Test
    @Override
    public void testDropNonEmptySchemaWithTable()
    {
        assertThatThrownBy(super::testDropNonEmptySchemaWithTable)
                .hasMessage("Creating schema in Kudu connector not allowed if schema emulation is disabled.");
    }
}

@@ -586,16 +586,48 @@
 .kudu;%0A%0A
+import io.trino.tpch.TpchTable;%0A
 import o
@@ -676,18 +676,225 @@
 til.
-Optional;%0A
+ArrayList;%0Aimport java.util.List;%0Aimport java.util.Optional;%0Aimport java.util.stream.Collectors;%0A%0Aimport static java.util.stream.Collectors.toUnmodifiableList;%0Aimport static org.assertj.core.api.Assertions.assertThat;
 %0Aimp
@@ -1275,105 +1275,585 @@
     
-assertQuery(%22SHOW TABLES FROM default%22, %22VALUES ('customer'), ('nation'), ('orders'), ('region')%22
+// Test methods may run in parallel and create tables in the default schema%0A        // Assert at least the TPCH tables exist but there may be more%0A        List%3CString%3E rows = new ArrayList%3C%3E(computeActual(%22SHOW TABLES FROM default%22).getMaterializedRows())%0A                .stream()%0A                .map(row -%3E ((String) row.getField(0)))%0A                .collect(toUnmodifiableList());%0A        assertThat(rows).containsAll(%0A                REQUIRED_TPCH_TABLES.stream()%0A                        .map(TpchTable::getTableName)%0A                        .collect(Collectors.toList())
 );%0A 

Fix test race in AbstractKuduWithDisabledInferSchemaConnectorTest