### Question:
LaunchableMesosWorker implements LaunchableTask { static Set<String> extractPortKeys(Configuration config) { final LinkedHashSet<String> tmPortKeys = new LinkedHashSet<>(TM_PORT_KEYS); final String portKeys = config.getString(PORT_ASSIGNMENTS); if (portKeys != null) { Arrays.stream(portKeys.split(",")) .map(String::trim) .peek(key -> LOG.debug("Adding port key {} to mesos request")) .forEach(tmPortKeys::add); } return Collections.unmodifiableSet(tmPortKeys); } LaunchableMesosWorker(
			MesosArtifactResolver resolver,
			MesosTaskManagerParameters params,
			ContainerSpecification containerSpec,
			Protos.TaskID taskID,
			MesosConfiguration mesosConfiguration); Protos.TaskID taskID(); @Override TaskRequest taskRequest(); @Override Protos.TaskInfo launch(Protos.SlaveID slaveId, MesosResourceAllocation allocation); @Override String toString();  }### Answer:
@Test public void canGetPortKeys() { Set<String> additionalPorts = new HashSet<>(Arrays.asList("someport.here", "anotherport")); Configuration config = new Configuration(); config.setString(PORT_ASSIGNMENTS, String.join(",", additionalPorts)); Set<String> portKeys = LaunchableMesosWorker.extractPortKeys(config); Set<String> expectedPorts = new HashSet<>(LaunchableMesosWorker.TM_PORT_KEYS); expectedPorts.addAll(additionalPorts); assertThat(portKeys, is(equalTo(expectedPorts))); }
@Test public void canGetNoPortKeys() { Configuration config = new Configuration(); Set<String> portKeys = LaunchableMesosWorker.extractPortKeys(config); assertThat(portKeys, is(equalTo(LaunchableMesosWorker.TM_PORT_KEYS))); }