### Question:
AWSGlueMetastoreFactory { public AWSGlueMetastore newMetastore(HiveConf conf) throws MetaException { AWSGlue glueClient = new AWSGlueClientFactory(conf).newClient(); AWSGlueMetastore defaultMetastore = new DefaultAWSGlueMetastore(conf, glueClient); if(isCacheEnabled(conf)) { return new AWSGlueMetastoreCacheDecorator(conf, defaultMetastore); } return defaultMetastore; }  AWSGlueMetastore newMetastore(HiveConf conf);  }### Answer:
@Test public void testNewMetastoreWhenCacheDisabled() throws Exception { when(hiveConf.getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false)).thenReturn(false); when(hiveConf.getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false)).thenReturn(false); assertTrue(DefaultAWSGlueMetastore.class.equals( awsGlueMetastoreFactory.newMetastore(hiveConf).getClass())); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false); }
@Test public void testNewMetastoreWhenTableCacheEnabled() throws Exception { when(hiveConf.getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false)).thenReturn(false); when(hiveConf.getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false)).thenReturn(true); assertTrue(AWSGlueMetastoreCacheDecorator.class.equals( awsGlueMetastoreFactory.newMetastore(hiveConf).getClass())); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false); }
@Test public void testNewMetastoreWhenDBCacheEnabled() throws Exception { when(hiveConf.getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false)).thenReturn(true); when(hiveConf.getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false)).thenReturn(true); assertTrue(AWSGlueMetastoreCacheDecorator.class.equals( awsGlueMetastoreFactory.newMetastore(hiveConf).getClass())); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false); }
@Test public void testNewMetastoreWhenAllCacheEnabled() throws Exception { when(hiveConf.getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false)).thenReturn(true); when(hiveConf.getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false)).thenReturn(true); assertTrue(AWSGlueMetastoreCacheDecorator.class.equals( awsGlueMetastoreFactory.newMetastore(hiveConf).getClass())); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false); verify(hiveConf, atLeastOnce()).getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false); }