Skip to content

Commit

Permalink
Test FileHiveMetastoreConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Oct 6, 2020
1 parent 04aa99c commit a1d899b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public String getCatalogDirectory()

@Config("hive.metastore.catalog.dir")
@ConfigDescription("Hive file-based metastore catalog directory")
public void setCatalogDirectory(String catalogDirectory)
public FileHiveMetastoreConfig setCatalogDirectory(String catalogDirectory)
{
this.catalogDirectory = catalogDirectory;
return this;
}

@NotNull
Expand All @@ -45,9 +46,10 @@ public String getMetastoreUser()

@Config("hive.metastore.user")
@ConfigDescription("Hive file-based metastore username for file access")
public void setMetastoreUser(String metastoreUser)
public FileHiveMetastoreConfig setMetastoreUser(String metastoreUser)
{
this.metastoreUser = metastoreUser;
return this;
}

public boolean isAssumeCanonicalPartitionKeys()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.metastore.file;

import com.google.common.collect.ImmutableMap;
import org.testng.annotations.Test;

import java.util.Map;

import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping;
import static io.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults;
import static io.airlift.configuration.testing.ConfigAssertions.recordDefaults;

public class TestFileHiveMetastoreConfig
{
@Test
public void testDefaults()
{
assertRecordedDefaults(recordDefaults(FileHiveMetastoreConfig.class)
.setCatalogDirectory(null)
.setMetastoreUser("presto")
.setAssumeCanonicalPartitionKeys(false));
}

@Test
public void testExplicitPropertyMapping()
{
Map<String, String> properties = new ImmutableMap.Builder<String, String>()
.put("hive.metastore.catalog.dir", "some path")
.put("hive.metastore.user", "some user")
.put("hive.metastore.assume-canonical-partition-keys", "true")
.build();

FileHiveMetastoreConfig expected = new FileHiveMetastoreConfig()
.setCatalogDirectory("some path")
.setMetastoreUser("some user")
.setAssumeCanonicalPartitionKeys(true);

assertFullMapping(properties, expected);
}
}

0 comments on commit a1d899b

Please sign in to comment.