@Test public void testExceptionThrowingBean() { // Ensure web exception from bean gets bubbled up given() .accept(JSONAPI_CONTENT_TYPE) .get("/exceptionThrowingBean/1") .then() .statusCode(Status.GONE.getStatusCode()); }
@Test(priority = 12) public void failDeleteParent() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/parent/678") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
@Test(priority = 8) public void testGetIncludeBadRelation() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .get("/parent/1?include=children.BadRelation") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
@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)); }
@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); }
@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); }
@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")); }
@Test(priority = 39) public void testPatchExtNoCommit() { String req = jsonParser.getJson("/ResourceIT/testPatchExtNoCommit.req.json"); given() .contentType(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .accept(JSONAPI_CONTENT_TYPE_WITH_JSON_PATCH_EXTENSION) .body(req) .patch("/") .then() .statusCode(HttpStatus.SC_FORBIDDEN) .body(equalTo("{\"errors\":[\"ForbiddenAccessException\"]}")); }
@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); }
@Test(priority = 11) public void testDeleteParent() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/parent/1") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .body(isEmptyOrNullString()); }
@Test(priority = 11) public void testDeleteWithCascade() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .delete("/invoice/1") .then() .statusCode(HttpStatus.SC_NO_CONTENT) .body(isEmptyOrNullString()); }
@Test public void createChildNonRootable() { String request = jsonParser.getJson("/ResourceIT/createChildNonRootable.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .post("/child") .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
@Test(priority = 34) public void testPostToRecord() { String createRoot = jsonParser.getJson("/ResourceIT/createOneToOneRoot.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(createRoot) .post("/oneToOneRoot/1") .then() .statusCode(HttpStatus.SC_BAD_REQUEST); }
@Test public void assignedIdWithoutProvidedId() { String request = jsonParser.getJson("/ResourceIT/assignedIdWithoutId.req.json"); given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body(request) .post("/assignedIdString") .then() .statusCode(HttpStatus.SC_BAD_REQUEST); }
@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); }
@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); }
@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); }
@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()); }
@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); }
@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); }