Closed jkubrynski closed 8 years ago
Hi, I confirmed 4e95a90 fixes my testcases above and found another issue
io.codearte.accurest.dsl.GroovyDsl.make {
request {
method 'GET'
urlPath '/api/categories'
}
response {
status 200
body([["Programming", "Java"], ["Programming", "Java", "Spring", "Boot"]])
headers {
header('Content-Type': 'application/json;charset=UTF-8')
}
}
}
generates
@Test
public void validate_getCategories_200() throws Exception {
// given:
MockMvcRequestSpecification request = given();
// when:
ResponseOptions response = given().spec(request)
.get("/api/categories");
// then:
assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).isEqualTo("application/json;charset=UTF-8");
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
}
No assertion
@making - can you check that with Accurest SNAPSHOT? You have to unfortunately build it yourself :/
Now I got:
@Test
public void validate_getCategories_200() throws Exception {
// given:
MockMvcRequestSpecification request = given();
// when:
ResponseOptions response = given().spec(request)
.get("/api/categories");
// then:
assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).isEqualTo("application/json;charset=UTF-8");
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
assertThatJson(parsedJson).array().arrayField().isEqualTo("Boot").value();
assertThatJson(parsedJson).array().arrayField().isEqualTo("Programming").value();
assertThatJson(parsedJson).array().arrayField().isEqualTo("Java").value();
assertThatJson(parsedJson).array().arrayField().isEqualTo("Spring").value();
}
👍
Thanks!
Sweet!
Extracted from #262