### Question:
ZkMetadataStoreDirectory implements MetadataStoreDirectory, RoutingDataListener { @Override public String getMetadataStoreRealm(String namespace, String shardingKey) { if (!_routingZkAddressMap.containsKey(namespace)) { throw new NoSuchElementException( "Failed to get metadata store realm: Namespace " + namespace + " is not found!"); } if (!_routingDataMap.containsKey(namespace)) { throw new IllegalStateException("Failed to get metadata store realm: Namespace " + namespace + " contains either empty or invalid routing data!"); } return _routingDataMap.get(namespace).getMetadataStoreRealm(shardingKey); } @VisibleForTesting protected  ZkMetadataStoreDirectory(); static ZkMetadataStoreDirectory getInstance(); static ZkMetadataStoreDirectory getInstance(String namespace, String zkAddress); @Override Collection<String> getAllNamespaces(); @Override Collection<String> getAllMetadataStoreRealms(String namespace); @Override Collection<String> getAllShardingKeys(String namespace); @Override Map<String, List<String>> getNamespaceRoutingData(String namespace); @Override boolean setNamespaceRoutingData(String namespace, Map<String, List<String>> routingData); @Override Collection<String> getAllShardingKeysInRealm(String namespace, String realm); @Override Map<String, String> getAllMappingUnderPath(String namespace, String path); @Override String getMetadataStoreRealm(String namespace, String shardingKey); @Override boolean addMetadataStoreRealm(String namespace, String realm); @Override boolean deleteMetadataStoreRealm(String namespace, String realm); @Override boolean addShardingKey(String namespace, String realm, String shardingKey); @Override boolean deleteShardingKey(String namespace, String realm, String shardingKey); @Override void refreshRoutingData(String namespace); @Override synchronized void close(); static void createRoutingDataPath(HelixZkClient zkClient, String zkAddress);  }### Answer:
@Test(dependsOnMethods = "testGetAllMappingUnderPath") public void testGetMetadataStoreRealm() { for (String namespace : _routingZkAddrMap.keySet()) { Assert.assertEquals( _metadataStoreDirectory.getMetadataStoreRealm(namespace, "/sharding/key/1/a/x/y/z"), TEST_REALM_1); Assert.assertEquals( _metadataStoreDirectory.getMetadataStoreRealm(namespace, "/sharding/key/1/d/x/y/z"), TEST_REALM_2); } }
@Test(dependsOnMethods = "testChildChangeCallback") public void testDataDeletionCallback() throws Exception { _zkList.forEach(zk -> { ZkClient zkClient = ZK_SERVER_MAP.get(zk).getZkClient(); if (zkClient.exists(MetadataStoreRoutingConstants.ROUTING_DATA_PATH)) { for (String zkRealm : zkClient .getChildren(MetadataStoreRoutingConstants.ROUTING_DATA_PATH)) { zkClient.delete(MetadataStoreRoutingConstants.ROUTING_DATA_PATH + "/" + zkRealm); } } } ); Assert.assertTrue(TestHelper.verify(() -> { for (String namespace : _routingZkAddrMap.keySet()) { try { _metadataStoreDirectory.getMetadataStoreRealm(namespace, TEST_SHARDING_KEYS_1.get(0)); return false; } catch (IllegalStateException e) { if (!e.getMessage().equals("Failed to get metadata store realm: Namespace " + namespace + " contains either empty or invalid routing data!")) { throw e; } } } return true; }, TestHelper.WAIT_DURATION)); }