### Question:
InstanceRegistry { public Mono<InstanceId> register(Registration registration) { Assert.notNull(registration, "'registration' must not be null"); InstanceId id = generator.generateId(registration); Assert.notNull(id, "'id' must not be null"); return repository.compute(id, (key, instance) -> { if (instance == null) { instance = Instance.create(key); } return Mono.just(instance.register(registration)); }).map(Instance::getId); } InstanceRegistry(InstanceRepository repository, InstanceIdGenerator generator); Mono<InstanceId> register(Registration registration); Flux<Instance> getInstances(); Flux<Instance> getInstances(String name); Mono<Instance> getInstance(InstanceId id); Mono<InstanceId> deregister(InstanceId id);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void registerFailed_null() { registry.register(null); }
@Test public void register() { Registration registration = Registration.create("abc", "http: InstanceId id = registry.register(registration).block(); StepVerifier.create(registry.getInstance(id)).assertNext(app -> { assertThat(app.getRegistration()).isEqualTo(registration); assertThat(app.getId()).isNotNull(); }).verifyComplete(); StepVerifier.create(registry.getInstances()).assertNext(app -> { assertThat(app.getRegistration()).isEqualTo(registration); assertThat(app.getId()).isNotNull(); }).verifyComplete(); }
@Test public void registerFailed_null() { assertThatThrownBy(() -> registry.register(null)).isInstanceOf(IllegalArgumentException.class); }
@Test public void register() { Registration registration = Registration.create("abc", "http: InstanceId id = registry.register(registration).block(); StepVerifier.create(registry.getInstance(id)).assertNext((app) -> { assertThat(app.getRegistration()).isEqualTo(registration); assertThat(app.getId()).isNotNull(); }).verifyComplete(); StepVerifier.create(registry.getInstances()).assertNext((app) -> { assertThat(app.getRegistration()).isEqualTo(registration); assertThat(app.getId()).isNotNull(); }).verifyComplete(); }