本文整理了Java中com.jayway.restassured.response.Response.then
方法的一些代码示例,展示了Response.then
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.then
方法的具体详情如下:
包路径:com.jayway.restassured.response.Response
类名称:Response
方法名:then
暂无
代码示例来源:origin: yahoo/elide
@Test
public void failChild() throws Exception {
String expected = jsonParser.getJson("/ResourceIT/failChild.json");
given().when().get("/parent/1/unknown").then().statusCode(HttpStatus.SC_NOT_FOUND)
.body(equalTo(expected));
}
代码示例来源:origin: yahoo/elide
@Test
public void testChild() throws Exception {
String expected = jsonParser.getJson("/ResourceIT/testChild.json");
given().when().get("/parent/1/children/1").then().statusCode(HttpStatus.SC_OK)
.body(equalTo(expected));
}
代码示例来源:origin: yahoo/elide
@Test
public void failFieldRequest() throws Exception {
String expected = jsonParser.getJson("/ResourceIT/failFieldRequest.json");
given().when().get("/parent/1/id").then().statusCode(HttpStatus.SC_NOT_FOUND)
.body(equalTo(expected));
}
代码示例来源:origin: yahoo/elide
@Test
public void failRootCollection() throws Exception {
String expected = jsonParser.getJson("/ResourceIT/failRootCollection.json");
given().when().get("/unknown").then().statusCode(HttpStatus.SC_NOT_FOUND)
.body(equalTo(expected));
}
代码示例来源:origin: yahoo/elide
@Test(priority = 12)
public void failDeleteParent() {
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.delete("/parent/678")
.then()
.statusCode(HttpStatus.SC_NOT_FOUND);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 8)
public void testGetRelEmptyColl() {
String expected = jsonParser.getJson("/ResourceIT/testGetRelEmptyColl.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.get("/parent/4/relationships/children")
.then()
.statusCode(HttpStatus.SC_OK)
.body(equalTo(expected));
}
代码示例来源:origin: yahoo/elide
@Test(dataProvider = "like_queries")
public void testSpecialCharacterLikeQuery(String filterParam, int noOfRecords) throws Exception {
String actual = given().when().get(String.format("/book?%s", filterParam)).then().statusCode(HttpStatus.SC_OK)
.extract().body().asString();
JsonApiDocument doc = jsonApiMapper.readJsonApiDocument(actual);
assertEquals(doc.getData().get().size(), noOfRecords);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 11)
public void testNoDeleteExcludedRelationship() throws Exception {
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body("{\"data\":{\"type\":\"excludedRelationship\",\"id\":\"1\"}}")
.delete("/parent/4/children/4/relationships/excludedRelationship")
.then()
.statusCode(HttpStatus.SC_NOT_FOUND);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 11)
public void testForbiddenDeleteEmptyCollectionRelationship() throws Exception {
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body("{\"data\":[]}")
.delete("/parent/4/children/4/relationships/parents")
.then()
.statusCode(HttpStatus.SC_FORBIDDEN);
}
代码示例来源:origin: yahoo/elide
@Test
public void testRootCollectionId() {
String expected = jsonParser.getJson("/ResourceIT/testRootCollectionId.json");
String actual = given().when().get("/parent/1").then().statusCode(HttpStatus.SC_OK)
.extract().body().asString();
assertEquals(actual, expected);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 2)
public void testAuditWithDuplicateLineageEntry() {
String request = jsonParser.getJson("/AuditIT/updateAuditEntityLineageDup.req.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.patch("/auditEntity/2/otherEntity/1")
.then()
.statusCode(HttpStatus.SC_NO_CONTENT);
Assert.assertTrue(logger.logMessages.contains("Updated value (for id: 1): update id 1 through id 2"));
}
代码示例来源:origin: yahoo/elide
@Test(priority = -1)
public void testRootCollection() throws Exception {
String actual = given().when().get("/parent").then().statusCode(HttpStatus.SC_OK)
.extract().body().asString();
JsonApiDocument doc = jsonApiMapper.readJsonApiDocument(actual);
assertEquals(doc.getData().get().size(), 4);
}
代码示例来源:origin: yahoo/elide
@Test
public void createParentBadUri() {
String request = jsonParser.getJson("/ResourceIT/createParentBadUri.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.post("/parent/678")
.then()
.statusCode(HttpStatus.SC_NOT_FOUND);
}
代码示例来源:origin: yahoo/elide
@Test
public void testPrivilegeEscalation() throws Exception {
String request = jsonParser.getJson("/ResourceIT/testUserRoleModification.req.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.patch("/user/1")
.then()
.statusCode(HttpStatus.SC_FORBIDDEN);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 3)
public void testPatchAttrList() throws Exception {
String request = jsonParser.getJson("/ResourceIT/testPatchAttrList.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.patch("/parent/3")
.then()
.statusCode(HttpStatus.SC_BAD_REQUEST);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 10)
public void testPatchRelNoUpdateDirect() throws Exception {
String request = jsonParser.getJson("/ResourceIT/testPatchRelNoUpdateDirect.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.patch("/parent/4/relationships/children")
.then()
.statusCode(HttpStatus.SC_NO_CONTENT)
.header(HttpHeaders.CONTENT_LENGTH, (String) null);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 6)
public void testPatchRelNoUpdateSingle() {
String request = jsonParser.getJson("/ResourceIT/testPatchRelNoUpdateSingle.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.patch("/parent/4")
.then()
.statusCode(HttpStatus.SC_NO_CONTENT)
.header(HttpHeaders.CONTENT_LENGTH, (String) null);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 2)
public void testPatchAttrNoUpdateSingle() {
String request = jsonParser.getJson("/ResourceIT/testPatchAttrNoUpdateSingle.json");
given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.body(request)
.patch("/parent/2")
.then()
.statusCode(HttpStatus.SC_NO_CONTENT)
.body(isEmptyOrNullString());
}
代码示例来源:origin: yahoo/elide
@Test(priority = 8)
public void testGetNestedSingleInclude() throws IOException {
String expected = jsonParser.getJson("/ResourceIT/testGetNestedSingleInclude.json");
String actual = given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.get("/parent/2?include=children.friends")
.then()
.statusCode(HttpStatus.SC_OK)
.extract().body().asString();
assertEqualDocuments(actual, expected);
}
代码示例来源:origin: yahoo/elide
@Test(priority = 8)
public void testGetWithTrailingSlash() {
String expected = jsonParser.getJson("/ResourceIT/testGetWithTrailingSlash.json");
String actual = given()
.contentType(JSONAPI_CONTENT_TYPE)
.accept(JSONAPI_CONTENT_TYPE)
.get("/parent/")
.then()
.statusCode(HttpStatus.SC_OK)
.extract().body().asString();
assertEqualDocuments(actual, expected);
}
内容来源于网络,如有侵权,请联系作者删除!