@Test public void serviceInstanceIsDeletedSuccessfully() throws Exception { ServiceInstance instance = ServiceInstanceFixture.getServiceInstance(); String createUrl = ServiceInstanceController.BASE_PATH + "/" + instance.getId(); String body = ServiceInstanceFixture.getCreateServiceInstanceRequestJson(); String deleteUrl = ServiceInstanceController.BASE_PATH + "/" + instance.getId() + "?service_id=" + instance.getServiceDefinitionId() + "&plan_id=" + instance.getPlanId(); mockMvc .perform( put(createUrl) .contentType(MediaType.APPLICATION_JSON) .content(body) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)); serviceInstanceService.getServiceInstance(instance.getId()); mockMvc .perform(delete(deleteUrl).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)); }
@RequestMapping(value = BASE_PATH + "/{bindingId}", method = RequestMethod.PUT) public ResponseEntity<ServiceInstanceBindingResponse> bindServiceInstance( @PathVariable("instanceId") String instanceId, @PathVariable("bindingId") String bindingId, @Valid @RequestBody ServiceInstanceBindingRequest request) throws ServiceInstanceDoesNotExistException, ServiceInstanceBindingExistsException, ServiceBrokerException { logger.debug( "PUT: " + BASE_PATH + "/{bindingId}" + ", bindServiceInstance(), serviceInstance.id = " + instanceId + ", bindingId = " + bindingId); ServiceInstance instance = serviceInstanceService.getServiceInstance(instanceId); if (instance == null) { throw new ServiceInstanceDoesNotExistException(instanceId); } ServiceInstanceBinding binding = serviceInstanceBindingService.createServiceInstanceBinding( bindingId, instance, request.getServiceDefinitionId(), request.getPlanId(), request.getAppGuid()); logger.debug("ServiceInstanceBinding Created: " + binding.getId()); return new ResponseEntity<ServiceInstanceBindingResponse>( new ServiceInstanceBindingResponse(binding), HttpStatus.CREATED); }
@Test public void testCreateInstance_success_shouldStoreInstanceDataInBrokerStore() throws Exception { ServiceInstance instance = getServiceInstance("instanceId2", "fake-bare-plan"); CreateServiceInstanceRequest request = getCreateInstanceRequest(instance); instanceService.createServiceInstance(request); ServiceInstance serviceInstance = instanceService.getServiceInstance("instanceId2"); assertThat(request.getServiceInstanceId(), equalTo(serviceInstance.getServiceInstanceId())); // todo: compare all of the fields }