@Test public void serviceInstanceBindingRetrievedSuccessfully() throws ServiceBrokerException, ServiceInstanceBindingExistsException { ServiceInstanceBinding binding = ServiceInstanceBindingFixture.getServiceInstanceBinding(); when(bindingRepository.findOne(anyString())).thenReturn(binding); assertEquals( binding.getId(), bindingService.getServiceInstanceBinding(binding.getId()).getId()); }
@Test(expected = ServiceInstanceBindingExistsException.class) public void serviceInstanceCreationFailsWithExistingInstance() throws ServiceBrokerException, ServiceInstanceBindingExistsException { when(bindingRepository.findOne(anyString())) .thenReturn(ServiceInstanceBindingFixture.getServiceInstanceBinding()); when(admin.getApplicationSensors(anyString())) .thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap())); CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest( serviceInstance.getServiceDefinitionId(), "planId", "appGuid"); bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID)); bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID)); }
@Test public void serviceInstanceBindingDeletedSuccessfully() throws ServiceBrokerException, ServiceInstanceBindingExistsException { ServiceInstanceBinding binding = ServiceInstanceBindingFixture.getServiceInstanceBinding(); when(bindingRepository.findOne(anyString())).thenReturn(binding); when(instanceRepository.findOne(anyString(), any(Boolean.class))).thenReturn(serviceInstance); when(serviceInstance.getServiceDefinitionId()).thenReturn(SVC_DEFN_ID); when(admin.invokeEffector(anyString(), anyString(), anyString(), anyString(), anyMap())) .thenReturn(new AsyncResult<String>("effector called")); DeleteServiceInstanceBindingRequest request = new DeleteServiceInstanceBindingRequest( binding.getId(), serviceInstance, "serviceId", "planId"); assertNotNull(bindingService.deleteServiceInstanceBinding(request)); }