@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");
}