Skip to content

Commit

Permalink
Release v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegIlyenko committed May 1, 2016
1 parent e4acbb1 commit 2cb0b25
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.2.1 (2016-05-01)

* Updated to sangria-marshalling-api v0.2.1

## v0.2.0 (2016-03-24)

* Updated to sangria-marshalling-api v0.2.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and produces correct results.
SBT Configuration:

```scala
libraryDependencies += "org.sangria-graphql" %% "sangria-marshalling-testkit" % "0.2.0" % "test"
libraryDependencies += "org.sangria-graphql" %% "sangria-marshalling-testkit" % "0.2.1" % "test"
```

## License
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "sangria-marshalling-testkit"
organization := "org.sangria-graphql"
version := "0.2.1-SNAPSHOT"
version := "0.2.1"

description := "Sangria Marshalling API TestKit"
homepage := Some(url("http://sangria-graphql.org"))
Expand All @@ -10,7 +10,7 @@ scalaVersion := "2.11.8"
scalacOptions ++= Seq("-deprecation", "-feature")

libraryDependencies ++= Seq(
"org.sangria-graphql" %% "sangria-marshalling-api" % "0.2.0",
"org.sangria-graphql" %% "sangria-marshalling-api" % "0.2.1",
"org.scalatest" %% "scalatest" % "2.2.6"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ trait InputHandlingBehaviour {

private def marshalUndefined(rm: ResultMarshaller): rm.Node =
rm.mapNode(Seq(
"title" rm.stringNode("Foo"),
"title" rm.scalarNode("Foo", "Test", Set.empty),
"comments" rm.arrayNode(Vector.empty)
))

private def verifyUndefined[T](res: T, m: ResultMarshaller)(implicit iu: InputUnmarshaller[T]): Unit = {
iu.isMapNode(res) should be (true)

iu.getMapKeys(res) should (contain("title") and contain("comments"))
iu.getMapValue(res, "title") should be (Some(m.stringNode("Foo")))
iu.getMapValue(res, "title") should be (Some(m.scalarNode("Foo", "Test", Set.empty)))
iu.getMapValue(res, "comments") should be (Some(m.arrayNode(Vector.empty)))

assertPossibleNullNodes(res, m, "text" :: "tags" :: Nil)
Expand All @@ -124,7 +124,7 @@ trait InputHandlingBehaviour {
iu.isMapNode(res) should be (true)

iu.getMapKeys(res) should (contain("title") and contain("comments"))
iu.getMapValue(res, "title") should be (Some(m.stringNode("Foo")))
iu.getMapValue(res, "title") should be (Some(m.scalarNode("Foo", "Test", Set.empty)))

assertPossibleNullNodes(res, m, "text" :: "tags" :: Nil)

Expand All @@ -136,7 +136,7 @@ trait InputHandlingBehaviour {

commentSeq should have size 1

iu.getMapValue(commentSeq(0), "author") should be (Some(m.stringNode("bob")))
iu.getMapValue(commentSeq(0), "author") should be (Some(m.scalarNode("bob", "Test", Set.empty)))

assertPossibleNullNodes(commentSeq(0), m, "text" :: Nil)
}
Expand All @@ -149,50 +149,50 @@ trait InputHandlingBehaviour {

private def marshalNull(rm: ResultMarshaller): rm.Node =
rm.mapNode(Seq(
"title" rm.stringNode("Foo"),
"title" rm.scalarNode("Foo", "Test", Set.empty),
"text" rm.nullNode,
"tags" rm.nullNode,
"comments" rm.arrayNode(Vector(
rm.mapNode(List(
"author" rm.stringNode("bob"))),
"author" rm.scalarNode("bob", "Test", Set.empty))),
rm.mapNode(List(
"author" rm.stringNode("bob1"),
"author" rm.scalarNode("bob1", "Test", Set.empty),
"text" rm.nullNode))
))
))

private def verifyNull[T](res: T, m: ResultMarshaller)(implicit iu: InputUnmarshaller[T]): Unit = {
iu.isMapNode(res) should be (true)

iu.getMapValue(res, "title") should be (Some(m.stringNode("Foo")))
iu.getMapValue(res, "title") should be (Some(m.scalarNode("Foo", "Test", Set.empty)))
iu.getMapValue(res, "text") should be (Some(m.nullNode))
iu.getMapValue(res, "tags") should be (Some(m.nullNode))
iu.getMapValue(res, "comments") should be (Some(m.arrayNode(Vector(
m.mapNode(Vector("author" m.stringNode("bob"))),
m.mapNode(Vector("author" m.stringNode("bob1"), "text" m.nullNode))
m.mapNode(Vector("author" m.scalarNode("bob", "Test", Set.empty))),
m.mapNode(Vector("author" m.scalarNode("bob1", "Test", Set.empty), "text" m.nullNode))
))))
}

private def marshalDefined(rm: ResultMarshaller): rm.Node =
rm.mapNode(Seq(
"title" rm.stringNode("Foo"),
"text" rm.stringNode("foo bar and baz"),
"tags" rm.arrayNode(Vector(rm.stringNode("culture"), rm.stringNode("nature"))),
"title" rm.scalarNode("Foo", "Test", Set.empty),
"text" rm.scalarNode("foo bar and baz", "Test", Set.empty),
"tags" rm.arrayNode(Vector(rm.scalarNode("culture", "Test", Set.empty), rm.scalarNode("nature", "Test", Set.empty))),
"comments" rm.arrayNode(Vector(
rm.mapNode(List(
"author" rm.stringNode("bob"),
"text" rm.stringNode("first!")))
"author" rm.scalarNode("bob", "Test", Set.empty),
"text" rm.scalarNode("first!", "Test", Set.empty)))
))
))

private def verifyDefined[T](res: T, m: ResultMarshaller)(implicit iu: InputUnmarshaller[T]): Unit = {
iu.isMapNode(res) should be (true)

iu.getMapValue(res, "title") should be (Some(m.stringNode("Foo")))
iu.getMapValue(res, "text") should be (Some(m.stringNode("foo bar and baz")))
iu.getMapValue(res, "tags") should be (Some(m.arrayNode(Vector(m.stringNode("culture"), m.stringNode("nature")))))
iu.getMapValue(res, "title") should be (Some(m.scalarNode("Foo", "Test", Set.empty)))
iu.getMapValue(res, "text") should be (Some(m.scalarNode("foo bar and baz", "Test", Set.empty)))
iu.getMapValue(res, "tags") should be (Some(m.arrayNode(Vector(m.scalarNode("culture", "Test", Set.empty), m.scalarNode("nature", "Test", Set.empty)))))
iu.getMapValue(res, "comments") should be (Some(m.arrayNode(Vector(
m.mapNode(Vector("author" m.stringNode("bob"), "text" m.stringNode("first!")))
m.mapNode(Vector("author" m.scalarNode("bob", "Test", Set.empty), "text" m.scalarNode("first!", "Test", Set.empty)))
))))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait MarshallingBehaviour {

def `value (un)marshaller`[T](rm: ResultMarshaller)(implicit iu: InputUnmarshaller[rm.Node]): Unit = {
"(un)marshal boolean scalar values" in {
val marshaled = rm.booleanNode(true)
val marshaled = rm.scalarNode(true, "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)
Expand All @@ -31,7 +31,7 @@ trait MarshallingBehaviour {
}

"(un)marshal int scalar values" in {
val marshaled = rm.intNode(123)
val marshaled = rm.scalarNode(123, "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)
Expand All @@ -51,7 +51,7 @@ trait MarshallingBehaviour {
}

"(un)marshal big int scalar values" in {
val marshaled = rm.bigIntNode(BigInt("12323432432432"))
val marshaled = rm.scalarNode(BigInt("12323432432432"), "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)
Expand All @@ -71,7 +71,27 @@ trait MarshallingBehaviour {
}

"(un)marshal float scalar values" in {
val marshaled = rm.floatNode(123.456D)
val marshaled = rm.scalarNode(123.456F, "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)

iu.getScalaScalarValue(marshaled) should equal (123.456F: Any)

if (scalar != scalaScalar)
scalar should be (marshaled)

iu.isScalarNode(marshaled) should be (true)
iu.isDefined(marshaled) should be (true)

iu.isEnumNode(marshaled) should be (false)
iu.isVariableNode(marshaled) should be (false)
iu.isMapNode(marshaled) should be (false)
iu.isListNode(marshaled) should be (false)
}

"(un)marshal double scalar values" in {
val marshaled = rm.scalarNode(123.456D, "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)
Expand All @@ -91,7 +111,7 @@ trait MarshallingBehaviour {
}

"(un)marshal big decimal scalar values" in {
val marshaled = rm.bigDecimalNode(BigDecimal("12323432432432.2435454354543"))
val marshaled = rm.scalarNode(BigDecimal("12323432432432.2435454354543"), "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)
Expand All @@ -111,7 +131,7 @@ trait MarshallingBehaviour {
}

"(un)marshal string scalar values" in {
val marshaled = rm.stringNode("Hello world")
val marshaled = rm.scalarNode("Hello world", "Test", Set.empty)

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)
Expand All @@ -130,6 +150,23 @@ trait MarshallingBehaviour {
iu.isListNode(marshaled) should be (false)
}

"(un)marshal enum values" in {
val marshaled = rm.enumNode("FOO", "Test")

val scalar = iu.getScalarValue(marshaled)
val scalaScalar = iu.getScalaScalarValue(marshaled)

scalaScalar should be ("FOO": Any)

iu.isScalarNode(marshaled) should be (scalar == scalaScalar)
iu.isDefined(marshaled) should be (true)

iu.isEnumNode(marshaled) should be (true)
iu.isVariableNode(marshaled) should be (false)
iu.isMapNode(marshaled) should be (false)
iu.isListNode(marshaled) should be (false)
}

"(un)marshal nulls" in {
val marshaled = rm.nullNode

Expand All @@ -145,8 +182,8 @@ trait MarshallingBehaviour {
"(un)marshal list values" in {
import sangria.marshalling.scalaMarshalling._

val map = rm.mapNode(Vector("a" rm.intNode(1)))
val seq = Vector(map, rm.nullNode, rm.stringNode("ABC"), rm.arrayNode(Vector.empty))
val map = rm.mapNode(Vector("a" rm.scalarNode(1, "Test", Set.empty)))
val seq = Vector(map, rm.nullNode, rm.scalarNode("ABC", "Test", Set.empty), rm.arrayNode(Vector.empty))
val marshaled = rm.arrayNode(seq)

marshaled.convertMarshaled[Any @@ ScalaInput] should be (
Expand All @@ -166,8 +203,8 @@ trait MarshallingBehaviour {
"(un)marshal map values" in {
import sangria.marshalling.scalaMarshalling._

val map = rm.mapNode(Vector("a" rm.intNode(1)))
val seq = rm.arrayNode(Vector(map, rm.nullNode, rm.stringNode("ABC"), rm.arrayNode(Vector.empty)))
def map = rm.mapNode(Vector("a" rm.scalarNode(1, "Test", Set.empty)))
def seq = rm.arrayNode(Vector(map, rm.nullNode, rm.scalarNode("ABC", "Test", Set.empty), rm.arrayNode(Vector.empty)))

val marshaled1 = rm.mapNode(Vector("first" seq, "second" rm.nullNode))
val marshaled2 = rm.mapNode(rm.addMapNodeElem(rm.addMapNodeElem(rm.emptyMapNode(Seq("first", "second")), "first", seq, false), "second", rm.nullNode, false))
Expand Down Expand Up @@ -198,7 +235,7 @@ trait MarshallingBehaviour {
}

"marshal optional list values" in {
rm.optionalArrayNodeValue(Some(rm.intNode(123))) should be (rm.intNode(123))
rm.optionalArrayNodeValue(Some(rm.scalarNode(123, "Test", Set.empty))) should be (rm.scalarNode(123, "Test", Set.empty))
rm.optionalArrayNodeValue(Some(rm.nullNode)) should be (rm.nullNode)
rm.optionalArrayNodeValue(None) should be (rm.nullNode)
}
Expand Down

0 comments on commit 2cb0b25

Please sign in to comment.