From 2cb0b25f7b80aa4745ac26e0144bcdb5dcaefd85 Mon Sep 17 00:00:00 2001 From: Oleg Ilyenko Date: Sun, 1 May 2016 02:33:17 +0200 Subject: [PATCH] Release v0.2.1 --- CHANGELOG.md | 4 ++ README.md | 2 +- build.sbt | 4 +- .../testkit/InputHandlingBehaviour.scala | 38 ++++++------ .../testkit/MarshallingBehaviour.scala | 59 +++++++++++++++---- 5 files changed, 74 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd248db..9c27d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 6ce0437..51b57e0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sbt b/build.sbt index 3db4470..f57e1d1 100644 --- a/build.sbt +++ b/build.sbt @@ -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")) @@ -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" ) diff --git a/src/main/scala/sangria/marshalling/testkit/InputHandlingBehaviour.scala b/src/main/scala/sangria/marshalling/testkit/InputHandlingBehaviour.scala index 8fe5d49..e094399 100644 --- a/src/main/scala/sangria/marshalling/testkit/InputHandlingBehaviour.scala +++ b/src/main/scala/sangria/marshalling/testkit/InputHandlingBehaviour.scala @@ -106,7 +106,7 @@ 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) )) @@ -114,7 +114,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))) iu.getMapValue(res, "comments") should be (Some(m.arrayNode(Vector.empty))) assertPossibleNullNodes(res, m, "text" :: "tags" :: Nil) @@ -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) @@ -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) } @@ -149,14 +149,14 @@ 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)) )) )) @@ -164,35 +164,35 @@ trait InputHandlingBehaviour { 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))) )))) } } diff --git a/src/main/scala/sangria/marshalling/testkit/MarshallingBehaviour.scala b/src/main/scala/sangria/marshalling/testkit/MarshallingBehaviour.scala index 1ca65af..94c0373 100644 --- a/src/main/scala/sangria/marshalling/testkit/MarshallingBehaviour.scala +++ b/src/main/scala/sangria/marshalling/testkit/MarshallingBehaviour.scala @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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 ( @@ -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)) @@ -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) }