Search in sources :

Example 1 with IfStatement

use of org.whole.lang.java.model.IfStatement in project whole by wholeplatform.

the class SelectQueriesTest method testSelectTemplateFromPattern.

@Test
public void testSelectTemplateFromPattern() {
    ITemplateManager tm = SelectQueriesTemplateManager.instance();
    JavaEntityFactory ef = JavaEntityFactory.instance;
    IfStatement ifStm = ef.createIfStatement(ef.createPrefixExpression(ef.createPrefixOperator(PrefixOperatorEnum.not), ef.createInfixExpression(ef.createSimpleName("x"), ef.createInfixOperator(InfixOperatorEnum.less), ef.createIntLiteral(3), ef.createExpressions(0))), ef.createEmptyStatement(), ef.createBlock(ef.createExpressionStatement(ef.createAssignment()), ef.createExpressionStatement(ef.createAssignment())));
    PathExpression pe1 = (PathExpression) tm.create("selectTemplateFromPattern");
    IfStatement t = BehaviorUtils.<IfStatement>evaluateFirstResult(pe1, ifStm);
    assertEquals(JavaEntityDescriptorEnum.PrefixExpression, t.getExpression().wGetEntityDescriptor());
    assertTrue(Matcher.match(ifStm.getElseStatement(), t.getThenStatement()));
    assertTrue(Matcher.match(ifStm.getThenStatement(), t.getElseStatement()));
}
Also used : IfStatement(org.whole.lang.java.model.IfStatement) JavaEntityFactory(org.whole.lang.java.factories.JavaEntityFactory) PathExpression(org.whole.lang.queries.model.PathExpression) ITemplateManager(org.whole.lang.templates.ITemplateManager) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 JavaEntityFactory (org.whole.lang.java.factories.JavaEntityFactory)1 IfStatement (org.whole.lang.java.model.IfStatement)1 PathExpression (org.whole.lang.queries.model.PathExpression)1 ITemplateManager (org.whole.lang.templates.ITemplateManager)1