@Test public void testRemoveGroup() throws Exception { groupDao.add(TestData.Group.getTestData()); assertNotNull(groupDao.findByName(TestData.DIRECTORY_ID, TestData.Group.NAME)); groupDao.remove(TestData.Group.getTestData()); try { groupDao.findByName(TestData.DIRECTORY_ID, TestData.Group.NAME); fail("Should have thrown a user not found exception"); } catch (GroupNotFoundException e) { assertEquals(TestData.Group.NAME, e.getGroupName()); } }
@Test public void testAddAndFindGroupByName() throws Exception { final Group createdGroup = groupDao.add(TestData.Group.getTestData()); TestData.Group.assertEqualsTestGroup(createdGroup); final Group retrievedGroup = groupDao.findByName(TestData.DIRECTORY_ID, TestData.Group.NAME); TestData.Group.assertEqualsTestGroup(retrievedGroup); }
@Test public void testUpdateGroup() throws Exception { final Group createdGroup = groupDao.add(TestData.Group.getTestData()); TestData.Group.assertEqualsTestGroup(createdGroup); final boolean updatedIsActive = false; final String updatedDescription = "updated Description"; groupDao.update( TestData.Group.getGroup( createdGroup.getName(), createdGroup.getDirectoryId(), updatedIsActive, updatedDescription, createdGroup.getType())); final Group updatedGroup = groupDao.findByName(TestData.DIRECTORY_ID, TestData.Group.NAME); assertEquals(TestData.Group.NAME, updatedGroup.getName()); assertEquals(TestData.DIRECTORY_ID, updatedGroup.getDirectoryId()); assertEquals(TestData.Group.TYPE, updatedGroup.getType()); assertEquals(updatedIsActive, updatedGroup.isActive()); assertEquals(updatedDescription, updatedGroup.getDescription()); }