2016-10-06 6 views
0

私はspring mvcを使用して残りのWebサービスをテストするためにRestAssuredにテストケースを作成しています。RestAssuredテストのhateoas

残り応答が

{ 
    "links": [ 
{ 
    "rel": "self", 
    "href": "http://www.localhost.com:8080/v1/communities?offset=0&limit=10" 
}, 
{ 
    "rel": "next", 
    "href": "http://www.localhost.com:8080/v1/communities?offset=10&limit=10" 
} 
    ], 
    "content": [ 
{ 
..... 

で、私のテストケースは、テストケースは私も

equalTo("[http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10"); 
を試してみました

java.lang.AssertionError: 1 expectation failed. 
JSON path links.href doesn't match. 
Expected: ["http://www.localhost.com:8080/v1/communities?offset=0&limit=10", "http://www.localhost.com:8080/v1/communities?offset=10&limit=10"] 
Actual: [http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10] 

エラーで失敗し

when(). 
     get("/communities"). 
    then(). 
     root("links"). 
     body("href", new ResponseAwareMatcher() { 
      public Matcher<? extends Object> matcher(ResponseBody response) { 
       return equalTo(new String[] {"http://www.localhost.com:8080/v1/communities?offset=0&limit=10", "http://www.localhost.com:8080/v1/communities?offset=10&limit=10"}); 
      } 
     }); 

です

java.lang.AssertionError: 1 expectation failed. 
JSON path links.href doesn't match. 
Expected: [http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10]] 
Actual: [http://www.localhost.com:8080/v1/communities?offset=0&limit=10, http://www.localhost.com:8080/v1/communities?offset=10&limit=10] 

ようにして、エラーとなる10

私は休憩が3.0.1をアシュアード使用しています。あなたの助けを前もってありがとう。

答えて

0

この

assertEquals("http://www.localhost.com:8080/v1/communities?offset=0&limit=10", given().when().get("/communities").body().jsonPath().get("links[0].href")); 
をお試しください
関連する問題