Skip to content

Instantly share code, notes, and snippets.

@laszlocsontos
Created September 20, 2013 07:26
Show Gist options
  • Save laszlocsontos/6634321 to your computer and use it in GitHub Desktop.
Save laszlocsontos/6634321 to your computer and use it in GitHub Desktop.
diff --git a/portal-impl/src/com/liferay/portal/service/impl/RoleLocalServiceImpl.java b/portal-impl/src/com/liferay/portal/service/impl/RoleLocalServiceImpl.java
index 65167cc..e6c8cf1 100644
--- a/portal-impl/src/com/liferay/portal/service/impl/RoleLocalServiceImpl.java
+++ b/portal-impl/src/com/liferay/portal/service/impl/RoleLocalServiceImpl.java
@@ -828,7 +828,7 @@ public class RoleLocalServiceImpl extends RoleLocalServiceBaseImpl {
public Collection<Role> getTeamRoles(long groupId, long[] skipRoleIds)
throws PortalException, SystemException {
- Map<Team, Role> roles = getTeamRoleMap(groupId, null);
+ Map<Team, Role> roles = getTeamRoleMap(groupId, skipRoleIds);
return roles.values();
}
diff --git a/portal-impl/test/integration/com/liferay/portal/service/RoleLocalServiceTest.java b/portal-impl/test/integration/com/liferay/portal/service/RoleLocalServiceTest.java
index 1acfd959..4559d20 100644
--- a/portal-impl/test/integration/com/liferay/portal/service/RoleLocalServiceTest.java
+++ b/portal-impl/test/integration/com/liferay/portal/service/RoleLocalServiceTest.java
@@ -33,6 +33,7 @@ import com.liferay.portal.util.GroupTestUtil;
import com.liferay.portal.util.LayoutTestUtil;
import com.liferay.portal.util.TestPropsValues;
+import java.util.Collection;
import java.util.Map;
import org.junit.BeforeClass;
@@ -58,6 +59,29 @@ public class RoleLocalServiceTest {
IndexerRegistryUtil.unregister(Organization.class.getName());
}
+ @Test
+ public void testGetTeamRoleMapWithExclusion() throws Exception {
+ Object[] objects = prepareOrganization();
+
+ Organization organization = (Organization)objects[0];
+ Team team = (Team)objects[1];
+
+ Map<Team, Role> teamRoleMap = RoleLocalServiceUtil.getTeamRoleMap(
+ organization.getGroupId());
+
+ Role role = teamRoleMap.get(team);
+
+ Assert.assertNotNull(role);
+
+ long[] excludedRoleIds = new long[] {role.getRoleId()};
+
+ Collection<Role> roles = RoleLocalServiceUtil.getTeamRoles(
+ organization.getGroupId(), excludedRoleIds);
+
+ Assert.assertNotNull(roles);
+ Assert.assertTrue(roles.isEmpty());
+ }
+
@Test(expected = NoSuchGroupException.class)
public void testGetTeamRoleMapWithInvalidGroupId() throws Exception {
RoleLocalServiceUtil.getTeamRoleMap(0L);
@@ -74,7 +98,7 @@ public class RoleLocalServiceTest {
Map<Team, Role> teamRoleMap = RoleLocalServiceUtil.getTeamRoleMap(
organization.getGroupId());
- doTest(teamRoleMap, team, true);
+ doTestGetTeamRoleMap(teamRoleMap, team, false);
}
@Test
@@ -87,7 +111,7 @@ public class RoleLocalServiceTest {
Map<Team, Role> teamRoleMap = RoleLocalServiceUtil.getTeamRoleMap(
organization.getGroupId());
- doTest(teamRoleMap, team, false);
+ doTestGetTeamRoleMap(teamRoleMap, team, true);
}
@Test
@@ -106,25 +130,25 @@ public class RoleLocalServiceTest {
Map<Team, Role> teamRoleMap = RoleLocalServiceUtil.getTeamRoleMap(
group.getGroupId());
- doTest(teamRoleMap, team, false);
+ doTestGetTeamRoleMap(teamRoleMap, team, true);
}
- protected void doTest(
- Map<Team, Role> teamRoleMap, Team team, boolean otherGroup) {
+ protected void doTestGetTeamRoleMap(
+ Map<Team, Role> teamRoleMap, Team team, boolean shouldContain) {
Assert.assertNotNull(teamRoleMap);
Assert.assertFalse(teamRoleMap.isEmpty());
- if (otherGroup) {
- Assert.assertFalse(teamRoleMap.containsKey(team));
- }
- else {
+ if (shouldContain) {
Assert.assertTrue(teamRoleMap.containsKey(team));
Role role = teamRoleMap.get(team);
Assert.assertEquals(role.getType(), RoleConstants.TYPE_PROVIDER);
}
+ else {
+ Assert.assertFalse(teamRoleMap.containsKey(team));
+ }
}
protected Object[] prepareOrganization() throws Exception {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment