### Question:
ApplicationRegistry { public Mono<Application> getApplication(String name) { return this.toApplication(name, this.instanceRegistry.getInstances(name).filter(Instance::isRegistered)) .filter((a) -> !a.getInstances().isEmpty()); } 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 getApplication_noRegisteredApplications() { when(this.instanceRegistry.getInstances(any(String.class))).thenReturn(Flux.just()); StepVerifier.create(this.applicationRegistry.getApplication("App1")).verifyComplete(); }
@Test public void getApplication_noMatchingRegisteredApplications() { when(this.instanceRegistry.getInstances("App2")).thenReturn(Flux.just(getInstance("App2"))); when(this.instanceRegistry.getInstances(any(String.class))).thenReturn(Flux.just()); StepVerifier.create(this.applicationRegistry.getApplication("App1")).verifyComplete(); }
@Test public void getApplication_matchingRegisteredApplications() { Instance instance = getInstance("App1"); when(this.instanceRegistry.getInstances("App1")).thenReturn(Flux.just(instance)); StepVerifier.create(this.applicationRegistry.getApplication("App1")) .assertNext((app) -> assertThat(app.getName()).isEqualTo("App1")).verifyComplete(); }