mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-16 21:01:10 +08:00
#166 added test for QBE
This commit is contained in:
parent
bfe72789cd
commit
16f1c3df65
@ -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");
|
||||
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user