Search in sources :

Example 66 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class MarketplaceRESTControllerTest method testMarketplaceEntriesFeed.

@Test
public void testMarketplaceEntriesFeed() {
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    MarketplaceEntry entry = new MarketplaceEntry(null, null, person);
    Set<MarketplaceEntry> marketplaceEntries = new HashSet<MarketplaceEntry>();
    marketplaceEntries.add(entry);
    ImmutableSet<MarketplaceEntry> entries = ImmutableSet.copyOf(marketplaceEntries);
    Mockito.when(marketplaceService.browseableMarketplaceEntriesFor(person, Collections.emptySet())).thenReturn(entries);
    ModelAndView modelAndView = marketplaceRESTController.marketplaceEntriesFeed(req);
    Set<MarketplaceEntry> returnEntries = (Set<MarketplaceEntry>) modelAndView.getModel().get("portlets");
    Assert.assertEquals(1L, entries.size());
}
Also used : IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 67 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class MarketplaceRESTControllerTest method testMarketplaceEntriesFeedNull.

@Test
public void testMarketplaceEntriesFeedNull() {
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(marketplaceService.browseableMarketplaceEntriesFor(person, Collections.emptySet())).thenReturn(null);
    ModelAndView modelAndView = marketplaceRESTController.marketplaceEntriesFeed(req);
    Assert.assertNull(modelAndView.getModel().get("portlets"));
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 68 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class MarketplaceRESTControllerTest method testMarketplaceEntriesFeedNoContent.

@Test
public void testMarketplaceEntriesFeedNoContent() {
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(marketplaceService.browseableMarketplaceEntriesFor(person, Collections.emptySet())).thenReturn(null);
    ModelAndView modelAndView = marketplaceRESTController.marketplaceEntriesFeed(req);
    Set<MarketplaceEntry> returnEntries = (Set<MarketplaceEntry>) modelAndView.getModel().get("portlets");
    Assert.assertNull(returnEntries);
}
Also used : IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 69 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PeopleRESTControllerTest method testGetPeople.

@Test
public void testGetPeople() {
    List<String> searchTerms = new ArrayList<>();
    searchTerms.add("q1");
    searchTerms.add("q2");
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    person.setFullName("john doe");
    List<IPersonAttributes> personAttributes = getIPersonAttributes();
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(lookupHelper.searchForPeople(Mockito.any(), Mockito.anyMap())).thenReturn(personAttributes);
    ModelAndView modelAndView = peopleRESTController.getPeople(searchTerms, req, res);
    Assert.assertEquals("json", modelAndView.getViewName());
    List<IPersonAttributes> persons = (List<IPersonAttributes>) modelAndView.getModel().get("people");
    Assert.assertEquals(1L, persons.size());
}
Also used : IPerson(org.apereo.portal.security.IPerson) IPersonAttributes(org.apereo.services.persondir.IPersonAttributes) PersonImpl(org.apereo.portal.security.provider.PersonImpl) NamedPersonImpl(org.apereo.services.persondir.support.NamedPersonImpl) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 70 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PeopleRESTControllerTest method testGetPerson.

@Test
public void testGetPerson() {
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(lookupHelper.findPerson(person, USER_NAME)).thenReturn(getNamedPerson());
    ModelAndView modelAndView = peopleRESTController.getPerson(USER_NAME, req, res);
    IPersonAttributes returnperson = (IPersonAttributes) modelAndView.getModel().get("person");
    Assert.assertEquals("json", modelAndView.getViewName());
    Assert.assertNotNull(returnperson);
    Assert.assertEquals(2L, returnperson.getAttributes().get("school").size());
}
Also used : IPerson(org.apereo.portal.security.IPerson) IPersonAttributes(org.apereo.services.persondir.IPersonAttributes) PersonImpl(org.apereo.portal.security.provider.PersonImpl) NamedPersonImpl(org.apereo.services.persondir.support.NamedPersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Aggregations

IPerson (org.apereo.portal.security.IPerson)198 Test (org.junit.Test)52 PersonImpl (org.apereo.portal.security.provider.PersonImpl)45 ModelAndView (org.springframework.web.servlet.ModelAndView)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)34 HttpServletRequest (javax.servlet.http.HttpServletRequest)32 IUserInstance (org.apereo.portal.user.IUserInstance)27 HashMap (java.util.HashMap)25 HttpSession (javax.servlet.http.HttpSession)22 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)22 ArrayList (java.util.ArrayList)20 EntityIdentifier (org.apereo.portal.EntityIdentifier)18 ISecurityContext (org.apereo.portal.security.ISecurityContext)17 IPersonAttributes (org.apereo.services.persondir.IPersonAttributes)17 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)15 List (java.util.List)14 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 Map (java.util.Map)11 Set (java.util.Set)11 IUserProfile (org.apereo.portal.IUserProfile)11