RestAssured-显示JSON响应,但我无法断言其中一个对象,因为它始终显示为null

时间:2018-08-14 03:16:39

标签: rest-assured-jsonpath

我具有所有值的有效JSON响应。显然,对于响应中的对象之一(“ CurrentBatchNumber”:427181),我无法声明其值。尽管该值显示在响应中,但是在代码中我无法声明其值。

==================================

代码段-

then().assertThat().contentType(ContentType.JSON).and().
    body("CurrentBatchNumber",equalTo("123456")).

JsonPath js= ReusableMethods.rawToJson(res);
    String AC=js.get("ApprovalCode");
    String RM=js.get("ResponseMessage");
    String TT=js.get("TransactionType");
    CBN=js.get("CurrentBatchNumber");


    System.out.println("Approval Code --> "+ AC + "\n" + "Response Message - 
 ->" + RM + "\n" + "Transaction Type -->" + TT + "\n");
    System.out.println("Batch Number -->" + CBN);

==================== 控制台输出----

Approval Code --> 2542280
Response Message -->Transaction successful.
Transaction Type -->PARAMETER DOWNLOAD

Batch Number -->null

JSON path CurrentBatchNumber doesn't match.
Expected: 123456
Actual: null

============================== 正在显示在控制台中捕获的实际响应--- CurrentBatchNumber。 ===>“ CurrentBatchNumber”:427181

0 个答案:

没有答案