/*
 * 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.prestosql.plugin.hive;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import io.prestosql.spi.Plugin;
import io.prestosql.spi.connector.ConnectorFactory;
import io.prestosql.testing.TestingConnectorContext;
import org.testng.annotations.Test;

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

public class TestHiveHadoop2Plugin
{
    @Test
    public void testS3SecurityMappingAndHiveCachingMutuallyExclusive()
    {
        Plugin plugin = new HiveHadoop2Plugin();
        ConnectorFactory connectorFactory = Iterables.getOnlyElement(plugin.getConnectorFactories());

        assertThatThrownBy(() -> {
            connectorFactory.create(
                    "test",
                    ImmutableMap.<String, String>builder()
                            .put("hive.s3.security-mapping.config-file", "/tmp/blah.txt")
                            .put("hive.cache.enabled", "true")
                            .build(),
                    new TestingConnectorContext())
                    .shutdown();
        }).hasMessageContaining("S3 security mapping is not compatible with Hive caching");
    }

    @Test
    public void testGcsAccessTokenAndHiveCachingMutuallyExclusive()
    {
        Plugin plugin = new HiveHadoop2Plugin();
        ConnectorFactory connectorFactory = Iterables.getOnlyElement(plugin.getConnectorFactories());

        assertThatThrownBy(() -> {
            connectorFactory.create(
                    "test",
                    ImmutableMap.<String, String>builder()
                            .put("hive.gcs.use-access-token", "true")
                            .put("hive.cache.enabled", "true")
                            .build(),
                    new TestingConnectorContext())
                    .shutdown();
        }).hasMessageContaining("Use of GCS access token is not compatible with Hive caching");
    }
}

@@ -2482,11 +2482,638 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testRubixCache()%0A    %7B%0A        Plugin plugin = new HiveHadoop2Plugin();%0A        ConnectorFactory connectorFactory = Iterables.getOnlyElement(plugin.getConnectorFactories());%0A%0A        connectorFactory.create(%0A                %22test%22,%0A                ImmutableMap.%3CString, String%3Ebuilder()%0A                        .put(%22hive.cache.enabled%22, %22true%22)%0A                        .put(%22hive.metastore.uri%22, %22thrift://foo:1234%22)%0A                        .put(%22hive.cache.location%22, %22/tmp/cache%22)%0A                        .build(),%0A                new TestingConnectorContext())%0A                .shutdown();%0A    %7D
 %0A%7D%0A

Add rubix module test