@Test public void fluxInitialValueAvailableOnceIfBroadcasted() { // "A deferred Flux with an initial value makes that value available once if broadcasted" // given: "a composable with an initial value" Flux<String> stream = Flux.just("test") .publish() .autoConnect(); // when: "the value is retrieved" AtomicReference<String> value = new AtomicReference<>(); AtomicReference<String> value2 = new AtomicReference<>(); stream.subscribe(value::set); stream.subscribe(value2::set); // then: "it is available in value 1 but value 2 has subscribed after dispatching" assertThat(value.get()).isEqualTo("test"); assertThat(value2.get()).isNullOrEmpty(); }
@Test public void shouldNotSetSystemPropertiesWhenHoverflyInWebServerMode() { System.clearProperty("http.proxyHost"); System.clearProperty("https.proxyHost"); hoverfly = new Hoverfly(localConfigs().asWebServer(), SIMULATE); hoverfly.start(); assertThat(System.getProperty("http.proxyHost")).isNullOrEmpty(); assertThat(System.getProperty("https.proxyHost")).isNullOrEmpty(); }
@Test public void createServiceInstanceBindingFails() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.createServiceInstanceBinding( CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isEqualTo("before create foo"); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isEqualTo("error create foo"); assertThat(this.results.getBeforeDelete()).isNullOrEmpty(); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
@Test public void deleteServiceInstanceBindingFails() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isNullOrEmpty(); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isEqualTo("before delete foo"); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isEqualTo("error delete foo"); }
@Test public void createServiceInstanceBindingSucceeds() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.createServiceInstanceBinding( CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo") .serviceDefinitionId("bar") .build())) .expectNext(CreateServiceInstanceAppBindingResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeCreate()).isEqualTo("before create foo"); assertThat(this.results.getAfterCreate()).isEqualTo("after create foo"); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isNullOrEmpty(); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
@Test public void deleteServiceInstanceBindingSucceeds() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("foo") .bindingId("bar") .build())) .expectNext(DeleteServiceInstanceBindingResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeCreate()).isNullOrEmpty(); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isEqualTo("before delete foo"); assertThat(this.results.getAfterDelete()).isEqualTo("after delete foo"); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
@Test public void getLastOperationFails() { prepareLastOperationEventFlows(); StepVerifier .create(serviceInstanceEventService.getLastOperation(GetLastServiceOperationRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeLastOperation()).isEqualTo("before foo"); assertThat(this.results.getAfterLastOperation()).isNullOrEmpty(); assertThat(this.results.getErrorLastOperation()).isEqualTo("error foo"); }
@Test public void createServiceInstanceFails() { prepareCreateEventFlows(); StepVerifier.create(serviceInstanceEventService.createServiceInstance( CreateServiceInstanceRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isEqualTo("before foo"); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isEqualTo("error foo"); }
@Test public void updateServiceInstanceFails() { prepareUpdateEventFlows(); StepVerifier .create(serviceInstanceEventService.updateServiceInstance( UpdateServiceInstanceRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeUpdate()).isEqualTo("before foo"); assertThat(this.results.getAfterUpdate()).isNullOrEmpty(); assertThat(this.results.getErrorUpdate()).isEqualTo("error foo"); }
@Test public void deleteServiceInstanceFails() { prepareDeleteEventFlows(); StepVerifier .create(serviceInstanceEventService.deleteServiceInstance( DeleteServiceInstanceRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeDelete()).isEqualTo("before foo"); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isEqualTo("error foo"); }
@Test public void updateServiceInstanceSucceeds() { prepareUpdateEventFlows(); StepVerifier .create(serviceInstanceEventService.updateServiceInstance( UpdateServiceInstanceRequest.builder() .serviceInstanceId("foo") .serviceDefinitionId("bar") .build())) .expectNext(UpdateServiceInstanceResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeUpdate()).isEqualTo("before foo"); assertThat(this.results.getAfterUpdate()).isEqualTo("after foo"); assertThat(this.results.getErrorUpdate()).isNullOrEmpty(); }
@Test public void getLastOperationSucceeds() { prepareLastOperationEventFlows(); StepVerifier .create(serviceInstanceEventService.getLastOperation(GetLastServiceOperationRequest.builder() .serviceInstanceId("foo") .serviceDefinitionId("bar") .build())) .expectNext(GetLastServiceOperationResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeLastOperation()).isEqualTo("before foo"); assertThat(this.results.getAfterLastOperation()).isEqualTo("after foo"); assertThat(this.results.getErrorLastOperation()).isNullOrEmpty(); }
@Test public void createServiceInstanceSucceeds() { prepareCreateEventFlows(); StepVerifier .create(serviceInstanceEventService.createServiceInstance( CreateServiceInstanceRequest.builder() .serviceInstanceId("foo") .serviceDefinitionId("bar") .build())) .expectNext(CreateServiceInstanceResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeCreate()).isEqualTo("before foo"); assertThat(this.results.getAfterCreate()).isEqualTo("after foo"); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); }
@Test public void deleteServiceInstanceSucceeds() { prepareDeleteEventFlows(); StepVerifier .create(serviceInstanceEventService.deleteServiceInstance( DeleteServiceInstanceRequest.builder() .serviceInstanceId("foo") .serviceDefinitionId("bar") .build())) .expectNext(DeleteServiceInstanceResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeDelete()).isEqualTo("before foo"); assertThat(this.results.getAfterDelete()).isEqualTo("after foo"); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }