Search in sources :

Example 1 with NumberValueValidationService

use of com.liferay.ide.portlet.core.lfportlet.model.internal.NumberValueValidationService in project liferay-ide by liferay.

the class LiferayPortletXmlTest method testNumberValidationService.

@Test
public void testNumberValidationService() throws Exception {
    if (shouldSkipBundleTests())
        return;
    LiferayPortletXml liferayPortletApp = LiferayPortletXml.TYPE.instantiate();
    LiferayPortlet liferayPortlet = liferayPortletApp.getPortlets().insert();
    SchedulerEntry schedulerEntry = liferayPortlet.getSchedulerEntries().insert();
    ElementHandle<ITrigger> cronTrigger = ((ElementHandle<ITrigger>) (schedulerEntry.getPortletTrigger()));
    ElementHandle<ICronTrigger> cronTriggerValueTrigger = cronTrigger.content(true, CronTrigger.class).getCronTrigger();
    CronTriggerValueTrigger cronTriggerValue = cronTriggerValueTrigger.content(true, CronTriggerValueTrigger.class);
    NumberValueValidationService vs = cronTriggerValue.getCronTriggerValue().service(NumberValueValidationService.class);
    cronTriggerValue.setCronTriggerValue("-1");
    assertEquals(false, "ok".equals(vs.validation().message()));
    cronTriggerValue.setCronTriggerValue("150");
    assertEquals(true, "ok".equals(vs.validation().message()));
}
Also used : ICronTrigger(com.liferay.ide.portlet.core.lfportlet.model.ICronTrigger) CronTrigger(com.liferay.ide.portlet.core.lfportlet.model.CronTrigger) ICronTrigger(com.liferay.ide.portlet.core.lfportlet.model.ICronTrigger) PropertyCronTrigger(com.liferay.ide.portlet.core.lfportlet.model.PropertyCronTrigger) LiferayPortletXml(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml) NumberValueValidationService(com.liferay.ide.portlet.core.lfportlet.model.internal.NumberValueValidationService) SchedulerEntry(com.liferay.ide.portlet.core.lfportlet.model.SchedulerEntry) CronTriggerValueTrigger(com.liferay.ide.portlet.core.lfportlet.model.CronTriggerValueTrigger) LiferayPortlet(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet) ITrigger(com.liferay.ide.portlet.core.lfportlet.model.ITrigger) Test(org.junit.Test)

Aggregations

CronTrigger (com.liferay.ide.portlet.core.lfportlet.model.CronTrigger)1 CronTriggerValueTrigger (com.liferay.ide.portlet.core.lfportlet.model.CronTriggerValueTrigger)1 ICronTrigger (com.liferay.ide.portlet.core.lfportlet.model.ICronTrigger)1 ITrigger (com.liferay.ide.portlet.core.lfportlet.model.ITrigger)1 LiferayPortlet (com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet)1 LiferayPortletXml (com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml)1 PropertyCronTrigger (com.liferay.ide.portlet.core.lfportlet.model.PropertyCronTrigger)1 SchedulerEntry (com.liferay.ide.portlet.core.lfportlet.model.SchedulerEntry)1 NumberValueValidationService (com.liferay.ide.portlet.core.lfportlet.model.internal.NumberValueValidationService)1 Test (org.junit.Test)1