@PreAcquireNamespaceLock
  @DeleteMapping("/items/{itemId}")
  public void delete(@PathVariable("itemId") long itemId, @RequestParam String operator) {
    Item entity = itemService.findOne(itemId);
    if (entity == null) {
      throw NotFoundException.itemNotFound(itemId);
    }
    itemService.delete(entity.getId(), operator);

    Namespace namespace = namespaceService.findOne(entity.getNamespaceId());

    commitService.createCommit(namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName(),
        new ConfigChangeContentBuilder().deleteItem(entity).build(), operator
    );

  }
@Test
  @Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
  @Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
  public void testDelete() {
    this.testCreate();

    String appId = "someAppId";
    AppDTO app = restTemplate.getForObject(appBaseUrl(), AppDTO.class, appId);
    assert app != null;
    ClusterDTO cluster = restTemplate.getForObject(clusterBaseUrl(), ClusterDTO.class, app.getAppId(), "default");
    assert cluster != null;
    NamespaceDTO namespace = restTemplate.getForObject(namespaceBaseUrl(),
        NamespaceDTO.class, app.getAppId(), cluster.getName(), "application");

    String itemKey = "test-key";

    long itemId = itemRepository.findByKey(itemKey, Pageable.ofSize(1))
        .getContent()
        .get(0)
        .getId();

    String deleteUrl = url(  "/items/{itemId}?operator=apollo");
    restTemplate.delete(deleteUrl, itemId);
    assertThat(itemRepository.findById(itemId).isPresent())
        .isFalse();

    assert namespace != null;
    List<Commit> commitList = commitRepository.findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(app.getAppId(), cluster.getName(), namespace.getNamespaceName(),
        Pageable.ofSize(10));
    assertThat(commitList).hasSize(2);
  }