@Transactional
  public Item update(Item item) {
    checkItemType(item.getType());
    checkItemValueLength(item.getNamespaceId(), item.getValue());
    Item managedItem = itemRepository.findById(item.getId()).orElse(null);
    BeanUtils.copyEntityProperties(item, managedItem);
    managedItem = itemRepository.save(managedItem);

    auditService.audit(Item.class.getSimpleName(), managedItem.getId(), Audit.OP.UPDATE,
                       managedItem.getDataChangeLastModifiedBy());

    return managedItem;
  }
@Test
    @Sql(scripts = "/sql/item-test.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
    @Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
    public void testUpdateItem() {
        Item item = new Item();
        item.setId(9901);
        item.setNamespaceId(1);
        item.setKey("k1");
        item.setType(2);
        item.setValue("v1-new");
        item.setComment("");
        item.setLineNum(1);

        Item dbItem = itemService.update(item);
        Assert.assertEquals(2, dbItem.getType());
        Assert.assertEquals("v1-new", dbItem.getValue());
    }