### Question:
UserBanner { public List<Group> getBannedUsersGroups() { List<Group> bannedUserGroups = groupDao.getByName(BANNED_USERS_GROUP_NAME); if (bannedUserGroups.isEmpty()) { bannedUserGroups.add(createBannedUserGroup()); } return bannedUserGroups; } UserBanner(GroupDao groupDao, UserDao userDao); List<PoulpeUser> getAllBannedUsers(); List<PoulpeUser> getNonBannedUsersByUsername(String availableFilterText, Pagination pagination); void banUsers(UserList usersToBan); void revokeBan(UserList usersToRevoke); List<Group> getBannedUsersGroups(); static final String BANNED_USERS_GROUP_NAME; }### Answer:
@Test public void testGetBannedUsersGroup_withoutGroups() throws Exception { doReturn(new ArrayList<Group>()).when(groupDao).getByNameContains("Banned Users"); List<Group> bannedUsersGroupsActual = sut.getBannedUsersGroups(); assertEquals(bannedUsersGroupsActual.get(0).getName(), "Banned Users"); }
@Test public void testGetBannedUsersGroup_withoutExistGroups() throws Exception { doReturn(Arrays.asList(new Group("Banned Users"))).when(groupDao).getByNameContains("Banned Users"); List<Group> bannedUsersGroupsActual = sut.getBannedUsersGroups(); assertEquals(bannedUsersGroupsActual.get(0).getName(), "Banned Users"); }