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());
}
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"));
}
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);
}
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());
}
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());
}
Aggregations