Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup

  • Loading branch information...
commit 9c60bb201739872464202974c593ea5972eac6f3 1 parent 2b19690
@gideondk authored
Showing with 0 additions and 185 deletions.
  1. +0 −185 src/test/scala/nl/gideondk/raiku/BucketAdvancedSpec.scala.orig
View
185 src/test/scala/nl/gideondk/raiku/BucketAdvancedSpec.scala.orig
@@ -1,185 +0,0 @@
-package nl.gideondk.raiku
-
-import akka.actor._
-import scala.concurrent._
-import scala.concurrent.duration._
-
-import scalaz._
-import Scalaz._
-
-import scalaz._
-import Scalaz._
-
-import spray.json._
-
-import org.specs2.mutable.Specification
-import org.specs2.matcher.Matcher
-
-case class Y(id: String, name: String, age: Int, groupId: String)
-
-class BucketAdvancedSpec extends Specification with DefaultJsonProtocol {
-
-<<<<<<< HEAD
- implicit val system = ActorSystem("adv-bucket-system")
- val client = RaikuClient("localhost", 8087, 4)
-
- implicit val yFormat = jsonFormat4(Y)
-
- implicit val yConverter = new RaikuConverter[Y] {
- def read(o: RaikuRWObject): ReadResult[Y] = try {
- yFormat.read(new String(o.value).asJson).success
- } catch {
- case e: Throwable => e.failure
- }
- def write(bucket: String, o: Y): RaikuRWObject = RaikuRWObject(bucket, o.id, o.toJson.toString.getBytes,
- binIndexes = Map("group_id" -> List(o.groupId)), intIndexes = Map("age" -> List(o.age)))
- }
-
- val bucket = RaikuBucket[Y]("raiku_test_y_bucket", client)
- bucket.setBucketProperties(RaikuBucketProperties(None, Some(true))).unsafeFulFill
-
- "A bucket" should {
- "be able to retrieve objects with their binary 2i" in {
- val newId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
- val obj = Y(newId, "Matsuo Bashō", 41, groupId)
-
- val key = for {
- _ <- bucket << obj
- idxf <- bucket idx ("group_id", groupId)
- } yield idxf
-
- val res = key.unsafeFulFill
- assert(res.isSuccess && res.toOption.get.length == 1 && res.toOption.get.head == newId)
- }
- "be able to retrieve objects with their integeral 2i" in {
- val newId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
- val obj = Y(newId, "Matsuo Bashō", 41, groupId)
-
- val keys = for {
- _ <- bucket << obj
- idxf <- bucket idx ("age", 41)
- } yield idxf
-
- val res = keys.unsafeFulFill
- res.toOption.get.contains(newId)
- }
- "be able to retrieve objects with ranges on a integeral 2i" in {
- val newId = java.util.UUID.randomUUID.toString
- val secId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
-
- val basho = Y(newId, "Matsuo Bashō", 41, groupId)
- val shiki = Y(secId, "Masaoka Shiki", 52, groupId)
-
- val keys = for {
- _ <- bucket << basho
- _ <- bucket << shiki
- all <- bucket idx ("age", 40 to 60)
- basho <- bucket idx ("age", 39 to 42)
- shiki <- bucket idx ("age", 50 to 60)
- } yield (all, basho, shiki)
-
- val res = keys.unsafeFulFill.toOption.get
- res._1.contains(newId) && res._1.contains(secId) && res._2.contains(newId) && !res._2.contains(secId) && !res._3.contains(newId) && res._3.contains(secId)
- }
- }
-
- step {
- client.disconnect
- system.shutdown()
- }
-=======
- implicit val system = ActorSystem("adv-bucket-system")
- val client = RaikuClient("localhost", 8087, 4)
-
- implicit val yFormat = jsonFormat4(Y)
-
- implicit val yConverter = new RaikuConverter[Y] {
- def read(o: RaikuRWObject): ReadResult[Y] = try {
- yFormat.read(new String(o.value).asJson).success
- } catch {
- case e : Throwable => e.failure
- }
- def write(bucket: String, o: Y): RaikuRWObject = RaikuRWObject(bucket, o.id, o.toJson.toString.getBytes,
- binIndexes = Map("group_id" -> List(o.groupId)), intIndexes = Map("age" -> List(o.age)))
- }
-
- val bucket = RaikuBucket[Y]("raiku_test_y_bucket", client)
- bucket.setBucketProperties(RaikuBucketProperties(None, Some(true))).unsafeFulFill
-
-
-
- "A bucket" should {
- "be able to retrieve objects with their binary 2i" in {
- val newId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
- val obj = Y(newId, "Matsuo Bashō", 41, groupId)
-
- val key = for {
- _ <- bucket << obj
- idxf <- bucket idx ("group_id", groupId)
- } yield idxf
-
- val res = key.unsafeFulFill
- assert(res.isSuccess && res.toOption.get.length == 1 && res.toOption.get.head == newId)
- }
- "be able to retrieve objects with their integeral 2i" in {
- val newId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
- val obj = Y(newId, "Matsuo Bashō", 41, groupId)
-
- val keys = for {
- _ <- bucket << obj
- idxf <- bucket idx ("age", 41)
- } yield idxf
-
- val res = keys.unsafeFulFill
- res.toOption.get.contains(newId)
- }
- "be able to retrieve objects with ranges on a integeral 2i" in {
- val newId = java.util.UUID.randomUUID.toString
- val secId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
-
- val basho = Y(newId, "Matsuo Bashō", 41, groupId)
- val shiki = Y(secId, "Masaoka Shiki", 52, groupId)
-
- val keys = for {
- _ <- bucket << basho
- _ <- bucket << shiki
- all <- bucket idx ("age", 40 to 60)
- basho <- bucket idx ("age", 39 to 42)
- shiki <- bucket idx ("age", 50 to 60)
- } yield (all, basho, shiki)
-
- val res = keys.unsafeFulFill.toOption.get
- res._1.contains(newId) && res._1.contains(secId) && res._2.contains(newId) && !res._2.contains(secId) && !res._3.contains(newId) && res._3.contains(secId)
- }
-
- "be able to use Scalaz functionality on ValidatedIOFutures" in {
- val newId = java.util.UUID.randomUUID.toString
- val secId = java.util.UUID.randomUUID.toString
- val groupId = java.util.UUID.randomUUID.toString
-
- val basho = Y(newId, "Matsuo Bashō", 41, groupId)
- val shiki = Y(secId, "Masaoka Shiki", 52, groupId)
-
- val all = for {
- _ <- bucket << basho
- _ <- bucket << shiki
- all <- bucket idx ("age", 40 to 60) >>= ((x: List[String]) => bucket ?* x)
- } yield (all)
-
- val res = all.unsafeFulFill
- res.isSuccess
- }
- }
-
- step {
- client.disconnect
- system.shutdown()
- }
->>>>>>> 26ff72128eebb39201dba5f66c9e8fe405f69156
-}
Please sign in to comment.
Something went wrong with that request. Please try again.