mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Add mongo integration tests
This commit is contained in:
parent
126258f2c4
commit
e46ab61d68
@ -127,7 +127,7 @@ public abstract class MongodbSerializer implements Visitor<Object, Void> {
|
||||
if (subOp == Ops.IN) {
|
||||
return visit(OperationImpl.create(Boolean.class, Ops.NOT_IN, subOperation.getArg(0),
|
||||
subOperation.getArg(1)), context);
|
||||
} else if (key.equals("$or")) {
|
||||
} else if ("$or".equals(key)) {
|
||||
return asDBObject("$nor", arg.get(key));
|
||||
|
||||
} else if (subOp != Ops.EQ && subOp != Ops.STRING_IS_EMPTY) {
|
||||
|
||||
@ -36,6 +36,7 @@ import com.querydsl.core.testutil.ExternalDB;
|
||||
import com.querydsl.core.types.EntityPath;
|
||||
import com.querydsl.core.types.OrderSpecifier;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.core.types.path.ListPath;
|
||||
import com.querydsl.core.types.path.StringPath;
|
||||
import com.querydsl.mongodb.domain.*;
|
||||
import com.querydsl.mongodb.domain.User.Gender;
|
||||
@ -332,10 +333,6 @@ public class MongodbQueryTest {
|
||||
@Test
|
||||
public void IsEmpty() {
|
||||
assertQuery(user.firstName.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEmpty2() {
|
||||
assertQuery(user.friends.isEmpty(), u1);
|
||||
}
|
||||
|
||||
@ -344,6 +341,7 @@ public class MongodbQueryTest {
|
||||
assertQuery(user.firstName.eq("Jaakko").not(), u3, u4, u2);
|
||||
assertQuery(user.firstName.ne("Jaakko").not(), u1);
|
||||
assertQuery(user.firstName.matches("Jaakko").not(), u3, u4, u2);
|
||||
assertQuery(user.friends.isNotEmpty(), u3, u4, u2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -351,18 +349,6 @@ public class MongodbQueryTest {
|
||||
assertQuery(user.lastName.eq("Aakkonen").or(user.lastName.eq("BeekkoNen")), u3, u4);
|
||||
}
|
||||
|
||||
//This is not supported yet
|
||||
// @Test
|
||||
// public void UniqueResult() {
|
||||
//
|
||||
// addUser("Dille", "Duplikaatti");
|
||||
// addUser("Dille", "Duplikaatti");
|
||||
//
|
||||
// assertEquals(2, where(user.firstName.eq("Dille")).count());
|
||||
// assertEquals(1, where(user.firstName.eq("Dille")).countDistinct());
|
||||
//
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void Iterate() {
|
||||
User a = addUser("A", "A");
|
||||
@ -398,6 +384,7 @@ public class MongodbQueryTest {
|
||||
|
||||
@Test
|
||||
public void Various() {
|
||||
ListPath<Address, QAddress> list = user.addresses;
|
||||
StringPath str = user.lastName;
|
||||
List<Predicate> predicates = new ArrayList<Predicate>();
|
||||
predicates.add(str.between("a", "b"));
|
||||
@ -413,7 +400,7 @@ public class MongodbQueryTest {
|
||||
predicates.add(str.isEmpty());
|
||||
predicates.add(str.isNotNull());
|
||||
predicates.add(str.isNull());
|
||||
// predicates.add(str.like("a"));
|
||||
predicates.add(str.like("a"));
|
||||
predicates.add(str.loe("a"));
|
||||
predicates.add(str.lt("a"));
|
||||
predicates.add(str.matches("a"));
|
||||
@ -422,6 +409,8 @@ public class MongodbQueryTest {
|
||||
predicates.add(str.notIn("a","b","c"));
|
||||
predicates.add(str.startsWith("a"));
|
||||
predicates.add(str.startsWithIgnoreCase("a"));
|
||||
predicates.add(list.isEmpty());
|
||||
predicates.add(list.isNotEmpty());
|
||||
|
||||
for (Predicate predicate : predicates) {
|
||||
where(predicate).count();
|
||||
|
||||
@ -199,7 +199,7 @@ public class MongodbSerializerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Regexcases() {
|
||||
public void RegexCases() {
|
||||
assertQuery(title.startsWith("A"),
|
||||
dbo("title", dbo("$regex", "^\\QA\\E")));
|
||||
assertQuery(title.startsWithIgnoreCase("A"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user