### Question:
OzoneS3Util { public static String buildServiceNameForToken( @Nonnull OzoneConfiguration configuration, @Nonnull String serviceId, @Nonnull Collection<String> omNodeIds) { StringBuilder rpcAddress = new StringBuilder(); int nodesLength = omNodeIds.size(); int counter = 0; for (String nodeId : omNodeIds) { counter++; String rpcAddrKey = OmUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY, serviceId, nodeId); String rpcAddrStr = OmUtils.getOmRpcAddress(configuration, rpcAddrKey); if (rpcAddrStr == null || rpcAddrStr.isEmpty()) { throw new IllegalArgumentException("Could not find rpcAddress for " + OZONE_OM_ADDRESS_KEY + "." + serviceId + "." + nodeId); } if (counter != nodesLength) { rpcAddress.append(SecurityUtil.buildTokenService( NetUtils.createSocketAddr(rpcAddrStr)) + ","); } else { rpcAddress.append(SecurityUtil.buildTokenService( NetUtils.createSocketAddr(rpcAddrStr))); } } return rpcAddress.toString(); } private  OzoneS3Util(); static String getS3Username(String userName); static String buildServiceNameForToken(
      @Nonnull OzoneConfiguration configuration, @Nonnull String serviceId,
      @Nonnull Collection<String> omNodeIds);  }### Answer:
@Test public void testBuildServiceNameForToken() { Collection<String> nodeIDList = OmUtils.getOMNodeIds(configuration, serviceID); configuration.set(OmUtils.addKeySuffixes(OMConfigKeys.OZONE_OM_ADDRESS_KEY, serviceID, "om1"), "om1:9862"); configuration.set(OmUtils.addKeySuffixes(OMConfigKeys.OZONE_OM_ADDRESS_KEY, serviceID, "om2"), "om2:9862"); configuration.set(OmUtils.addKeySuffixes(OMConfigKeys.OZONE_OM_ADDRESS_KEY, serviceID, "om3"), "om3:9862"); String expectedOmServiceAddress = buildServiceAddress(nodeIDList); SecurityUtil.setConfiguration(configuration); String omserviceAddr = OzoneS3Util.buildServiceNameForToken(configuration, serviceID, nodeIDList); Assert.assertEquals(expectedOmServiceAddress, omserviceAddr); }
@Test public void testBuildServiceNameForTokenIncorrectConfig() { Collection<String> nodeIDList = OmUtils.getOMNodeIds(configuration, serviceID); configuration.set(OmUtils.addKeySuffixes(OMConfigKeys.OZONE_OM_ADDRESS_KEY, serviceID, "om1"), "om1:9862"); configuration.set(OmUtils.addKeySuffixes(OMConfigKeys.OZONE_OM_ADDRESS_KEY, serviceID, "om2"), "om2:9862"); SecurityUtil.setConfiguration(configuration); try { OzoneS3Util.buildServiceNameForToken(configuration, serviceID, nodeIDList); fail("testBuildServiceNameForTokenIncorrectConfig failed"); } catch (IllegalArgumentException ex) { GenericTestUtils.assertExceptionContains("Could not find rpcAddress " + "for", ex); } }