DefaultDockerCloudClient extends BuildServerAdapter implements DockerCloudClient { @Nullable @Override public String generateAgentName(@Nonnull AgentDescription agent) { return null; } DefaultDockerCloudClient(@Nonnull DockerCloudClientConfig clientConfig,
                             @Nonnull final List<DockerImageConfig> imageConfigs,
                             @Nonnull final DockerImageNameResolver resolver,
                             @Nonnull CloudState cloudState,
                             @Nonnull final SBuildServer buildServer); @Nonnull @Override UUID getUuid(); @Nonnull @Override DockerCloudSupport getCloudSupport(); @Override void serverStartup(); @Override boolean isInitialized(); @Nullable @Override DockerImage findImageById(@Nonnull String id); @Nullable @Override DockerInstance findInstanceByAgent(@Nonnull AgentDescription agent); @Nonnull @Override Collection<DockerImage> getImages(); @Nullable @Override CloudErrorInfo getErrorInfo(); @Override boolean canStartNewInstance(@Nonnull CloudImage image); @Nullable @Override String generateAgentName(@Nonnull AgentDescription agent); @Nonnull @Override DockerInstance startNewInstance(@Nonnull final CloudImage image, @Nonnull final CloudInstanceUserData tag); @Override void restartInstance(@Nonnull final CloudInstance instance); @Override void terminateInstance(@Nonnull final CloudInstance instance); @Override void dispose(); Optional<Instant> getLastDockerSyncTime(); @Override void notifyFailure(@Nonnull String msg, @Nullable Throwable throwable);  }
@Test public void generateAgentName() { DefaultDockerCloudClient client = createClient(); DockerImage image = waitForImage(client); testCloudSupport.getClientFacade().agentConfigurator((container -> container.name("test_container_name"))); DockerInstance instance = client.startNewInstance(image, userData); waitForInstanceStatus(instance, InstanceStatus.RUNNING); assertThat(buildServer.getAgentNameGenerator()).isNotNull(); TestSBuildAgent agent = new TestSBuildAgent(). environmentVariable(DockerCloudUtils.ENV_CLIENT_ID, client.getUuid().toString()). environmentVariable(DockerCloudUtils.ENV_IMAGE_ID, image.getUuid().toString()). environmentVariable(DockerCloudUtils.ENV_INSTANCE_ID, instance.getUuid().toString()). hostAddress("172.17.0.1"); assertThat(buildServer.getAgentNameGenerator().generateName(agent)).isEqualTo("test_container_name/172.17.0.1"); agent.hostAddress(null); assertThat(buildServer.getAgentNameGenerator().generateName(agent)).isEqualTo("test_container_name"); agent.hostAddress(""); assertThat(buildServer.getAgentNameGenerator().generateName(agent)).isEqualTo("test_container_name"); }