### Question:
KafkaCloudSlave extends AbstractCloudSlave { public static String getSlaveName(String baseNameArg) { String baseName = StringUtils.defaultIfBlank(baseNameArg, DEFAULT_AGENT_PREFIX); baseName = baseName.replaceAll("[ _]", "-").toLowerCase(); baseName = baseName.substring(0, Math.min(baseName.length(), 62 - AGENT_NAME_RANDOM_LENGTH)); Set<String> existingNodeNames = Jenkins.get() .getNodes() .stream() .map(Node::getNodeName) .collect(Collectors.toSet()); while (true) { String randString = RandomStringUtils.random(AGENT_NAME_RANDOM_LENGTH, "bcdfghjklmnpqrstvwxz0123456789"); String name = String.format("%s-%s", baseName, randString); if (!existingNodeNames.contains(name)) { return name; } } } KafkaCloudSlave(@Nonnull KafkaKubernetesCloud cloud); String getName(); String getCloudName(); void setCloudName(String cloudName); @Nonnull KafkaKubernetesCloud getCloud(); String getNamespace(); static String getSlaveName(String baseNameArg); @Override AbstractCloudComputer createComputer();  }### Answer:
@Test public void testGetAgentNameBlankBaseName() { String baseName = null; String name = KafkaCloudSlave.getSlaveName(baseName); assertTrue(StringUtils.isNotBlank(name)); baseName = ""; name = KafkaCloudSlave.getSlaveName(baseName); assertTrue(StringUtils.isNotBlank(name)); }
@Test public void testGetAgentNameIsRandom() { final String baseName = "base-name"; final String name1 = KafkaCloudSlave.getSlaveName(baseName); final String name2 = KafkaCloudSlave.getSlaveName(baseName); assertThat(name1, is(not(name2))); }
@Test public void testGetAgentNameContainBaseName() { final String baseName = "base-name"; final String name = KafkaCloudSlave.getSlaveName(baseName); assertThat(name, containsString(baseName)); }