use of org.whole.lang.java.factories.JavaEntityFactory 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()));
}
use of org.whole.lang.java.factories.JavaEntityFactory in project whole by wholeplatform.
the class FactoriesTest method testUniqueConstraint.
// TODO replace test language with one having unique constraints
@Test
public void testUniqueConstraint() {
JavaEntityFactory ef = JavaEntityFactory.instance;
JavaEntityFactory sef = JavaEntityFactory.instance(RegistryConfigurations.STRICT);
ExtendedModifiers e = ef.createExtendedModifiers(ef.createModifier(ModifierEnum._abstract), ef.createModifier(ModifierEnum._abstract));
e.wAdd(ef.createModifier(ModifierEnum._abstract));
Assert.assertEquals(3, e.wSize());
ExtendedModifiers se = sef.createExtendedModifiers(sef.createModifier(ModifierEnum._abstract), sef.createModifier(ModifierEnum._abstract));
se.wAdd(ef.createModifier(ModifierEnum._abstract));
// TODO was 1
Assert.assertEquals(3, se.wSize());
// TODO was false
Assert.assertTrue(Matcher.match(se, e));
Assert.assertFalse(Matcher.match(se, ef.createExtendedModifiers(// TODO was true
ef.createModifier(ModifierEnum._abstract))));
}
use of org.whole.lang.java.factories.JavaEntityFactory in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl7.
@Test
public void testQueryDecl7() {
QueriesEntityFactory qef = QueriesEntityFactory.instance;
JavaEntityFactory jef = JavaEntityFactory.instance;
IEntity queryExp1 = qef.createDivision(qef.createMultiplication(qef.createIntLiteral(10), qef.createIntLiteral(8)), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
IEntity queryExp2 = qef.createDivision(qef.createIntLiteral(10), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
IEntity javaExp1 = jef.createInfixExpression(jef.createInfixExpression(jef.createIntLiteral(10), jef.createInfixOperator(InfixOperatorEnum.times), jef.createIntLiteral(8), jef.createExpressions(0)), jef.createInfixOperator(InfixOperatorEnum.divide), jef.createInfixExpression(jef.createIntLiteral(2), jef.createInfixOperator(InfixOperatorEnum.plus), jef.createIntLiteral(1), jef.createExpressions(0)), jef.createExpressions(0));
IEntity javaExp2 = EntityUtils.clone(javaExp1);
javaExp2.wSet(JavaFeatureDescriptorEnum.leftOperand, jef.createIntLiteral(10));
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl7");
assertTrue(Matcher.match(javaExp2, BehaviorUtils.evaluateFirstResult(query, queryExp2)));
assertTrue(Matcher.match(javaExp1, BehaviorUtils.evaluateFirstResult(query, queryExp1)));
}
use of org.whole.lang.java.factories.JavaEntityFactory in project whole by wholeplatform.
the class FactoriesTest method testSimpleEntityFactoryMethodWithObjects.
@Test
public void testSimpleEntityFactoryMethodWithObjects() {
JavaEntityFactory ef = JavaEntityFactory.instance;
ef.buildMethodInvocation().set(JavaFeatureDescriptorEnum.name, "methodName").getResult();
ef.create(JavaEntityDescriptorEnum.MethodInvocation, ef.createThisExpression(), ef.createTypes(), "methodName", ef.createArguments());
ef.create(JavaEntityDescriptorEnum.MethodInvocation, ef.createThisExpression(), ef.createTypes(), // with less arguments
"methodName");
}
Aggregations