Permalink
Browse files

SCALA-68: First pass at Aggregation framework support in Query DSL

1 parent 1582a79 commit 525cd11bd15600085820b4376f2a9e91124e27f5 @bwmcadams bwmcadams committed May 4, 2012
@@ -0,0 +1,23 @@
+package com.mongodb.casbah.query
+
+/**
+ * Copyright (c) 2008 - 2012 10gen, Inc. <http://10gen.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+class AggregationFramework {
+
+}
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2010 - 2012 10gen, Inc. <http://10gen.com>
+ * Copyright (c) 2009, 2010 Novus Partners, Inc. <http://novus.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * For questions and comments about this product, please see the project page at:
+ *
+ * http://github.com/mongodb/casbah
+ *
+ */
+
+package com.mongodb.casbah.test.query
+
+import com.mongodb.casbah.query._
+import com.mongodb.casbah.commons.test.CasbahMutableSpecification
+
+// TODO - Operational/Integration testing with this code
+@SuppressWarnings(Array("deprecation"))
+class AggregationFrameworkSpec extends CasbahMutableSpecification {
+
+ "Casbah's Aggregation DSL" should {
+ "Work with $limit" in {
+ val limit = | $limit 5
+ limit must not beNull
+ }
+ "Work with $skip" in {
+ val skip = | $skip 5
+ skip must not beNull
+ }
+ "Work with $sort" in {
+ val sort = | $sort ( "foo" -> 1, "bar" -> -1 )
+ sort must not beNull
+ }
+
+ "Work with $unwind" in {
+ val unwind = | $unwind "$foo"
+ unwind must haveEntry("$unwind" -> "$foo")
+ }
+
+ "Fail to accept a non $-ed target field" in {
+ (| $unwind "foo" ) must throwA[IllegalArgumentException]
+ }
+
+ "Work with $match and Casbah Queries" in {
+ val _match = | $match { "score" $gt 50 $lte 90 }
+ _match must haveEntry("$match.score.$gt" -> 50) and haveEntry("$match.score.$lte" -> 90)
+ }
+ "Work with $match and Casbah Queries plus additional chains" in {
+ val _match = | $match { ("score" $gt 50 $lte 90) ++ ("type" $in ("exam", "quiz")) }
+ _match must haveEntries("$match.score.$gt" -> 50, "$match.score.$lte" -> 90, "$match.type.$in" -> List("exam", "quiz"))
+ }
+ }
+}
+
+
+// vim: set ts=2 sw=2 sts=2 et:

0 comments on commit 525cd11

Please sign in to comment.