Skip to content

Commit 3abc850

Browse files
committed
next SNAPSHOT
1 parent 39ed990 commit 3abc850

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

src/test/resources/restaurant.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"_id": {
3+
"$oid": "589565ca170d563dbb8f68f2"
4+
},
5+
"address": {
6+
"building": "351",
7+
"coord": [
8+
-73.98513559999999,
9+
40.7676919
10+
],
11+
"street": "West 57 Street",
12+
"zipcode": "10019"
13+
},
14+
"borough": "Manhattan",
15+
"cuisine": "Irish",
16+
"grades": [],
17+
"name": "Dj Reynolds Pub And Restaurant",
18+
"restaurant_id": "30191841"
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.sfxcode.nosql.mongo.demo.restaurant
2+
3+
import java.text.SimpleDateFormat
4+
5+
import com.sfxcode.nosql.mongo.demo.restaurant.RestaurantDemoDatabase.Restaurant
6+
import com.sfxcode.nosql.mongo.model.Person.fromJson
7+
import org.json4s.DefaultFormats
8+
import org.json4s.native.Serialization._
9+
10+
object Restaurant {
11+
12+
implicit val formats = new DefaultFormats {
13+
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
14+
}
15+
val testData: Restaurant = read[Restaurant](fromJson("/restaurant.json"))
16+
17+
}

src/test/scala/com/sfxcode/nosql/mongo/demo/restaurant/RestaurantDemoSpec.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package com.sfxcode.nosql.mongo.demo.restaurant
22

33
import com.sfxcode.nosql.mongo.demo.restaurant.RestaurantDemoDatabase._
44
import org.specs2.mutable.Specification
5+
import org.specs2.specification.BeforeAll
6+
import com.sfxcode.nosql.mongo._
57

6-
class RestaurantDemoSpec extends Specification with RestaurantDemoDatabaseFunctions {
8+
class RestaurantDemoSpec extends Specification with RestaurantDemoDatabaseFunctions with BeforeAll {
79

810
"RestaurantDemo" should {
911

@@ -16,4 +18,13 @@ class RestaurantDemoSpec extends Specification with RestaurantDemoDatabaseFuncti
1618
}
1719
}
1820

21+
override def beforeAll(): Unit = {
22+
// needed if no restaurants imported
23+
val count = restaurantsSize
24+
val testRestaurant: Restaurant = Restaurant.testData
25+
26+
if (count == 0) {
27+
RestaurantDAO.insertOne(testRestaurant).headResult()
28+
}
29+
}
1930
}

version.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "1.4.0"
1+
version in ThisBuild := "1.4.1-SNAPSHOT"

0 commit comments

Comments
 (0)