diff --git a/modules/global/test/com/haulmont/cuba/core/global/QueryTransformationTest.java b/modules/global/test/com/haulmont/cuba/core/global/QueryTransformationTest.java new file mode 100644 index 0000000000..ca25df8e90 --- /dev/null +++ b/modules/global/test/com/haulmont/cuba/core/global/QueryTransformationTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2008-2015 Haulmont. All rights reserved. + * Use is subject to license terms, see http://www.cuba-platform.com/license for details. + */ + +package com.haulmont.cuba.core.global; + +import com.haulmont.cuba.core.sys.jpql.DomainModel; +import com.haulmont.cuba.core.sys.jpql.model.Entity; +import com.haulmont.cuba.core.sys.jpql.model.EntityBuilder; +import com.haulmont.cuba.core.sys.jpql.transform.QueryTransformerAstBased; +import org.junit.Test; + +/** + * @author degtyarjov + * @version $Id$ + */ +public class QueryTransformationTest { + @Test + public void testAst() throws Exception { + for (int i = 0; i < 10000000; i++) { + QueryTransformerAstBased transformerAstBased = new QueryTransformerAstBased(prepareDomainModel(), "select g from sec$GroupHierarchy g", "sec$GroupHierarchy"); + transformerAstBased.addWhere("g.deleteTs is null"); + } + } + + @Test + public void testRegexp() throws Exception { + for (int i = 0; i < 10000; i++) { + QueryTransformerRegex queryTransformerRegex = new QueryTransformerRegex("select g from sec$GroupHierarchy g"); + queryTransformerRegex.addWhere("g.deleteTs is null"); + } + } + + private DomainModel prepareDomainModel() { + EntityBuilder builder = new EntityBuilder(); + builder.startNewEntity("sec$GroupHierarchy"); + builder.addStringAttribute("group"); + builder.addStringAttribute("createdBy"); + builder.addReferenceAttribute("parent", "sec$GroupHierarchy"); + builder.addReferenceAttribute("other", "sec$GroupHierarchy"); + builder.addCollectionReferenceAttribute("constraints", "sec$Constraint"); + Entity groupHierarchy = builder.produce(); + + Entity constraintEntity = builder.produceImmediately("sec$Constraint"); + return new DomainModel(groupHierarchy, constraintEntity); + } +} diff --git a/modules/gui/test/com/haulmont/cuba/gui/autocomplete/impl/transform/QueryTransformerAstBasedTest.java b/modules/gui/test/com/haulmont/cuba/gui/autocomplete/impl/transform/QueryTransformerAstBasedTest.java index 62d773357d..378fbcaa7f 100644 --- a/modules/gui/test/com/haulmont/cuba/gui/autocomplete/impl/transform/QueryTransformerAstBasedTest.java +++ b/modules/gui/test/com/haulmont/cuba/gui/autocomplete/impl/transform/QueryTransformerAstBasedTest.java @@ -801,7 +801,7 @@ public class QueryTransformerAstBasedTest { transformer.removeDistinct(); String res = transformer.getResult(); assertEquals( - "select h from sec$GroupHierarchy h\", \"sec$GroupHierarchy", + "select h from sec$GroupHierarchy h", res); }