Fix the bug: VertexSpec
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/c6b607fe Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/c6b607fe Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/c6b607fe Branch: refs/heads/feature/test_daewon Commit: c6b607fe44ce8f5d89438b8715050a2d794a4088 Parents: 9f528db Author: daewon <[email protected]> Authored: Wed Dec 23 14:44:27 2015 +0900 Committer: daewon <[email protected]> Committed: Wed Dec 23 14:44:27 2015 +0900 ---------------------------------------------------------------------- s2rest_play/test/controllers/VertexSpec.scala | 62 +++++++++++++--------- 1 file changed, 38 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c6b607fe/s2rest_play/test/controllers/VertexSpec.scala ---------------------------------------------------------------------- diff --git a/s2rest_play/test/controllers/VertexSpec.scala b/s2rest_play/test/controllers/VertexSpec.scala index 1fc79c3..46461ea 100644 --- a/s2rest_play/test/controllers/VertexSpec.scala +++ b/s2rest_play/test/controllers/VertexSpec.scala @@ -1,38 +1,52 @@ package controllers +import com.kakao.s2graph.core.Graph +import com.kakao.s2graph.core.rest.RestCaller +import com.typesafe.config.ConfigFactory import play.api.libs.json._ import play.api.test.FakeApplication import play.api.test.Helpers._ +import scala.concurrent.Await +import scala.concurrent.duration.Duration + class VertexSpec extends SpecCommon { // init() "vetex tc" should { "tc1" in { -// -// running(FakeApplication()) { -// val ids = (7 until 20).map(tcNum => tcNum * 1000 + 0) -// -// val (serviceName, columnName) = (testServiceName, testColumnName) -// -// val data = vertexInsertsPayload(serviceName, columnName, ids) -// val payload = Json.parse(Json.toJson(data).toString) -// println(payload) -// -// val jsResult = contentAsString(VertexController.tryMutates(payload, "insert", -// Option(serviceName), Option(columnName), withWait = true)) -// -// val query = vertexQueryJson(serviceName, columnName, ids) -// val ret = contentAsJson(QueryController.getVerticesInner(query)) -// println(">>>", ret) -// val fetched = ret.as[Seq[JsValue]] -// for { -// (d, f) <- data.zip(fetched) -// } yield { -// (d \ "id") must beEqualTo((f \ "id")) -// ((d \ "props") \ "age") must beEqualTo(((f \ "props") \ "age")) -// } -// } + + running(FakeApplication()) { + val config = ConfigFactory.load() + val graph = new Graph(config) + val rest = new RestCaller(graph) + + val ids = (7 until 20).map(tcNum => tcNum * 1000 + 0) + + val (serviceName, columnName) = (testServiceName, testColumnName) + + val data = vertexInsertsPayload(serviceName, columnName, ids) + val payload = Json.parse(Json.toJson(data).toString) + println(payload) + + val jsResult = contentAsString(VertexController.tryMutates(payload, "insert", + Option(serviceName), Option(columnName), withWait = true)) + + val query = vertexQueryJson(serviceName, columnName, ids) + val res = rest.uriMatch("/graphs/getVertices", query) + + + val ret = Await.result(res, Duration("30 seconds")) + + println(">>>", ret) + val fetched = ret.as[Seq[JsValue]] + for { + (d, f) <- data.zip(fetched) + } yield { + (d \ "id") must beEqualTo((f \ "id")) + ((d \ "props") \ "age") must beEqualTo(((f \ "props") \ "age")) + } + } true } }
