### Question:
ApplicationRegistry { public Flux<Application> getApplications() { return this.instanceRegistry.getInstances().filter(Instance::isRegistered) .groupBy((instance) -> instance.getRegistration().getName()) .flatMap((grouped) -> toApplication(grouped.key(), grouped), Integer.MAX_VALUE); } ApplicationRegistry(InstanceRegistry instanceRegistry, InstanceEventPublisher instanceEventPublisher); Flux<Application> getApplications(); Mono<Application> getApplication(String name); Flux<Application> getApplicationStream(); Flux<InstanceId> deregister(String name);  }### Answer:
@Test public void getApplications_noRegisteredApplications() { when(this.instanceRegistry.getInstances()).thenReturn(Flux.just()); StepVerifier.create(this.applicationRegistry.getApplications()).verifyComplete(); }
@Test public void getApplications_allRegisteredApplications() { Instance instance1 = getInstance("App1"); Instance instance2 = getInstance("App2"); when(this.instanceRegistry.getInstances()).thenReturn(Flux.just(instance1, instance2)); StepVerifier.create(this.applicationRegistry.getApplications()).recordWith(ArrayList::new) .thenConsumeWhile((a) -> true) .consumeRecordedWith((applications) -> assertThat(applications.stream().map(Application::getName)) .containsExactlyInAnyOrder("App1", "App2")) .verifyComplete(); }