Skip to content

Commit a6be199

Browse files
committed
sbt 1.4.0
1 parent 1a98eee commit a6be199

File tree

3 files changed

+51
-27
lines changed

3 files changed

+51
-27
lines changed

build.sbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ lazy val docs = (project in file("docs"))
2626
.enablePlugins(GhpagesPlugin)
2727
.settings(
2828
name := "simple mongo docs",
29-
scalaVersion := "2.13.2",
29+
scalaVersion := "2.13.3",
3030
resolvers += "SFXCode" at "https://dl.bintray.com/sfxcode/maven/",
31-
libraryDependencies += "com.sfxcode.nosql" %% "simple-mongo" % "1.9.3",
32-
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.7.3",
31+
libraryDependencies += "com.sfxcode.nosql" % "simple-mongo_2.13" % "2.0.5",
32+
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.7.3",
3333
publish / skip := true,
3434
ghpagesNoJekyll := true,
3535
git.remoteRepo := "[email protected]:sfxcode/simple-mongo.git",
@@ -53,15 +53,15 @@ libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" % Test
5353

5454
libraryDependencies += "joda-time" % "joda-time" % "2.10.6" % Test
5555

56-
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.9" % Test
56+
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.10" % Test
5757

5858
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "4.1.0"
5959

6060
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.7.7" % Provided
6161

6262
libraryDependencies += "com.github.luben" % "zstd-jni" % "1.4.5-6" % Provided
6363

64-
val MongoJavaServerVersion = "1.34.0"
64+
val MongoJavaServerVersion = "1.36.0"
6565

6666
libraryDependencies += "de.bwaldvogel" % "mongo-java-server" % MongoJavaServerVersion % Provided
6767

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.4.0-RC1
1+
sbt.version=1.4.0

src/test/scala/com/sfxcode/nosql/mongo/operation/CrudSpec.scala

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.sfxcode.nosql.mongo.operation
22

3-
import com.sfxcode.nosql.mongo.test.TestDatabase._
43
import com.sfxcode.nosql.mongo._
54
import com.sfxcode.nosql.mongo.dao.PersonSpecification
5+
import com.sfxcode.nosql.mongo.database.DatabaseProvider
66
import com.sfxcode.nosql.mongo.model.CodecTest
7+
import com.sfxcode.nosql.mongo.test.TestDatabase._
78
import com.typesafe.scalalogging.LazyLogging
9+
import org.bson.conversions.Bson
810
import org.mongodb.scala.bson.ObjectId
9-
import org.mongodb.scala.model.changestream.ChangeStreamDocument
11+
import org.mongodb.scala.model.Filters.equal
12+
import org.mongodb.scala.result.DeleteResult
13+
import org.mongodb.scala.model.Updates._
1014

1115
class CrudSpec extends PersonSpecification with LazyLogging {
1216

@@ -15,32 +19,52 @@ class CrudSpec extends PersonSpecification with LazyLogging {
1519
override def beforeAll(): Unit = {
1620
super.beforeAll()
1721
CodecDao.drop().result()
18-
// CodecDao.addChangeObserver(ChangeObserver(consumeCodecChanges))
19-
val result = CodecDao.insertOne(CodecTest()).result()
2022

21-
val list: List[CodecTest] = CodecDao.find().resultList()
22-
list.size mustEqual 1
23+
}
2324

24-
list.head._id must haveClass[ObjectId]
25+
"Crud Operations" should {
2526

26-
def consumeCodecChanges(changeStreamDocument: ChangeStreamDocument[CodecTest]): Unit =
27-
logger.info(
28-
"codec changed %s:%s with ID: %s".format(
29-
changeStreamDocument.getNamespace,
30-
changeStreamDocument.getOperationType,
31-
changeStreamDocument.getDocumentKey
32-
)
33-
)
27+
"create Document in" in {
28+
val result = CodecDao.insertOne(CodecTest()).result()
3429

35-
}
30+
val list: List[CodecTest] = CodecDao.find().resultList()
31+
list.size mustEqual 1
3632

37-
"Crud Operations" should {
33+
}
34+
35+
"update Document in" in {
36+
var list: List[CodecTest] = CodecDao.find().resultList()
37+
var codec = list.head
38+
codec.id mustEqual 1
39+
CodecDao.updateOne(Map("id" -> 1), set("id", 2)).result()
40+
list = CodecDao.find().resultList()
41+
codec = list.head
42+
codec.id mustEqual 2
43+
}
44+
45+
"replace Document in" in {
46+
var list: List[CodecTest] = CodecDao.find().resultList()
47+
var codec = list.head
48+
codec.id mustEqual 2
49+
CodecDao.replaceOne(codec.copy(id = 1)).result()
50+
list = CodecDao.find().resultList()
51+
codec = list.head
52+
codec.id mustEqual 1
53+
}
54+
55+
"delete Document in" in {
56+
val hexString = CodecDao.find().result()._id.toHexString
57+
hexString must not beEmpty
58+
59+
val result: DeleteResult =
60+
CodecDao.deleteOne(equal(DatabaseProvider.ObjectIdKey, new ObjectId(hexString))).result()
61+
62+
result.wasAcknowledged() must beTrue
63+
result.getDeletedCount must beEqualTo(1)
3864

39-
"create Documents in" in {
65+
val list: List[CodecTest] = CodecDao.find().resultList()
4066

41-
CodecDao.count().result() must be equalTo 1
42-
val findOneResult: Option[CodecTest] = CodecDao.find("id", 1).resultOption()
43-
findOneResult must beSome[CodecTest]
67+
list.size mustEqual 0
4468
}
4569

4670
}

0 commit comments

Comments
 (0)