Skip to content

Commit

Permalink
Initial commit with base domain
Browse files Browse the repository at this point in the history
  • Loading branch information
matwojcik committed Feb 19, 2019
0 parents commit 3cb74c9
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
.history
.cache
.lib/
*.class
*.log
.idea
38 changes: 38 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name := "testing-without-mocking"

version := "0.1"

scalaVersion := "2.12.8"

scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-language:higherKinds",
"-Ypartial-unification",
)

val compilerPlugins = Seq(
compilerPlugin("io.tryp" % "splain" % "0.3.5" cross CrossVersion.patch),
compilerPlugin("com.softwaremill.clippy" %% "plugin" % "0.5.3" classifier "bundle"),
compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.8"),
compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.2.4")
)

val cats = Seq(
"org.typelevel" %% "cats-core" % "1.5.0",
"org.typelevel" %% "cats-mtl-core" % "0.4.0",
"org.typelevel" %% "cats-effect" % "1.2.0",
"org.typelevel" %% "cats-tagless-macros" % "0.1.0",
"com.olegpy" %% "meow-mtl" % "0.2.0",
)

val scalatest = Seq(
"org.scalactic" %% "scalactic" % "3.0.4",
"org.scalatest" %% "scalatest" % "3.0.5",
"com.ironcorelabs" %% "cats-scalatest" % "2.3.1"
).map(_ % Test)

libraryDependencies ++= compilerPlugins ++ cats ++ scalatest
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version = 1.2.8
11 changes: 11 additions & 0 deletions src/main/scala/orders/OrderRepository.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package orders
import orders.domain.Order

trait OrderRepository[F[_]] {
def find(id: Order.Id): F[Option[Order]]
def save(order: Order): F[Unit]
}

object OrderRepository {
def apply[F[_]](implicit ev: OrderRepository[F]): OrderRepository[F] = ev
}
9 changes: 9 additions & 0 deletions src/main/scala/orders/Orders.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package orders

import orders.domain.Order

trait Orders[F[_]] {
def completeIfPossible(id: Order.Id): F[Option[Order]]
}

object Orders {}
21 changes: 21 additions & 0 deletions src/main/scala/orders/domain.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package orders

import orders.domain.Order.Id
import orders.domain.Order.Status

object domain {

case class Order(id: Id, status: Status)

object Order {
case class Id(value: String) extends AnyVal

sealed trait Status extends Product with Serializable

object Status {
case object Initial extends Status
case object InProgress extends Status
case object Complete extends Status
}
}
}
27 changes: 27 additions & 0 deletions src/test/scala/orders/OrdersSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package orders

import orders.domain.Order
import orders.domain.Order.Status.Complete
import orders.domain.Order.Status.InProgress
import orders.domain.Order.Status.Initial
import org.scalatest.Matchers
import org.scalatest.WordSpec

class OrdersSpec extends WordSpec with Matchers {

val OrderId = Order.Id("123")
val OrderInInitialStatus = Order(OrderId, Initial)
val OrderInProgressStatus = Order(OrderId, InProgress)
val OrderInCompleteStatus = Order(OrderId, Complete)

"Order completion" when {
"order is initial status" should {
"not complete the order" in {}
}

"order is in progress" should {
"complete order" in {}
}
}

}

0 comments on commit 3cb74c9

Please sign in to comment.