@Test
  public void duplicateServiceInstanceCreationFails() throws Exception {
    ServiceInstance instance = ServiceInstanceFixture.getServiceInstance();

    String url = ServiceInstanceController.BASE_PATH + "/" + instance.getId();
    String body = ServiceInstanceFixture.getCreateServiceInstanceRequestJson();

    serviceInstanceService.createServiceInstance(
        ServiceFixture.getService(),
        instance.getId(),
        instance.getPlanId(),
        instance.getOrganizationGuid(),
        instance.getSpaceGuid());

    mockMvc
        .perform(
            put(url)
                .contentType(MediaType.APPLICATION_JSON)
                .content(body)
                .accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isConflict());

    serviceInstanceService.deleteServiceInstance(
        instance.getId(), instance.getServiceDefinitionId(), instance.getPlanId());
  }
  @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));
  }
  @Test
  public void deleteUnknownServiceInstanceFails() throws Exception {
    ServiceInstance instance = ServiceInstanceFixture.getServiceInstanceTwo();

    String url =
        ServiceInstanceController.BASE_PATH
            + "/"
            + instance.getId()
            + "?service_id="
            + instance.getServiceDefinitionId()
            + "&plan_id="
            + instance.getPlanId();

    mockMvc
        .perform(delete(url).accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isNotFound());
  }