use of org.seasar.doma.internal.apt.decl.TypeDeclaration in project doma by domaframework.
the class ExpressionValidatorTest method testMethod_foundFromCandidates.
@Test
void testMethod_foundFromCandidates() throws Exception {
Class<?> target = ExpressionValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testEmp", Emp.class);
Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
ExpressionValidator validator = new ExpressionValidator(ctx, methodElement, parameterTypeMap);
ExpressionNode node = new ExpressionParser("emp.hoge(\"aaa\")").parse();
TypeDeclaration result = validator.validate(node);
assertTrue(result.isNumberType());
}
});
compile();
assertTrue(getCompiledResult());
}
use of org.seasar.doma.internal.apt.decl.TypeDeclaration in project doma by domaframework.
the class ExpressionValidatorTest method testAddOperator_text_text.
@Test
void testAddOperator_text_text() throws Exception {
Class<?> target = ExpressionValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testEmp", Emp.class);
Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
ExpressionValidator validator = new ExpressionValidator(ctx, methodElement, parameterTypeMap);
ExpressionNode node = new ExpressionParser("\"1\" + \"2\"").parse();
TypeDeclaration result = validator.validate(node);
assertTrue(result.isTextType());
}
});
compile();
assertTrue(getCompiledResult());
}
use of org.seasar.doma.internal.apt.decl.TypeDeclaration in project doma by domaframework.
the class ExpressionValidatorTest method testFieldAccess_static_optional.
@Test
void testFieldAccess_static_optional() throws Exception {
Class<?> target = ExpressionValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testPerson", Person.class);
Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
ExpressionValidator validator = new ExpressionValidator(ctx, methodElement, parameterTypeMap);
ExpressionNode node = new ExpressionParser("person.staticName").parse();
TypeDeclaration result = validator.validate(node);
assertTrue(result.isTextType());
}
});
compile();
assertTrue(getCompiledResult());
}
use of org.seasar.doma.internal.apt.decl.TypeDeclaration in project doma by domaframework.
the class ExpressionValidatorTest method testMethod_foundWithSupertype.
@Test
void testMethod_foundWithSupertype() throws Exception {
Class<?> target = ExpressionValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testEmp", Emp.class);
Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
ExpressionValidator validator = new ExpressionValidator(ctx, methodElement, parameterTypeMap);
ExpressionNode node = new ExpressionParser("emp.hoge(new java.lang.Integer(1))").parse();
TypeDeclaration result = validator.validate(node);
assertTrue(result.isNumberType());
}
});
compile();
assertTrue(getCompiledResult());
}
use of org.seasar.doma.internal.apt.decl.TypeDeclaration in project doma by domaframework.
the class ExpressionValidatorTest method testCustomFunction_superClassMethodFound.
@Test
void testCustomFunction_superClassMethodFound() throws Exception {
Class<?> target = ExpressionValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testEmp", Emp.class);
Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
ExpressionValidator validator = new ExpressionValidator(ctx, methodElement, parameterTypeMap, MyExpressionFunctions.class.getName());
ExpressionNode node = new ExpressionParser("@prefix(emp.name)").parse();
TypeDeclaration result = validator.validate(node);
assertTrue(result.isTextType());
}
});
compile();
assertTrue(getCompiledResult());
}
Aggregations