@Test public void testAddAndStoreAttributesAndFindGroupWithAttributesByName() throws Exception { final Group createdGroup = groupDao.add(TestData.Group.getTestData()); TestData.Group.assertEqualsTestGroup(createdGroup); groupDao.storeAttributes(createdGroup, TestData.Attributes.getTestData()); final GroupWithAttributes retrievedGroup = groupDao.findByNameWithAttributes(TestData.DIRECTORY_ID, TestData.Group.NAME); TestData.Group.assertEqualsTestGroup(retrievedGroup); TestData.Attributes.assertEqualsTestData(retrievedGroup); }
@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 testRemoveAttribute() throws Exception { final Group createdGroup = groupDao.add(TestData.Group.getTestData()); groupDao.storeAttributes(createdGroup, TestData.Attributes.getTestData()); TestData.Attributes.assertEqualsTestData( groupDao.findByNameWithAttributes(TestData.DIRECTORY_ID, TestData.Group.NAME)); groupDao.removeAttribute(createdGroup, TestData.Attributes.ATTRIBUTE1); final GroupWithAttributes groupWithLessAttributes = groupDao.findByNameWithAttributes(TestData.DIRECTORY_ID, TestData.Group.NAME); assertNull(groupWithLessAttributes.getValue(TestData.Attributes.ATTRIBUTE1)); }
@Test public void testRemoveAttribute() throws Exception { final User createdUser = userDao.add(TestData.User.getTestData(), TestData.User.CREDENTIAL); userDao.storeAttributes(createdUser, TestData.Attributes.getTestData()); TestData.Attributes.assertEqualsTestData( userDao.findByNameWithAttributes(TestData.DIRECTORY_ID, TestData.User.NAME)); userDao.removeAttribute(createdUser, TestData.Attributes.ATTRIBUTE1); final UserWithAttributes userWithLessAttributes = userDao.findByNameWithAttributes(TestData.DIRECTORY_ID, TestData.User.NAME); assertNull(userWithLessAttributes.getValue(TestData.Attributes.ATTRIBUTE1)); }