mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
added more tests
This commit is contained in:
parent
823ee0783f
commit
3fa2f897cf
@ -16,6 +16,7 @@ import com.mysema.query.types.ExpressionException;
|
||||
import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.PathImpl;
|
||||
import com.mysema.query.types.PathMetadata;
|
||||
import com.mysema.query.types.PathMetadataFactory;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.SimpleExpression;
|
||||
|
||||
@ -39,6 +40,10 @@ public class CollectionPath<E, Q extends SimpleExpression<E>> extends Collection
|
||||
|
||||
private final Class<Q> queryType;
|
||||
|
||||
public CollectionPath(Class<? super E> type, Class<Q> queryType, String variable) {
|
||||
this(type, queryType, PathMetadataFactory.forVariable(variable));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CollectionPath(Class<? super E> type, Class<Q> queryType, PathMetadata<?> metadata) {
|
||||
super((Class)Collection.class);
|
||||
|
||||
@ -46,6 +46,10 @@ public class ListPath<E, Q extends SimpleExpression<E>> extends CollectionPathBa
|
||||
@Nullable
|
||||
private transient Q any;
|
||||
|
||||
public ListPath(Class<? super E> elementType, Class<Q> queryType, String variable) {
|
||||
this(elementType, queryType, PathMetadataFactory.forVariable(variable));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ListPath(Class<? super E> elementType, Class<Q> queryType, PathMetadata<?> metadata) {
|
||||
super((Class)List.class);
|
||||
|
||||
@ -16,6 +16,7 @@ import com.mysema.query.types.ExpressionException;
|
||||
import com.mysema.query.types.Path;
|
||||
import com.mysema.query.types.PathImpl;
|
||||
import com.mysema.query.types.PathMetadata;
|
||||
import com.mysema.query.types.PathMetadataFactory;
|
||||
import com.mysema.query.types.Visitor;
|
||||
import com.mysema.query.types.expr.SimpleExpression;
|
||||
|
||||
@ -39,6 +40,10 @@ public class SetPath<E, Q extends SimpleExpression<E>> extends CollectionPathBas
|
||||
|
||||
private final Class<Q> queryType;
|
||||
|
||||
public SetPath(Class<? super E> type, Class<Q> queryType, String variable) {
|
||||
this(type, queryType, PathMetadataFactory.forVariable(variable));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SetPath(Class<? super E> type, Class<Q> queryType, PathMetadata<?> metadata) {
|
||||
super((Class)Set.class);
|
||||
|
||||
@ -8,17 +8,22 @@ import com.mysema.query.annotations.PropertyType;
|
||||
|
||||
public class BeanPathTest {
|
||||
|
||||
private BeanPath<BeanPathTest> beanPath = new BeanPath<BeanPathTest>(BeanPathTest.class, "p");
|
||||
|
||||
@Test
|
||||
public void As(){
|
||||
SimplePath<BeanPathTest> simplePath = new SimplePath<BeanPathTest>(BeanPathTest.class, "p");
|
||||
assertNotNull(beanPath.as(simplePath));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void CreateEnum(){
|
||||
BeanPath<BeanPathTest> beanPath = new BeanPath<BeanPathTest>(BeanPathTest.class, "p");
|
||||
assertNotNull(beanPath.createEnum("property", PropertyType.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void As(){
|
||||
BeanPath<BeanPathTest> beanPath = new BeanPath<BeanPathTest>(BeanPathTest.class, "p");
|
||||
SimplePath<BeanPathTest> simplePath = new SimplePath<BeanPathTest>(BeanPathTest.class, "p");
|
||||
assertNotNull(beanPath.as(simplePath));
|
||||
public void InstanceOf(){
|
||||
assertNotNull(beanPath.instanceOf(BeanPathTest.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
package com.mysema.query.types.path;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.types.ConstantImpl;
|
||||
import com.mysema.query.types.PathMetadataFactory;
|
||||
|
||||
public class ListPathTest {
|
||||
@ -17,6 +18,8 @@ public class ListPathTest {
|
||||
assertEquals("stringPath", stringPath.any().toString());
|
||||
assertEquals("eqIc(stringPath.get(0),X)", stringPath.get(0).equalsIgnoreCase("X").toString());
|
||||
assertEquals("eqIc(stringPath,X)", stringPath.any().equalsIgnoreCase("X").toString());
|
||||
assertEquals("stringPath.get(0)", stringPath.get(ConstantImpl.create(0)).toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -144,10 +144,13 @@ public class PathTest {
|
||||
paths.add(new ArrayPath(String[].class, "p"));
|
||||
paths.add(new BeanPath(Object.class, "p"));
|
||||
paths.add(new BooleanPath("p"));
|
||||
paths.add(new CollectionPath(String.class, StringPath.class, "p"));
|
||||
paths.add(new ComparablePath(String.class,"p"));
|
||||
paths.add(new DatePath(Date.class,"p"));
|
||||
paths.add(new DateTimePath(Date.class,"p"));
|
||||
paths.add(new EnumPath(ExampleEnum.class,"p"));
|
||||
paths.add(new ListPath(String.class, StringPath.class, "p"));
|
||||
paths.add(new MapPath(String.class, String.class, StringPath.class, "p"));
|
||||
paths.add(new NumberPath(Integer.class,"p"));
|
||||
paths.add(new SimplePath(String.class,"p"));
|
||||
paths.add(new StringPath("p"));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user