/*
 * 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");
    }

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

        connectorFactory.create(
                "test",
                ImmutableMap.<String, String>builder()
                        .put("hive.cache.enabled", "true")
                        .put("hive.metastore.uri", "thrift://foo:1234")
                        .put("hive.cache.location", "/tmp/cache")
                        .build(),
                new TestingConnectorContext())
                .shutdown();
    }
}

@@ -1226,38 +1226,24 @@
 rownBy(() -%3E
- %7B%0A           
  connectorFa
@@ -1268,36 +1268,32 @@
             
-    
 %22test%22,%0A
             
@@ -1272,36 +1272,32 @@
         %22test%22,%0A
-    
                 
@@ -1327,36 +1327,32 @@
 tring%3Ebuilder()%0A
-    
                 
@@ -1437,36 +1437,32 @@
                 
- 
-   
 .put(%22hive.cache
@@ -1472,36 +1472,32 @@
 abled%22, %22true%22)%0A
-    
                 
@@ -1522,36 +1522,32 @@
                 
-    
 new TestingConne
@@ -1569,36 +1569,32 @@
                 
-   
- 
 .shutdown();%0A   
@@ -1584,34 +1584,38 @@
  .shutdown()
-;%0A
+)%0A    
         
 %7D).hasMessag
@@ -1594,34 +1594,36 @@
 ())%0A            
-%7D)
+    
 .hasMessageConta
@@ -1967,22 +1967,8 @@
 ) -%3E
- %7B%0A           
  con
@@ -2001,36 +2001,32 @@
             
-    
 %22test%22,%0A
             
@@ -2005,36 +2005,32 @@
         %22test%22,%0A
-    
                 
@@ -2084,36 +2084,32 @@
                 
-    
 .put(%22hive.gcs.u
@@ -2150,36 +2150,32 @@
                 
- 
-   
 .put(%22hive.cache
@@ -2185,36 +2185,32 @@
 abled%22, %22true%22)%0A
-    
                 
@@ -2235,36 +2235,32 @@
                 
-    
 new TestingConne
@@ -2282,36 +2282,32 @@
                 
-   
- 
 .shutdown();%0A   
@@ -2301,26 +2301,30 @@
 utdown()
-;%0A
+)%0A    
         
 %7D).hasMe
@@ -2319,10 +2319,12 @@
     
-%7D)
+    
 .has

Use expression lambdas