PL-5590 AST-based QueryTransformer

Fix test
#PL-5590
This commit is contained in:
Eugeny Degtyarjov 2015-08-03 10:26:27 +00:00
parent 4c76008fd8
commit 375957cb06
2 changed files with 49 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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);
}