use of com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement in project liferay-ide by liferay.
the class PortletStyleValidationService method compute.
@Override
protected Status compute() {
Element modelElement = context(Element.class);
if (!modelElement.disposed() && modelElement instanceof PortletStyleElement) {
Path path = (Path) modelElement.property(context(ValueProperty.class)).content();
if (path != null) {
String name = path.lastSegment();
IProject project = modelElement.adapt(IProject.class);
boolean fileExisted = new FileCheckVisitor().checkFiles(project, name);
if (!fileExisted) {
return Status.createErrorStatus("File " + path.toPortableString() + " is not existed");
}
} else {
return Status.createErrorStatus("Can not set empty value");
}
}
return Status.createOkStatus();
}
use of com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement in project liferay-ide by liferay.
the class LiferayPortletXmlTest method testLiferayScriptPossibleValuesService.
@Test
public void testLiferayScriptPossibleValuesService() throws Exception {
if (shouldSkipBundleTests())
return;
NewLiferayPluginProjectOp newProjectOp = NewLiferayPluginProjectOp.TYPE.instantiate();
newProjectOp.setProjectName("test-script");
newProjectOp.setPluginType(PluginType.portlet);
newProjectOp.setIncludeSampleCode(true);
newProjectOp.setPortletFramework("mvc");
newProjectOp.setPortletName("testPortlet");
final IProject testProject = createAntProject(newProjectOp);
LiferayPortletXml liferayPortletApp = op(testProject);
for (LiferayPortlet liferayPortlet : liferayPortletApp.getPortlets()) {
ElementList<PortletStyleElement> portletCsses = liferayPortlet.getHeaderPortletCsses();
{
for (PortletStyleElement portletCss : portletCsses) {
final PossibleValuesService scriptService = portletCss.getValue().service(PossibleValuesService.class);
assertEquals(true, scriptService.values().contains("/css/main.css"));
}
}
}
}
use of com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement in project liferay-ide by liferay.
the class LiferayPortletXmlTest method testPortletXmlRead.
@Test
public void testPortletXmlRead() throws Exception {
final LiferayPortletXml portletApp = op(PORTLET_XML);
assertNotNull(portletApp);
final ElementList<LiferayPortlet> portlets = portletApp.getPortlets();
assertNotNull(portlets);
assertEquals(1, portlets.size());
final LiferayPortlet portlet = portlets.get(0);
assertNotNull(portlet);
assertEquals("new", portlet.getPortletName().content());
assertEquals("/icon.png", portlet.getIcon().content().toPortableString());
assertEquals("/testStrutsPath", portlet.getStrutsPath().content());
assertEquals("com.test.configuration.Test", portlet.getConfigurationActionClass().content().toString());
String[] indexerClassNames = { "com.test.index.Test1", "com.test.index.Test2", "com.test.index.Test3" };
final ElementList<IndexerClass> indexerClasses = portlet.getIndexerClasses();
assertNotNull(indexerClasses);
for (IndexerClass indexer : indexerClasses) {
assertEquals(true, Arrays.asList(indexerClassNames).contains(indexer.getValue().toString()));
}
String[] schedulerEntryDescriptions = { "scheduler cron entry test", "scheduler simple entry test" };
String[] schedulerEntryClasses = { "com.test.schedulerEntry.TestScheduler1", "com.test.schedulerEntry.TestScheduler2" };
final ElementList<SchedulerEntry> schedulerEntris = portlet.getSchedulerEntries();
assertNotNull(schedulerEntris);
for (SchedulerEntry schedulerEntry : schedulerEntris) {
assertEquals(true, Arrays.asList(schedulerEntryDescriptions).contains(schedulerEntry.getSchedulerDescription().content()));
assertEquals(true, Arrays.asList(schedulerEntryClasses).contains(schedulerEntry.getSchedulerEventListenerClass().toString()));
ElementHandle<ITrigger> trigger = schedulerEntry.getPortletTrigger();
if (trigger.content() instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) (trigger.content());
ElementHandle<ICronTrigger> cronTriggerDetail = cronTrigger.getCronTrigger();
if (cronTriggerDetail.content() instanceof PropertyCronTrigger) {
PropertyCronTrigger propertyTrigger = (PropertyCronTrigger) cronTriggerDetail.content();
assertEquals("cron", propertyTrigger.getPropertyKey().content());
} else if (cronTriggerDetail.content() instanceof CronTriggerValueTrigger) {
CronTriggerValueTrigger valueTrigger = (CronTriggerValueTrigger) cronTriggerDetail.content();
assertEquals("15", valueTrigger.getCronTriggerValue().content());
}
} else {
SimpleTrigger simpleTrigger = (SimpleTrigger) (trigger.content());
ElementHandle<ISimpleTrigger> simpleTriggerDetail = simpleTrigger.getSimpleTrigger();
if (simpleTriggerDetail.content() instanceof PropertySimpleTrigger) {
PropertySimpleTrigger propertyTrigger = (PropertySimpleTrigger) simpleTriggerDetail.content();
assertEquals("simple", propertyTrigger.getPropertyKey().content());
} else if (simpleTriggerDetail.content() instanceof SimpleTriggerValueTrigger) {
SimpleTriggerValueTrigger valueTrigger = (SimpleTriggerValueTrigger) simpleTriggerDetail.content();
assertEquals("15", valueTrigger.getSimpleTriggerValue().content());
}
assertEquals("minute", simpleTrigger.getTimeUnit().content());
}
}
assertEquals("com.test.friendUrlMapper.Test", portlet.getFriendlyURLMapperClass().content().toString());
assertEquals("test", portlet.getFriendlyURLMapping().toString());
assertEquals("test", portlet.getFriendlyURLRoutes().toString());
assertEquals("com.test.portletDataHandler.Test", portlet.getPortletDataHandlerClass().content().toString());
final ElementList<StagedModelDataHandlerClass> stageHandlers = portlet.getStagedModelDataHandlerClasses();
assertNotNull(stageHandlers);
String[] stageHandlersValue = { "com.test.stagedModelDataHandler.Test1", "com.test.stagedModelDataHandler.Test2", "com.test.stagedModelDataHandler.Test3" };
for (StagedModelDataHandlerClass stageHandler : stageHandlers) {
assertEquals(true, Arrays.asList(stageHandlersValue).contains(stageHandler.getValue().content().toString()));
}
final ElementList<SocialActivityInterpreterClass> socialActivities = portlet.getSocialActivityInterpreterClasses();
assertNotNull(socialActivities);
String[] socialActivityValues = { "com.test.socialActivityListener.Test1", "com.test.socialActivityListener.Test2", "com.test.socialActivityListener.Test3" };
for (SocialActivityInterpreterClass socialActivity : socialActivities) {
assertEquals(true, Arrays.asList(socialActivityValues).contains(socialActivity.getValue().content().toString()));
}
assertEquals("my", portlet.getControlPanelEntryCategory().content());
assertEquals(new Double(1.5), portlet.getControlPanelEntryWeight().content());
assertEquals("com.test.NewPortletControlPanelEntry", portlet.getControlPanelEntryClass().content().toString());
final ElementList<AssetRendererFactory> assetHandlers = portlet.getAssetRendererFactories();
assertNotNull(assetHandlers);
String[] assetHandlersValues = { "com.test.assetRenderFactory.Test1", "com.test.assetRenderFactory.Test2", "com.test.assetRenderFactory.Test3" };
for (AssetRendererFactory assetHandler : assetHandlers) {
assertEquals(true, Arrays.asList(assetHandlersValues).contains(assetHandler.getValue().content().toString()));
}
final ElementList<TrashHandler> trashHanlders = portlet.getTrashHandlers();
assertNotNull(trashHanlders);
String[] trashHanldersValues = { "com.test.trashHandler.Test1", "com.test.trashHandler.Test2", "com.test.trashHandler.Test3" };
for (TrashHandler trashHanlder : trashHanlders) {
assertEquals(true, Arrays.asList(trashHanldersValues).contains(trashHanlder.getValue().content().toString()));
}
// workflow test
final ElementList<PortletStyleElement> headerPortletCsses = portlet.getHeaderPortletCsses();
assertNotNull(headerPortletCsses);
String[] headerPortletCssesValues = { "/css/portlet1.css", "/css/portlet2.css", "/css/portlet3.css" };
for (PortletStyleElement headerPortalCss : headerPortletCsses) {
assertEquals(true, Arrays.asList(headerPortletCssesValues).contains(headerPortalCss.getValue().content().toPortableString()));
}
final ElementList<PortletStyleElement> headerPortletJses = portlet.getHeaderPortletJavascripts();
assertNotNull(headerPortletJses);
String[] headerPortletJsesValues = { "/js/portlet1.js", "/js/portlet2.js", "/js/portlet3.js" };
for (PortletStyleElement headerPortletJs : headerPortletJses) {
assertEquals(true, Arrays.asList(headerPortletJsesValues).contains(headerPortletJs.getValue().content().toPortableString()));
}
final ElementList<PortletStyleElement> footerPortletJses = portlet.getFooterPortletJavascripts();
assertNotNull(footerPortletJses);
String[] footerPortletJsesValues = { "/js/portlet1.js", "/js/portlet2.js", "/js/portlet3.js" };
for (PortletStyleElement footerPortletJs : footerPortletJses) {
assertEquals(true, Arrays.asList(footerPortletJsesValues).contains(footerPortletJs.getValue().content().toPortableString()));
}
assertEquals("test", portlet.getCssClassWrapper().toString());
assertEquals("test", portlet.getCssClassWrapper().content());
final ElementList<SecurityRoleRef> roleMappers = portletApp.getRoleMappers();
assertNotNull(roleMappers);
String[] roleMapperNameValues = { "administrator", "guest", "power-user", "user" };
String[] roleMapperLinkValues = { "Administrator", "Guest", "Power User", "User" };
for (SecurityRoleRef roleMapper : roleMappers) {
assertEquals(true, Arrays.asList(roleMapperNameValues).contains(roleMapper.getRoleName().content()));
assertEquals(true, Arrays.asList(roleMapperLinkValues).contains(roleMapper.getRoleLink().content()));
}
final ElementList<CustomUserAttribute> userAttributes = portletApp.getCustomUserAttributes();
assertNotNull(userAttributes);
String[] attributeNameValues = { "tag1", "tag2", "tag3" };
String[] attributeClassValues = { "com.test.customUserAttribute.Test1" };
for (CustomUserAttribute attribute : userAttributes) {
ElementList<CutomUserAttributeName> attributeNames = attribute.getCustomUserAttributeNames();
assertNotNull(attributeNames);
for (CutomUserAttributeName attributeName : attributeNames) {
assertEquals(true, Arrays.asList(attributeNameValues).contains(attributeName.getValue().content()));
}
assertEquals(true, Arrays.asList(attributeClassValues).contains(attribute.getCustomClass().toString()));
}
}
Aggregations