Тип содержимого заголовка облачного контракта Spring имеет значение null - PullRequest
0 голосов
/ 28 ноября 2018

У меня простой заводной весенний контракт.

Contract.make {

description "should return one order response"

request {
    url("/order/1")
    method GET()
}

response {
    status 200
    headers {
        header (HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
    }
    body ([id: "1", customer: "", supplier: "", productId: "", product: "product"])
}

}

Spring генерирует тестовый метод без каких-либо проблем, но затем я получил ошибку при выполнении теста:

org.junit.ComparisonFailure: expected:<"application/json"> but was:<null>
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at com.bearingpoint.beyond.delivery.nokiaoen.marketplace.backend.BaseClasses.ContractVerifierTest.validate_shouldReturnOrderResponse(ContractVerifierTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

Итак, если я правильно понимаюу меня есть нулевое значение в заголовке ответа, но я написал тип контента в контракте.Кто-нибудь может дать какой-нибудь совет, как я могу это решить?

...