Skip to content

Commit

Permalink
Remove CrudResource trait in favor of ResourceContext
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanadrien committed May 8, 2017
1 parent 74f2224 commit c630b52
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 62 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ Environment with AuthorizedEnvironment with LazyLogging {

// thngs

val thngs = new CrudResource[Thng] {
val format = implicitly[JsonFormat[Thng]]

val env = self
val urlPath = "/thngs"

}
val thngs = new ResourceContext[Thng](this, "/thngs") with Crud[Thng]

def thng(thngId : Ref) = new ThngContext(thngId, apiKey, projectScope)

Expand All @@ -43,23 +37,13 @@ Environment with AuthorizedEnvironment with LazyLogging {

// collections

val collections = new CrudResource[Collection] {
val format = implicitly[JsonFormat[Collection]]

val env = self
val urlPath = "/collections"
}
val collections = new ResourceContext[Collection](this, "/collections") with Crud[Collection]

def collection(collectionId : Ref) = new CollectionContext(collectionId, apiKey, projectScope)

// projects

val projects = new CrudResource[Project] {
val format = implicitly[JsonFormat[Project]]

val env = self
val urlPath = "/projects"
}
val projects = new ResourceContext[Project](this, "/projects") with Crud[Project]

def project(projectId : Ref) = new ProjectContext(apiKey, projectId)

Expand All @@ -70,11 +54,7 @@ Environment with AuthorizedEnvironment with LazyLogging {

// places

object places extends CrudResource[Place] {
val format = implicitly[JsonFormat[Place]]

val env = self
val urlPath = "/places"
object places extends ResourceContext[Place](this, "/places") with Crud[Place] {

def listAround(position : (Double, Double), maxDist : Double) = list().queryParameter(
"lat" -> position._2.toString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ class ProjectContext(val apiKey : String, projectId: Ref) extends

self =>

val applications = new CrudResource[Application] {
val format = implicitly[JsonFormat[Application]]

val env = self
val urlPath = s"/projects/${projectId}/applications"
}
val applications = new ResourceContext[Application](this, s"/projects/${projectId}/applications") with Crud[Application]

def application(id : Ref) = new ApplicationContext(projectId, id, apiKey)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ApplicationCrudSpec(implicit val ee : ExecutionEnv) extends TestOperatorCo
}

def deleteTheApplication =
operator.project(containingProject.id.get).applications.delete(theApplication.id.get).exec must beEqualTo(()).awaitFor(timeout)
operator.project(containingProject.id.get).applications.remove(theApplication.id.get).exec must beEqualTo(()).awaitFor(timeout)

def missTheApplication =
operator.project(containingProject.id.get).applications.read(theApplication.id.get).exec must throwAn[EvtRequestException].like {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CollectionCrudSpec(implicit val ee : ExecutionEnv) extends TestOperatorCon
}

def deleteTheCollection =
operator.collections.delete(theCollection.id.get).exec must beEqualTo(()).awaitFor(timeout)
operator.collections.remove(theCollection.id.get).exec must beEqualTo(()).awaitFor(timeout)

def missTheCollection =
operator.collections.read(theCollection.id.get).exec must throwAn[EvtRequestException].like {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class PlaceCrudSpec(implicit val ee: ExecutionEnv) extends TestOperatorContext {
}

def deleteThePlace =
operator.places.delete(thePlace.id.get).exec must beEqualTo(()).awaitFor(timeout)
operator.places.remove(thePlace.id.get).exec must beEqualTo(()).awaitFor(timeout)

def missThePlace =
operator.places.read(thePlace.id.get).exec must throwAn[EvtRequestException].like {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ProjectCrudSpec(implicit val ee : ExecutionEnv) extends TestOperatorContex
}

def deleteTheProject =
operator.projects.delete(theProject.id.get).exec must beEqualTo(()).awaitFor(timeout)
operator.projects.remove(theProject.id.get).exec must beEqualTo(()).awaitFor(timeout)

def missTheProject =
operator.projects.read(theProject.id.get).exec must throwAn[EvtRequestException].like {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ThngCrudSpec(implicit val ee: ExecutionEnv) extends TestOperatorContext {
}

def deleteTheThng =
operator.thngs.delete(theThng.id.get).exec must beEqualTo(()).awaitFor(timeout)
operator.thngs.remove(theThng.id.get).exec must beEqualTo(()).awaitFor(timeout)

def missTheThng =
operator.thngs.read(theThng.id.get).exec must throwAn[EvtRequestException].like {
Expand Down

0 comments on commit c630b52

Please sign in to comment.