### Question:
ZkRoutingDataWriter implements MetadataStoreRoutingDataWriter { @Override public synchronized boolean setRoutingData(Map<String, List<String>> routingData) { if (_leaderElection.isLeader()) { if (_zkClient.isClosed()) { throw new IllegalStateException("ZkClient is closed!"); } if (routingData == null) { throw new IllegalArgumentException("routingData given is null!"); } for (String zkRealm : _zkClient .getChildren(MetadataStoreRoutingConstants.ROUTING_DATA_PATH)) { if (!_zkClient.delete(MetadataStoreRoutingConstants.ROUTING_DATA_PATH + "/" + zkRealm)) { LOG.error( "Failed to delete existing routing data in setRoutingData()! Namespace: {}, Realm: {}", _namespace, zkRealm); return false; } } for (Map.Entry<String, List<String>> routingDataEntry : routingData.entrySet()) { String zkRealm = routingDataEntry.getKey(); List<String> shardingKeyList = routingDataEntry.getValue(); ZNRecord znRecord = new ZNRecord(zkRealm); znRecord .setListField(MetadataStoreRoutingConstants.ZNRECORD_LIST_FIELD_KEY, shardingKeyList); String realmPath = MetadataStoreRoutingConstants.ROUTING_DATA_PATH + "/" + zkRealm; try { if (!_zkClient.exists(realmPath)) { _zkClient.createPersistent(realmPath); } _zkClient.writeData(realmPath, znRecord); } catch (Exception e) { LOG.error("Failed to write data in setRoutingData()! Namespace: {}, Realm: {}", _namespace, zkRealm, e); return false; } } return true; } String url = buildEndpointFromLeaderElectionNode(_leaderElection.getCurrentLeaderInfo()) + constructUrlSuffix(MetadataStoreRoutingConstants.MSDS_GET_ALL_ROUTING_DATA_ENDPOINT); HttpPut httpPut = new HttpPut(url); String routingDataJsonString; try { routingDataJsonString = OBJECT_MAPPER.writeValueAsString(routingData); } catch (JsonGenerationException | JsonMappingException e) { throw new IllegalArgumentException(e.getMessage()); } catch (IOException e) { LOG.error( "setRoutingData failed before forwarding the request to leader: an exception happened while routingData is converted to json. routingData: {}", routingData, e); return false; } httpPut.setEntity(new StringEntity(routingDataJsonString, ContentType.APPLICATION_JSON)); return sendRequestToLeader(httpPut, Response.Status.CREATED.getStatusCode()); } ZkRoutingDataWriter(String namespace, String zkAddress); static String buildEndpointFromLeaderElectionNode(ZNRecord znRecord); @Override synchronized boolean addMetadataStoreRealm(String realm); @Override synchronized boolean deleteMetadataStoreRealm(String realm); @Override synchronized boolean addShardingKey(String realm, String shardingKey); @Override synchronized boolean deleteShardingKey(String realm, String shardingKey); @Override synchronized boolean setRoutingData(Map<String, List<String>> routingData); @Override synchronized void close();  }### Answer:
@Test(dependsOnMethods = "testDeleteShardingKey") public void testSetRoutingData() { Map<String, List<String>> testRoutingDataMap = ImmutableMap.of(DUMMY_REALM, Collections.singletonList(DUMMY_SHARDING_KEY)); _zkRoutingDataWriter.setRoutingData(testRoutingDataMap); ZNRecord znRecord = _gZkClientTestNS .readData(MetadataStoreRoutingConstants.ROUTING_DATA_PATH + "/" + DUMMY_REALM); Assert.assertNotNull(znRecord); Assert.assertEquals( znRecord.getListField(MetadataStoreRoutingConstants.ZNRECORD_LIST_FIELD_KEY).size(), 1); Assert.assertTrue(znRecord.getListField(MetadataStoreRoutingConstants.ZNRECORD_LIST_FIELD_KEY) .contains(DUMMY_SHARDING_KEY)); }