Skip to content

Commit

Permalink
typo!
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigogdea committed Apr 15, 2020
1 parent d7919b6 commit 23b9b17
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ lazy val rxmongoVersion = "0.20.3"
lazy val commonSettings = Seq(
name := "akka-reactivemongo-plugin",
organization := "null-vector",
version := "1.3.7",
version := "1.3.8",
scalaVersion := scala213,
crossScalaVersions := supportedScalaVersions,
scalacOptions := Seq(
Expand Down
22 changes: 17 additions & 5 deletions core/src/test/scala/org/nullvector/EventAdapterFactorySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.util.{Success, Try}
class EventAdapterFactorySpec extends FlatSpec {

it should "create a complex mapping" in {
val eventAdapter = EventAdatpterFactory.adapt[A]("Aed")
val eventAdapter = EventAdapterFactory.adapt[A]("Aed")

val anInstance = A(
B(Set(F(Some(C("Hola", Map("2" -> Seq(J("j"))))))),
Expand Down Expand Up @@ -42,7 +42,7 @@ class EventAdapterFactorySpec extends FlatSpec {
case BSONDocument(_) => BSONDocument("s" -> "Reader Overrided")
}: PartialFunction[BSONDocument, BSONDocument])

val eventAdapter = EventAdatpterFactory.adapt[I]("Ied")
val eventAdapter = EventAdapterFactory.adapt[I]("Ied")
val anInstance = I(K("k"))
val document = eventAdapter.payloadToBson(anInstance)
eventAdapter.bsonToPayload(document).k.s shouldBe "Reader Overrided"
Expand All @@ -59,7 +59,7 @@ class EventAdapterFactorySpec extends FlatSpec {
case _ => Set("TagN")
}

val eventAdapter = EventAdatpterFactory.adapt[I]("Ied", justForTestTags)
val eventAdapter = EventAdapterFactory.adapt[I]("Ied", justForTestTags)

eventAdapter.tags("A") should contain("TagA")
eventAdapter.tags("x") should contain("TagN")
Expand All @@ -81,7 +81,7 @@ class EventAdapterFactorySpec extends FlatSpec {
}

val tags = Set("aTag")
val eventAdapter = EventAdatpterFactory.adapt[L]("Led", tags)
val eventAdapter = EventAdapterFactory.adapt[L]("Led", tags)
val document = eventAdapter.payloadToBson(L(Map(Monday -> "A"), Sunday))
val payload = eventAdapter.bsonToPayload(document)

Expand All @@ -94,13 +94,25 @@ class EventAdapterFactorySpec extends FlatSpec {
val distanceFromEarthAndMars = PlanetDistanceBetweenEarth(and = Mars, kilometers = 209050000.0)

implicit val conf: Aux[MacroOptions] = MacroConfiguration(discriminator = "_type", typeNaming = TypeNaming.SimpleName)
val eventAdapter = EventAdatpterFactory.adapt[PlanetDistanceBetweenEarth]("x")
val eventAdapter = EventAdapterFactory.adapt[PlanetDistanceBetweenEarth]("x")

val document = eventAdapter.payloadToBson(distanceFromEarthAndMars)
document.getAsOpt[BSONDocument]("and").get.getAsOpt[String]("_type").get should be ("Mars")
eventAdapter.bsonToPayload(document).and should be (Mars)
}

it should "mapping sealed trit familly as root event" in {
val jupiter: SolarPlanet = Jupiter

implicit val conf: Aux[MacroOptions] = MacroConfiguration(discriminator = "_type", typeNaming = TypeNaming.SimpleName)
val eventAdapter = EventAdapterFactory.adapt[SolarPlanet]("x")

val document = eventAdapter.payloadToBson(jupiter)

document.getAsOpt[String]("_type").get should be ("Jupiter")
eventAdapter.bsonToPayload(document) should be (Jupiter)
}

}


Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.nullvector

object EventAdatpterFactory {
object EventAdapterFactory {

def adapt[E](withManifest: String): EventAdapter[E] = macro EventAdapterMacroFactory.adapt[E]

Expand Down

0 comments on commit 23b9b17

Please sign in to comment.