@PreAcquireNamespaceLock
  @PostMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items")
  public ItemDTO create(@PathVariable("appId") String appId,
                        @PathVariable("clusterName") String clusterName,
                        @PathVariable("namespaceName") String namespaceName, @RequestBody ItemDTO dto) {
    Item entity = BeanUtils.transform(Item.class, dto);

    Item managedEntity = itemService.findOne(appId, clusterName, namespaceName, entity.getKey());
    if (managedEntity != null) {
      throw BadRequestException.itemAlreadyExists(entity.getKey());
    }
    entity = itemService.save(entity);
    dto = BeanUtils.transform(ItemDTO.class, entity);
    commitService.createCommit(appId, clusterName, namespaceName, new ConfigChangeContentBuilder().createItem(entity).build(),
        dto.getDataChangeLastModifiedBy()
    );

    return dto;
  }
@Test
  @Sql(scripts = "/controller/test-itemset.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
  @Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
  public void 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";
    String itemValue = "test-value";
    ItemDTO item = new ItemDTO(itemKey, itemValue, "", 1);
    assert namespace != null;
    item.setNamespaceId(namespace.getId());
    item.setDataChangeLastModifiedBy("apollo");

    ResponseEntity<ItemDTO> response = restTemplate.postForEntity(itemBaseUrl(),
        item, ItemDTO.class, app.getAppId(), cluster.getName(), namespace.getNamespaceName());
    Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
    Assert.assertEquals(itemKey, Objects.requireNonNull(response.getBody()).getKey());

    List<Commit> commitList = commitRepository.findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(app.getAppId(), cluster.getName(), namespace.getNamespaceName(),
        Pageable.ofSize(10));
    Assert.assertEquals(1, commitList.size());

    Commit commit = commitList.get(0);
    Assert.assertTrue(commit.getChangeSets().contains(itemKey));
    Assert.assertTrue(commit.getChangeSets().contains(itemValue));
  }