Модульное тестирование - PullRequest
       6

Модульное тестирование

0 голосов
/ 12 апреля 2019

Я пытаюсь проверить один из моих графиков API.Но он всегда возвращает запрос был отклонен с отклонениями List (MalformedRequestContentRejection (, java.lang.NullPointerException), UnsupportedRequestContentTypeRejection (Set (application / graphql))).

Тот же запрос работает от почтальона


  implicit val ec = ExecutionContext.global

 // implicit final def marshaller[A: Encoder]: ToEntityMarshaller[A] = {
  //  Marshaller.withFixedContentType(`application/json`) { a =>
   //   HttpEntity(`application/json`, a.asJson.noSpaces)
   // }
  //}

  val test1 = """{"query" : "query { articles { name } }"}"""
  //val t = Json.fromString(test1)


// val entiry = Marshal(t).to[MessageEntity].futureValue

  "Post /graphql" should {
    "return 200 OK" in new Context {
      Post(
        "/graphql"
      ).withHeaders(RawHeader("Content-Type","application/json")).withEntity(test1) ~> routes ~> check {

       // println(status)
      status.intValue() shouldBe 200
      }
    }
  }```
...