ServiceInstanceBindingServiceProxy implements ServiceInstanceBindingService { @Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) { preBinding(request); final CreateServiceInstanceBindingRequest req = mapper.map(request); final ResponseEntity<CreateServiceInstanceAppBindingResponse> response = client.createServiceInstanceBinding(req.getServiceInstanceId(), req.getBindingId(), OsbConstants.X_Broker_API_Version_Value,req); postBinding(request, response.getBody()); return Mono.just(response.getBody()); } @Autowired  ServiceInstanceBindingServiceProxy(ServiceInstanceBindingServiceClient client, ServiceInstanceBindingFilterRunner filterRunner, ServiceInstanceBindingRequestMapper mapper); @Override Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding(CreateServiceInstanceBindingRequest request); @Override Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest request);  }
@Test public void should_proxy_create_service_instance_binding_request_to_filtered_broker() throws Exception { Mockito.when(client.createServiceInstanceBinding("instance_id", "binding_id", OsbConstants.X_Broker_API_Version_Value,createServiceInstanceBindingRequest())) .thenReturn(created()); serviceInstanceBindingServiceProxy.createServiceInstanceBinding(createServiceInstanceBindingRequest()); Mockito.verify(client).createServiceInstanceBinding("instance_id", "binding_id", OsbConstants.X_Broker_API_Version_Value,createServiceInstanceBindingRequest()); }
@Test public void should_fail_to_create_service_instance_instance_when_any_post_filter_fails() throws Exception { Mockito.when(client.createServiceInstanceBinding("instance_id", "binding_id", OsbConstants.X_Broker_API_Version_Value,createServiceInstanceBindingRequest())) .thenReturn(created()); Mockito.doThrow(new RuntimeException("filter failed")) .when(filterRunner).postBind(createServiceInstanceBindingRequest(), new CreateServiceInstanceAppBindingResponse()); this.thrown.expect(RuntimeException.class); this.thrown.expectMessage("filter failed"); serviceInstanceBindingServiceProxy.createServiceInstanceBinding(createServiceInstanceBindingRequest()); }
@Test public void should_fail_to_create_service_instance_instance_when_any_pre_filter_fails() throws Exception { Mockito.doThrow(new RuntimeException("filter failed")) .when(filterRunner).preBind(createServiceInstanceBindingRequest()); this.thrown.expect(RuntimeException.class); this.thrown.expectMessage("filter failed"); serviceInstanceBindingServiceProxy.createServiceInstanceBinding(createServiceInstanceBindingRequest()); }