File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed
scala/com/sfxcode/nosql/mongo/demo/restaurant Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ package com.sfxcode.nosql.mongo.demo.restaurant
22
33import com .sfxcode .nosql .mongo .demo .restaurant .RestaurantDemoDatabase ._
44import 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}
Original file line number Diff line number Diff line change 1- version in ThisBuild := " 1.4.0 "
1+ version in ThisBuild := " 1.4.1-SNAPSHOT "
You can’t perform that action at this time.
0 commit comments