/**
   * Accuracy test for the method <code>
   * saveProjectMetadataKey(DirectProjectMetadataKey projectMetadataKey,
   * long userId)</code>.<br>
   * The result should be correct.
   *
   * @throws Exception to JUnit.
   */
  @Test
  public void test_saveProjectMetadataKey_2() 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.saveProjectMetadataKey(projectMetadataKey, userId);
    em.getTransaction().commit();

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

    assertEquals(
        "'saveProjectMetadataKey' should be correct.", "name3", directProjectMetadataKey.getName());
    assertEquals(
        "'saveProjectMetadataKey' should be correct.",
        "new description",
        directProjectMetadataKey.getDescription());
    assertNull(
        "'saveProjectMetadataKey' should be correct.", directProjectMetadataKey.getClientId());
    assertNull(
        "'saveProjectMetadataKey' should be correct.", directProjectMetadataKey.getGrouping());
    assertTrue("'saveProjectMetadataKey' should be correct.", directProjectMetadataKey.isSingle());
  }
  /**
   * Accuracy test for the method <code>
   * saveProjectMetadataKey(DirectProjectMetadataKey projectMetadataKey,
   * long userId)</code>.<br>
   * The result should be correct.
   *
   * @throws Exception to JUnit.
   */
  @Test
  public void test_saveProjectMetadataKey_1() throws Exception {
    em.getTransaction().begin();
    instance.saveProjectMetadataKey(projectMetadataKey, userId);
    em.getTransaction().commit();

    Query query =
        em.createQuery(
            "SELECT directProjectMetadataKey FROM DirectProjectMetadataKey directProjectMetadataKey"
                + " WHERE name = 'name3'");

    DirectProjectMetadataKey directProjectMetadataKey =
        (DirectProjectMetadataKey) query.getSingleResult();

    assertEquals(
        "'saveProjectMetadataKey' should be correct.", "name3", directProjectMetadataKey.getName());
    assertEquals(
        "'saveProjectMetadataKey' should be correct.",
        "some text",
        directProjectMetadataKey.getDescription());
    assertNull(
        "'saveProjectMetadataKey' should be correct.", directProjectMetadataKey.getClientId());
    assertNull(
        "'saveProjectMetadataKey' should be correct.", directProjectMetadataKey.getGrouping());
    assertTrue("'saveProjectMetadataKey' should be correct.", directProjectMetadataKey.isSingle());
  }
  /**
   * Failure test for the method <code>
   * saveProjectMetadataKey(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_saveProjectMetadataKey_ValidationError() throws Exception {
    projectMetadataKey.setClientId(1L);

    instance.saveProjectMetadataKey(projectMetadataKey, userId);
  }
  /**
   * Failure test for the method <code>
   * saveProjectMetadataKey(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_saveProjectMetadataKey_projectMetadataKeyNull() throws Exception {
    projectMetadataKey = null;

    instance.saveProjectMetadataKey(projectMetadataKey, userId);
  }