use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testFromMarketplacePortletDefinition.
@Test
public void testFromMarketplacePortletDefinition() {
Long id = 345L;
String name = "testName";
String[] keywords = new String[] { "val1", "val2" };
List<IPortletPreference> prefs = new ArrayList<>();
prefs.add(portletPref);
Mockito.when(portletPref.getName()).thenReturn("keywords");
Mockito.when(portletPref.getValues()).thenReturn(keywords);
Map<String, IPortletDefinitionParameter> params = new HashMap<>();
params.put("test1", portletDefParam);
MarketplacePortletDefinition mpd = buildMarketplacePortletDefinition(id, name, prefs, params);
PortletDefinitionBean pdb = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd, Locale.ENGLISH, false);
assertEquals(averageRating, pdb.getAverageRating());
assertEquals(id, (Long) pdb.getId());
assertEquals(fName, pdb.getFname());
assertEquals(title, pdb.getTitle());
assertEquals(name, pdb.getName());
assertEquals(description, pdb.getDescription());
assertEquals(state.toString(), pdb.getState());
assertEquals(typeId, pdb.getTypeId());
assertEquals(usersRated, (Long) pdb.getRatingsCount());
assertEquals(params, pdb.getParameters());
assertEquals(Arrays.asList(keywords), pdb.getKeywords());
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testCompareToDifferent.
@Test
public void testCompareToDifferent() {
String name1 = "testName1";
String name2 = "testName2";
MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(678L, name1, null, null);
MarketplacePortletDefinition mpd2 = buildMarketplacePortletDefinition(678L, name2, null, null);
PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
PortletDefinitionBean pdb2 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd2, Locale.ENGLISH, false);
assertEquals(name1.compareTo(name2), pdb1.compareTo(pdb2));
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testFromMarketplacePortletDefinitionHashCode.
@Test
public void testFromMarketplacePortletDefinitionHashCode() {
MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(678L, "testName1", null, null);
MarketplacePortletDefinition mpd2 = buildMarketplacePortletDefinition(678L, "testName2", null, null);
PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
PortletDefinitionBean pdb2 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd2, Locale.ENGLISH, false);
assertEquals(pdb1.hashCode(), pdb2.hashCode());
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testEqualsSameID.
@Test
public void testEqualsSameID() {
Long id1 = 678L;
Long id2 = 678L;
MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(id1, "testName", null, null);
MarketplacePortletDefinition mpd2 = buildMarketplacePortletDefinition(id2, "testName", null, null);
PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
PortletDefinitionBean pdb2 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd2, Locale.ENGLISH, false);
assertTrue(pdb1.equals(pdb2));
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class ChannelListController method preparePortletDefinitionBean.
private PortletDefinitionBean preparePortletDefinitionBean(WebRequest req, IPortletDefinition portlet, Locale locale) {
MarketplacePortletDefinition mktpd = marketplaceService.getOrCreateMarketplacePortletDefinition(portlet);
PortletDefinitionBean rslt = PortletDefinitionBean.fromMarketplacePortletDefinition(mktpd, locale);
// See api docs for postProcessIconUrlParameter() below
IPortletDefinitionParameter iconParameter = rslt.getParameters().get(ICON_URL_PARAMETER_NAME);
if (iconParameter != null) {
IPortletDefinitionParameter evaluated = postProcessIconUrlParameter(iconParameter, req);
rslt.putParameter(evaluated);
}
return rslt;
}
Aggregations