@Test public void getSecondaryGroupsWithNullReturnsEmptyList() throws IllegalAccessException, InstantiationException, MalformedURLException, SQLException { groups = " "; when(result.getString(configuration.webappSecondaryGroupGroupIDColumn)).thenReturn(null); List<String> secondaryGroups = webGroupDao.getSecondaryGroupIDs(USER_ID); assertEquals(0, secondaryGroups.size()); }
@Test public void getSecondaryGroupsReturnsOnlyGroupIDs() throws IllegalAccessException, InstantiationException, MalformedURLException, SQLException { groups = " , " + group2; when(result.getString(configuration.webappSecondaryGroupGroupIDColumn)).thenReturn(groups); List<String> secondaryGroups = webGroupDao.getSecondaryGroupIDs(USER_ID); assertEquals(1, secondaryGroups.size()); assertTrue(secondaryGroups.contains(group2)); }
@Test public void getSecondaryGroupsReturnsOneGroupID() throws IllegalAccessException, InstantiationException, MalformedURLException, SQLException { groups = RandomStringUtils.randomNumeric(2); when(result.getString(configuration.webappSecondaryGroupGroupIDColumn)).thenReturn(groups); List<String> secondaryGroups = webGroupDao.getSecondaryGroupIDs(USER_ID); assertEquals(1, secondaryGroups.size()); assertEquals(groups, secondaryGroups.get(0)); }
@Test public void getSecondaryGroupsWhenSecondaryDisableReturnsEmptyList() throws IllegalAccessException, InstantiationException, MalformedURLException, SQLException { configuration.webappSecondaryGroupEnabled = false; assertEquals(0, webGroupDao.getSecondaryGroupIDs("").size()); }
@Test public void getSecondaryGroupsShouldHandleNoResult() throws IllegalAccessException, InstantiationException, MalformedURLException, SQLException { when(result.next()).thenReturn(false); assertNotNull(webGroupDao.getSecondaryGroupIDs(USER_ID)); }