#166 added test for QBE

This commit is contained in:
Timo Westkämper 2012-06-11 19:18:23 +03:00
parent bfe72789cd
commit 16f1c3df65
2 changed files with 34 additions and 0 deletions

View File

@ -44,6 +44,7 @@ public class GenericExporterTest extends AbstractProcessorTest{
expected.add("QDelegateTest_SimpleUser2.java");
expected.add("QDelegateTest_User.java");
expected.add("QDelegate2Test_Entity.java");
expected.add("QExampleEntity.java");
// projections are not supported
expected.add("QQueryProjectionTest_EntityWithProjection.java");

View File

@ -0,0 +1,33 @@
package com.mysema.query.domain;
import static org.junit.Assert.*;
import org.junit.Test;
import com.mysema.query.annotations.QueryDelegate;
import com.mysema.query.types.Predicate;
public class QueryByExampleTest {
@QueryDelegate(ExampleEntity.class)
public static Predicate like(QExampleEntity qtype, ExampleEntity example) {
return example.name != null ? qtype.name.eq(example.name) : null;
}
@Test
public void Name_Not_Set() {
ExampleEntity entity = new ExampleEntity();
Predicate qbe = QExampleEntity.exampleEntity.like(entity);
assertNull(qbe);
}
@Test
public void Name_Set() {
ExampleEntity entity = new ExampleEntity();
entity.name = "XXX";
Predicate qbe = QExampleEntity.exampleEntity.like(entity);
assertEquals("exampleEntity.name = XXX", qbe.toString());
}
}