我的控制器:
@RequestMapping(value = "/api/rest")
@RestController
@RequiredArgsConstructor
@Validated
public class WarehouseController {
....
@GetMapping(path = "v2/warehouses/limited")
public List<WarehouseSimpleListDto> getRestrictedWarehouses(
@RequestParam(required = false, defaultValue = "{}") WarehouseSearchFilterSimpleDto filter
) {
我的 cucumber 测试:
Given I request GET at endpoint:
"""
/api/rest/v2/warehouses/limited?filter={"shipper_ids":[333444]}
"""
Then the response status code should be 200
其中:
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.Set;
@Data
public class WarehouseSearchFilterSimpleDto {
@JsonProperty("shipper_ids")
private Set<Long> shipperIds;
@JsonProperty("carrier_ids")
private Set<Long> carrierIds;
}
这是怎么回事?我有非常相似的端点工作!当我改变过滤器dto的工作(相同!),然后它的确定。魔术对我来说
错误:
. Reason: Expected to find an object with property ['id'] in path $ but found 'net.minidev.json.JSONArray'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
2023-04-08 22:17:50.908 INFO 13016 --- [nio-8080-exec-2] e.t.c.l.CustomRequestLoggingFilter : F1BE16AC5518488DA1B0FBF90CE1C38B RQ BEGIN [GET /api/rest/v2/warehouses/limited?filter=%7B%22shipper_ids%22:%5B1057128%5D%7D];headers=[user-agent:"cucumber/tests", host:"localhost:8080", connection:"Keep-Alive", accept-encoding:"gzip"]
2023-04-08 22:17:50.941 INFO 13016 --- [nio-8080-exec-2] e.t.c.l.CustomRequestLoggingFilter : F1BE16AC5518488DA1B0FBF90CE1C38B RQ END [GET /api/rest/v2/warehouses/limited?filter=%7B%22shipper_ids%22:%5B1057128%5D%7D]
2023-04-08 22:17:50.958 INFO 13016 --- [ main] p.a.common.integration.ApiStepdefs : Cannot extract ID from body <!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title><style type="text/css">body {
font-family:Tahoma,Arial,sans-serif;}
h1, h2, h3, b {
color:white;background-color:#525D76;}
h1 {
font-size:22px;}
h2 {
font-size:16px;}
h3 {
font-size:14px;}
p {
font-size:12px;}
a {
color:black;}
.line {
height:1px;background-color:#525D76;border:none;}
</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1></body></html>. Reason: Expected to find an object with property ['id'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
对象中的UPDATEMap只对String字段有效!
1条答案
按热度按时间l7wslrjt1#
我不得不在我的项目中添加一些Map器: