### Question:
TrieRoutingData implements MetadataStoreRoutingData { public String getMetadataStoreRealm(String path) throws IllegalArgumentException, NoSuchElementException { if (!ZkValidationUtil.isPathValid(path)) { throw new IllegalArgumentException("Provided path is not a valid Zookeeper path: " + path); } TrieNode node = getLongestPrefixNodeAlongPath(path); if (!node.isShardingKey()) { throw new NoSuchElementException( "No sharding key found within the provided path. Path: " + path); } return node.getRealmAddress(); } TrieRoutingData(Map<String, List<String>> routingData); Map<String, String> getAllMappingUnderPath(String path); String getMetadataStoreRealm(String path); String getShardingKeyInPath(String path); boolean isShardingKeyInsertionValid(String shardingKey); boolean containsKeyRealmPair(String shardingKey, String realmAddress);  }### Answer:
@Test(dependsOnMethods = "testConstructionNormal") public void testGetMetadataStoreRealmEmptyPath() { try { Assert.assertEquals(_trie.getMetadataStoreRealm(""), "realmAddress2"); Assert.fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("Provided path is not a valid Zookeeper path: ")); } }
@Test(dependsOnMethods = "testConstructionNormal") public void testGetMetadataStoreRealmNoSlash() { try { Assert.assertEquals(_trie.getMetadataStoreRealm("b/c/d/x/y/z"), "realmAddress2"); Assert.fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { Assert.assertTrue( e.getMessage().contains("Provided path is not a valid Zookeeper path: b/c/d/x/y/z")); } }
@Test(dependsOnMethods = "testConstructionNormal") public void testGetMetadataStoreRealm() { try { Assert.assertEquals(_trie.getMetadataStoreRealm("/b/c/d/x/y/z"), "realmAddress2"); } catch (NoSuchElementException e) { Assert.fail("Not expecting NoSuchElementException"); } }
@Test(dependsOnMethods = "testConstructionNormal") public void testGetMetadataStoreRealmWrongPath() { try { _trie.getMetadataStoreRealm("/x/y/z"); Assert.fail("Expecting NoSuchElementException"); } catch (NoSuchElementException e) { Assert.assertTrue( e.getMessage().contains("No sharding key found within the provided path. Path: /x/y/z")); } }
@Test(dependsOnMethods = "testConstructionNormal") public void testGetMetadataStoreRealmNoLeaf() { try { _trie.getMetadataStoreRealm("/b/c"); Assert.fail("Expecting NoSuchElementException"); } catch (NoSuchElementException e) { Assert.assertTrue( e.getMessage().contains("No sharding key found within the provided path. Path: /b/c")); } }