### Question:
CloudFoundryInstanceIdGenerator implements InstanceIdGenerator { @Override public InstanceId generateId(Registration registration) { String applicationId = registration.getMetadata().get("applicationId"); String instanceId = registration.getMetadata().get("instanceId"); if (StringUtils.hasText(applicationId) && StringUtils.hasText(instanceId)) { return InstanceId.of(String.format("%s:%s", applicationId, instanceId)); } return fallbackIdGenerator.generateId(registration); } CloudFoundryInstanceIdGenerator(InstanceIdGenerator fallbackIdGenerator); @Override InstanceId generateId(Registration registration);  }### Answer:
@Test public void test_cloud_foundry_instance_id() { Registration registration = Registration.create("foo", "http: .metadata("applicationId", "549e64cf-a478-423d-9d6d-02d803a028a8") .metadata("instanceId", "0") .build(); assertThat(instance.generateId(registration)).isEqualTo( InstanceId.of("549e64cf-a478-423d-9d6d-02d803a028a8:0")); }
@Test public void test_cloud_foundry_instance_id() { Registration registration = Registration.create("foo", "http: .metadata("applicationId", "549e64cf-a478-423d-9d6d-02d803a028a8").metadata("instanceId", "0").build(); assertThat(instance.generateId(registration)) .isEqualTo(InstanceId.of("549e64cf-a478-423d-9d6d-02d803a028a8:0")); }
@Test public void test_health_url_instance_id() { Registration registration = Registration.create("foo", "http: assertThat(instance.generateId(registration)).isEqualTo(InstanceId.of("8f9960c48139")); }