Skip to content

Commit

Permalink
LPS-83339 Sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Gonzalez authored and brianchandotcom committed Jul 12, 2018
1 parent 5f636e2 commit 901f4d0
Showing 1 changed file with 56 additions and 52 deletions.
Expand Up @@ -124,11 +124,10 @@ public void testAddSharingEntryActionIds() throws Exception {
RandomTestUtil.randomLong(), RandomTestUtil.randomLong(),
_group.getGroupId(),
Arrays.asList(
SharingEntryActionKey.VIEW,
SharingEntryActionKey.ADD_DISCUSSION),
SharingEntryActionKey.UPDATE, SharingEntryActionKey.VIEW),
serviceContext);

Assert.assertEquals(5, sharingEntry.getActionIds());
Assert.assertEquals(3, sharingEntry.getActionIds());

serviceContext = ServiceContextTestUtil.getServiceContext(
_group.getGroupId());
Expand All @@ -138,10 +137,11 @@ public void testAddSharingEntryActionIds() throws Exception {
RandomTestUtil.randomLong(), RandomTestUtil.randomLong(),
_group.getGroupId(),
Arrays.asList(
SharingEntryActionKey.UPDATE, SharingEntryActionKey.VIEW),
SharingEntryActionKey.VIEW,
SharingEntryActionKey.ADD_DISCUSSION),
serviceContext);

Assert.assertEquals(3, sharingEntry.getActionIds());
Assert.assertEquals(5, sharingEntry.getActionIds());

serviceContext = ServiceContextTestUtil.getServiceContext(
_group.getGroupId());
Expand Down Expand Up @@ -281,38 +281,6 @@ public void testDeleteSharingEntry() throws Exception {
sharingEntry.getSharingEntryId()));
}

@Test
public void testHasSharingPermissionWithViewAndAddDiscussionSharingEntryActionKey()
throws Exception {

long classNameId = RandomTestUtil.randomLong();
long classPK = RandomTestUtil.randomLong();

ServiceContext serviceContext =
ServiceContextTestUtil.getServiceContext(_group.getGroupId());

_sharingEntryLocalService.addSharingEntry(
_fromUser.getUserId(), _toUser.getUserId(), classNameId, classPK,
_group.getGroupId(),
Arrays.asList(
SharingEntryActionKey.VIEW,
SharingEntryActionKey.ADD_DISCUSSION),
serviceContext);

Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.ADD_DISCUSSION));
}

@Test(expected = InvalidSharingEntryActionKeyException.class)
public void testHasSharingPermissionWithoutViewSharingEntryActionKey()
throws Exception {
Expand Down Expand Up @@ -346,18 +314,18 @@ public void testHasSharingPermissionWithUpdateViewSharingEntryActionKey()
SharingEntryActionKey.UPDATE, SharingEntryActionKey.VIEW),
serviceContext);

Assert.assertTrue(
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertFalse(
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.ADD_DISCUSSION));
SharingEntryActionKey.VIEW));
}

@Test
Expand All @@ -380,15 +348,15 @@ public void testHasSharingPermissionWithUpdateViewSharingEntryActionKeyFromUserI
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_fromUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_fromUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_fromUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.ADD_DISCUSSION));
SharingEntryActionKey.VIEW));
}

@Test
Expand All @@ -401,15 +369,15 @@ public void testHasSharingPermissionWithUserNotHavingSharingEntryActionKey()
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.ADD_DISCUSSION));
SharingEntryActionKey.VIEW));
}

@Test
Expand All @@ -433,15 +401,47 @@ public void testHasSharingPermissionWithViewAddDiscussionSharingEntryActionKey()
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
}

@Test
public void testHasSharingPermissionWithViewAndAddDiscussionSharingEntryActionKey()
throws Exception {

long classNameId = RandomTestUtil.randomLong();
long classPK = RandomTestUtil.randomLong();

ServiceContext serviceContext =
ServiceContextTestUtil.getServiceContext(_group.getGroupId());

_sharingEntryLocalService.addSharingEntry(
_fromUser.getUserId(), _toUser.getUserId(), classNameId, classPK,
_group.getGroupId(),
Arrays.asList(
SharingEntryActionKey.VIEW,
SharingEntryActionKey.ADD_DISCUSSION),
serviceContext);

Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
}

@Test
Expand All @@ -459,14 +459,18 @@ public void testHasSharingPermissionWithViewSharingEntryActionKey()
_group.getGroupId(), Arrays.asList(SharingEntryActionKey.VIEW),
serviceContext);

Assert.assertTrue(
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
}

@Test
Expand All @@ -486,18 +490,18 @@ public void testHasSharingPermissionWithViewUpdateSharingEntryActionKey()
SharingEntryActionKey.VIEW, SharingEntryActionKey.UPDATE),
serviceContext);

Assert.assertTrue(
Assert.assertFalse(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.VIEW));
SharingEntryActionKey.ADD_DISCUSSION));
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.UPDATE));
Assert.assertFalse(
Assert.assertTrue(
_sharingEntryLocalService.hasSharingPermission(
_toUser.getUserId(), classNameId, classPK,
SharingEntryActionKey.ADD_DISCUSSION));
SharingEntryActionKey.VIEW));
}

@DeleteAfterTestRun
Expand Down

0 comments on commit 901f4d0

Please sign in to comment.