Search in sources :

Example 1 with Assignment

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

the class ResolversTest method testAmbiguousDataEntityResolverTightening.

@Category(KnownFailingTests.class)
@Test
public void testAmbiguousDataEntityResolverTightening() {
    // workaround for JVM termination on StackOverflowError
    Assert.fail();
    Expression expression = createResolver(JavaEntityDescriptorEnum.Expression);
    Assignment assignment = jf.createAssignment();
    assignment.setRightHandSide(expression);
    expression.wSetValue("stringLiteral");
    Assert.assertTrue(Matcher.matchImpl(JavaEntityDescriptorEnum.StringLiteral, assignment.getRightHandSide()));
}
Also used : Assignment(org.whole.lang.java.model.Assignment) Expression(org.whole.lang.java.model.Expression) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 2 with Assignment

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

the class SelectQueriesTest method testSelectTupleOfTemplatesAs.

@Test
public void testSelectTupleOfTemplatesAs() {
    Model model = new XmlModel().create();
    ITemplateManager tm = SelectQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("selectTupleOfTemplatesAs");
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
        FieldDeclaration f = (FieldDeclaration) tuple.wGet(0);
        SingleVariableDeclaration p = (SingleVariableDeclaration) tuple.wGet(1);
        ExpressionStatement s = (ExpressionStatement) tuple.wGet(2);
        Feature e = (Feature) tuple.wGet(3);
        String ptype = e.getType().wStringValue();
        String pname = e.getName().wStringValue();
        assertSame(f, bm.wGet("field"));
        assertEquals(ptype, f.getType().wStringValue());
        assertSame(p, bm.wGet("param"));
        assertEquals(ptype, p.getType().wStringValue());
        assertEquals(pname, p.getName().wStringValue());
        assertSame(s, bm.wGet("init"));
        assertEquals(pname, ((Assignment) s.getExpression()).getRightHandSide().wStringValue());
    }
}
Also used : Assignment(org.whole.lang.java.model.Assignment) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) SingleVariableDeclaration(org.whole.lang.java.model.SingleVariableDeclaration) ExpressionStatement(org.whole.lang.java.model.ExpressionStatement) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) IBindingManager(org.whole.lang.bindings.IBindingManager) XmlModel(org.whole.lang.models.codebase.XmlModel) ITemplateManager(org.whole.lang.templates.ITemplateManager) Feature(org.whole.lang.models.model.Feature) FieldDeclaration(org.whole.lang.java.model.FieldDeclaration) Test(org.junit.Test)

Example 3 with Assignment

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

the class ResolversTest method testDataEntityResolverTightening.

@Test
public void testDataEntityResolverTightening() {
    Expression expression = createResolver(JavaEntityDescriptorEnum.Expression);
    Assignment assignment = jf.createAssignment();
    assignment.setRightHandSide(expression);
    expression.wSetValue(false);
    Assert.assertTrue(Matcher.matchImpl(JavaEntityDescriptorEnum.BooleanLiteral, assignment.getRightHandSide()));
}
Also used : Assignment(org.whole.lang.java.model.Assignment) Expression(org.whole.lang.java.model.Expression) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Assignment (org.whole.lang.java.model.Assignment)3 Expression (org.whole.lang.java.model.Expression)2 Category (org.junit.experimental.categories.Category)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 ExpressionStatement (org.whole.lang.java.model.ExpressionStatement)1 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)1 SingleVariableDeclaration (org.whole.lang.java.model.SingleVariableDeclaration)1 IEntity (org.whole.lang.model.IEntity)1 XmlModel (org.whole.lang.models.codebase.XmlModel)1 Feature (org.whole.lang.models.model.Feature)1 Model (org.whole.lang.models.model.Model)1 PathExpression (org.whole.lang.queries.model.PathExpression)1 ITemplateManager (org.whole.lang.templates.ITemplateManager)1