use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PortletDefinitionImpl method updateLifecycleState.
/**
* In {@link PortletDefinitionImpl}, this overload does all the work. (The other overload
* forwards.) Adding <code>synchronized</code> in case two threads try to modify the collection
* at the same time.
*/
@Override
public synchronized void updateLifecycleState(PortletLifecycleState lifecycleState, IPerson user, Date timestamp) {
/*
* Lifecycle entries that are scheduled for an instant
* on or after the new entry must be cleared.
*/
final Set<IPortletLifecycleEntry> canceledStateChanges = lifecycleEntries.stream().filter(entry -> entry.getDate().compareTo(timestamp) >= 0).collect(Collectors.toSet());
lifecycleEntries.removeAll(canceledStateChanges);
final IPortletLifecycleEntry newEntry = new PortletLifecycleEntryImpl(user.getID(), lifecycleState, timestamp);
lifecycleEntries.add(newEntry);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class UpdatePreferencesServletTest method testRemoveFavorite.
@Test(expected = NullPointerException.class)
public void testRemoveFavorite() throws IOException {
req.setLocalName("en-US");
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
IUserInstance userInstance = new UserInstance(person, null, null);
Mockito.when(userInstanceManager.getUserInstance(req)).thenReturn(userInstance);
ModelAndView modelAndView = updatePreferencesServlet.removeFavorite("channelId", req, res);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PermissionAssignmentMapControllerTest method testDeletePermission.
@Test
public void testDeletePermission() throws Exception {
String[] str = new String[] { "principal1", "principal2" };
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(true);
Mockito.when(permissionAdministrationHelper.canEditPermission(person, "target")).thenReturn(true);
Mockito.when(groupListHelper.getEntityForPrincipal("principal")).thenReturn(null);
permissionAssignmentMapController.deletePermission("principal", "owner", "activity1", "target", req, res);
Assert.assertEquals(200L, res.getStatus());
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PermissionAssignmentMapControllerTest method testUpdatePermissionCannotViewPermission.
@Test
public void testUpdatePermissionCannotViewPermission() throws Exception {
String[] str = new String[] { "principal1", "principal2" };
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(false);
ModelAndView modelAndView = permissionAssignmentMapController.updatePermission("principal", "assignment1", str, "owner", "activity1", "target", req, res);
Assert.assertNull(modelAndView);
Assert.assertEquals(401L, res.getStatus());
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PermissionAssignmentMapControllerTest method testUpdatePermissionNull.
@Test
public void testUpdatePermissionNull() throws Exception {
String[] str = new String[] { "principal1", "principal2" };
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(true);
Mockito.when(groupListHelper.getEntityForPrincipal("principal")).thenReturn(null);
ModelAndView modelAndView = permissionAssignmentMapController.updatePermission("principal", "assignment1", str, "owner", "activity1", "target", req, res);
Assert.assertNull(modelAndView);
}
Aggregations