/**
   * Accuracy test for the method <code>
   * updateProjectMetadataKey(DirectProjectMetadataKey projectMetadataKey,
   * long userId)</code>.<br>
   * The result should be correct.
   *
   * @throws Exception to JUnit.
   */
  @Test
  public void test_updateProjectMetadataKey() throws Exception {
    em.getTransaction().begin();
    instance.createProjectMetadataKey(projectMetadataKey, userId);
    em.getTransaction().commit();

    projectMetadataKey.setDescription("new description");
    projectMetadataKey.setPredefinedValues(new ArrayList<DirectProjectMetadataPredefinedValue>());
    em.getTransaction().begin();
    instance.updateProjectMetadataKey(projectMetadataKey, userId);
    em.getTransaction().commit();

    DirectProjectMetadataKey directProjectMetadataKey =
        em.find(DirectProjectMetadataKey.class, projectMetadataKey.getId());

    assertEquals(
        "'updateProjectMetadataKey' should be correct.",
        "name3",
        directProjectMetadataKey.getName());
    assertEquals(
        "'updateProjectMetadataKey' should be correct.",
        "new description",
        directProjectMetadataKey.getDescription());
    assertNull(
        "'updateProjectMetadataKey' should be correct.", directProjectMetadataKey.getClientId());
    assertNull(
        "'updateProjectMetadataKey' should be correct.", directProjectMetadataKey.getGrouping());
    assertTrue(
        "'updateProjectMetadataKey' should be correct.", directProjectMetadataKey.isSingle());
  }
  /**
   * Failure test for the method <code>
   * updateProjectMetadataKey(DirectProjectMetadataKey projectMetadataKey,
   * long userId)</code> with requested entity is not found in db.<br>
   * <code>EntityNotFoundException</code> is expected.
   *
   * @throws Exception to JUnit.
   */
  @Test(expected = EntityNotFoundException.class)
  public void test_updateProjectMetadataKey_EntityNotFoundError() throws Exception {
    projectMetadataKey.setId(Long.MAX_VALUE);

    instance.updateProjectMetadataKey(projectMetadataKey, userId);
  }
  /**
   * Failure test for the method <code>
   * updateProjectMetadataKey(DirectProjectMetadataKey projectMetadataKey,
   * long userId)</code> with entity fails the validation.<br>
   * <code>ValidationException</code> is expected.
   *
   * @throws Exception to JUnit.
   */
  @Test(expected = ValidationException.class)
  public void test_updateProjectMetadataKey_ValidationError() throws Exception {
    projectMetadataKey.setClientId(1L);

    instance.updateProjectMetadataKey(projectMetadataKey, userId);
  }
  /**
   * Failure test for the method <code>
   * updateProjectMetadataKey(DirectProjectMetadataKey projectMetadataKey,
   * long userId)</code> with projectMetadataKey is <code>null</code>.<br>
   * <code>IllegalArgumentException</code> is expected.
   *
   * @throws Exception to JUnit.
   */
  @Test(expected = IllegalArgumentException.class)
  public void test_updateProjectMetadataKey_projectMetadataKeyNull() throws Exception {
    projectMetadataKey = null;

    instance.updateProjectMetadataKey(projectMetadataKey, userId);
  }