@Test
  public void testAddAndFindUserByName() throws Exception {
    final User createdUser = userDao.add(TestData.User.getTestData(), TestData.User.CREDENTIAL);

    TestData.User.assertEqualsTestUser(createdUser);

    final User retrievedUser = userDao.findByName(TestData.DIRECTORY_ID, TestData.User.NAME);

    TestData.User.assertEqualsTestUser(retrievedUser);
  }
  @Test
  public void testAddAndStoreAttributesAndFindUserWithAttributesByName() throws Exception {
    final User createdUser = userDao.add(TestData.User.getTestData(), TestData.User.CREDENTIAL);
    TestData.User.assertEqualsTestUser(createdUser);

    userDao.storeAttributes(createdUser, TestData.Attributes.getTestData());

    final UserWithAttributes retrievedUser =
        userDao.findByNameWithAttributes(TestData.DIRECTORY_ID, TestData.User.NAME);
    TestData.User.assertEqualsTestUser(retrievedUser);
    TestData.Attributes.assertEqualsTestData(retrievedUser);
  }
  @Test
  public void testUpdateUser() throws Exception {
    final User createdUser = userDao.add(TestData.User.getTestData(), TestData.User.CREDENTIAL);
    TestData.User.assertEqualsTestUser(createdUser);

    final boolean updatedIsActive = false;
    final String updatedEmail = "*****@*****.**";
    final String updatedFirstName = "updatedFirstName";
    final String updatedLastName = "updatedLastName";
    final String updatedDisplayName = "updatedDisplayName";

    userDao.update(
        TestData.User.getUser(
            createdUser.getName(),
            createdUser.getDirectoryId(),
            updatedIsActive,
            updatedFirstName,
            updatedLastName,
            updatedDisplayName,
            updatedEmail));

    final User updatedUser = userDao.findByName(TestData.DIRECTORY_ID, TestData.User.NAME);

    assertEquals(TestData.User.NAME, updatedUser.getName());
    assertEquals(updatedIsActive, updatedUser.isActive());
    assertEquals(updatedFirstName, updatedUser.getFirstName());
    assertEquals(updatedLastName, updatedUser.getLastName());
    assertEquals(updatedDisplayName, updatedUser.getDisplayName());
    assertEquals(updatedEmail, updatedUser.getEmailAddress());
  }