### Question:
Configuration { static List<String> parseHostList(String hostList) { Matcher rangeMatcher = Pattern.compile("([\\w-]+)\\{(\\d+)-(\\d+)}").matcher(hostList); if(rangeMatcher.matches()) { String name = rangeMatcher.group(1); int lowerRange = Integer.parseInt(rangeMatcher.group(2)); int upperRange = Integer.parseInt(rangeMatcher.group(3)); if(lowerRange < upperRange) { return IntStream.rangeClosed(lowerRange, upperRange).mapToObj(i -> name + i).collect(Collectors.toList()); } else { throw new IllegalArgumentException("lower range must be small than upper range on " + hostList); } } else if(hostList.matches("\\S+(,\\s*\\S+)*")) { return Splitter.on(',').trimResults().omitEmptyStrings().splitToList(hostList); } else { throw new IllegalArgumentException("Host list must be a comma separated list of host names, or in the form hostName{1-n}"); } } private  Configuration(String remoteHost, Integer remotePort, String slaveName, String jobName,
                          List<String> hostList, String buildTag, long clientTimeout, boolean https, int clientAttempts); static Configuration newConfigurationFromEnv(Map<String, String> envOverrides); String getJobName(); String getRemoteHost(); String getSlaveName(); List<String> getHostList(); Integer getRemotePort(); String getBuildTag(); long getClientTimeout(); int getClientAttempts(); boolean isHttps(); static final String ENV_HOST_NAME; static final String ENV_HYDRA_ADDRESS; static final String ENV_HYDRA_HOSTS; static final String ENV_HYDRA_HTTPS; static final String ENV_HYDRA_CLIENT_TIMEOUT; static final String ENV_HYDRA_CLIENT_ATTEMPTS; static final String ENV_JOB_NAME; static final String ENV_BUILD_TAG; }### Answer:
@Test public void csvHostList() { List<String> expectedHostList = Arrays.asList("jenkins-ut1", "jenkins-ut2", "jenkins-ut3", "jenkins-ut4"); List<String> parsedHostList = Configuration.parseHostList("jenkins-ut1,jenkins-ut2,jenkins-ut3,jenkins-ut4"); assertEquals(expectedHostList, parsedHostList); }
@Test public void rangeHostList() { List<String> expectedHostList = Arrays.asList("jenkins-ut1", "jenkins-ut2", "jenkins-ut3", "jenkins-ut4"); List<String> parsedHostList = Configuration.parseHostList("jenkins-ut{1-4}"); assertEquals(expectedHostList, parsedHostList); }
@Test public void rangeHostListDoubleDigit() { List<String> expectedHostList = Arrays.asList("jenkins-ut10", "jenkins-ut11", "jenkins-ut12", "jenkins-ut13"); List<String> parsedHostList = Configuration.parseHostList("jenkins-ut{10-13}"); assertEquals(expectedHostList, parsedHostList); }