mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 10:17:43 +08:00
LocalDate / LocalDateTime / LocalTime / OffsetTime / OffsetDateTime support for persistence and UI components #417
Support query macro. Fix tests
This commit is contained in:
parent
25f4cb75e4
commit
d03042b9a0
@ -16,19 +16,27 @@
|
|||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core.sys.querymacro;
|
package com.haulmont.cuba.core.sys.querymacro;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import com.haulmont.cuba.core.global.AppBeans;
|
||||||
|
import com.haulmont.cuba.testsupport.TestContainer;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.ClassRule;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DateEqualsMacroHandlerTest extends TestCase {
|
public class DateEqualsMacroHandlerTest {
|
||||||
|
|
||||||
|
@ClassRule
|
||||||
|
public static TestContainer cont = TestContainer.Common.INSTANCE;
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testExpandMacro() throws Exception {
|
public void testExpandMacro() throws Exception {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
DateEqualsMacroHandler handler = new DateEqualsMacroHandler();
|
DateEqualsMacroHandler handler = AppBeans.get(DateEqualsMacroHandler.class);
|
||||||
String res = handler.expandMacro("select distinct t from tm$Task t where t.id <> :param_exclItem " +
|
String res = handler.expandMacro("select distinct t from tm$Task t where t.id <> :param_exclItem " +
|
||||||
"and @dateEquals(t.createTs, :component_genericFilter_nLxPpRlkOq29857) order by t.num desc");
|
"and @dateEquals(t.createTs, :component_genericFilter_nLxPpRlkOq29857) order by t.num desc");
|
||||||
handler.setQueryParams(Collections.<String, Object>singletonMap("component_genericFilter_nLxPpRlkOq29857", date));
|
handler.setQueryParams(Collections.<String, Object>singletonMap("component_genericFilter_nLxPpRlkOq29857", date));
|
||||||
@ -37,8 +45,8 @@ public class DateEqualsMacroHandlerTest extends TestCase {
|
|||||||
System.out.println(res);
|
System.out.println(res);
|
||||||
System.out.println(params);
|
System.out.println(params);
|
||||||
|
|
||||||
assertEquals("select distinct t from tm$Task t where t.id <> :param_exclItem and (t.createTs >= :component_genericFilter_nLxPpRlkOq29857 and t.createTs < :t_createTs_1) order by t.num desc", res);
|
Assert.assertEquals("select distinct t from tm$Task t where t.id <> :param_exclItem and (t.createTs >= :component_genericFilter_nLxPpRlkOq29857 and t.createTs < :t_createTs_1) order by t.num desc", res);
|
||||||
assertEquals(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), params.get("component_genericFilter_nLxPpRlkOq29857"));
|
Assert.assertEquals(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), params.get("component_genericFilter_nLxPpRlkOq29857"));
|
||||||
assertEquals(DateUtils.addDays(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), 1), params.get("t_createTs_1"));
|
Assert.assertEquals(DateUtils.addDays(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), 1), params.get("t_createTs_1"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.haulmont.cuba.core.sys.querymacro;
|
package com.haulmont.cuba.core.sys.querymacro;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.haulmont.cuba.core.global.AppBeans;
|
||||||
import com.haulmont.cuba.testsupport.TestContainer;
|
import com.haulmont.cuba.testsupport.TestContainer;
|
||||||
import org.junit.ClassRule;
|
import org.junit.ClassRule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class TimeTodayQueryMacroHandlerTest {
|
public class TimeTodayQueryMacroHandlerTest {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
@ -27,8 +31,9 @@ public class TimeTodayQueryMacroHandlerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExpandMacro() throws Exception {
|
public void testExpandMacro() throws Exception {
|
||||||
TimeTodayQueryMacroHandler handler = new TimeTodayQueryMacroHandler();
|
TimeTodayQueryMacroHandler handler = AppBeans.get(TimeTodayQueryMacroHandler.class);
|
||||||
String res = handler.expandMacro("select u from sec$User where @today(u.createTs) and u.deleteTs is null");
|
String res = handler.expandMacro("select u from sec$User where @today(u.createTs) and u.deleteTs is null");
|
||||||
|
handler.setExpandedParamTypes(ImmutableMap.of("u_createTs_1_1", Date.class, "u_createTs_1_2", Date.class));
|
||||||
System.out.println(res);
|
System.out.println(res);
|
||||||
System.out.println(handler.getParams());
|
System.out.println(handler.getParams());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user