Refine search
/** * Specify the default content type * * @param contentType The content type * @deprecated Use a {@link com.jayway.restassured.builder.RequestSpecBuilder} to set the content-type and then set the created {@link com.jayway.restassured.specification.RequestSpecification} to {@link #requestSpecification}. */ @Deprecated public static void requestContentType(String contentType) { requestSpecification = (requestSpecification == null ? new RequestSpecBuilder().build() : requestSpecification).contentType(contentType); }
@InSequence(23) public void testApplicationMeterUnitPrometheus() { given().header("Accept", TEXT_PLAIN).when().get("/metrics/application/meterMeA") .then().statusCode(200) .and() .body(containsString("meter_me_a_total")) .body(containsString("meter_me_a_rate_per_second")) .body(containsString("meter_me_a_one_min_rate_per_second")) .body(containsString("meter_me_a_five_min_rate_per_second")) .body(containsString("meter_me_a_fifteen_min_rate_per_second")); }
@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 public void shouldProvideBookmarkLinkToResource() throws Exception { given(). contentType(TEST_MEDIA_TYPE). then(). contentType(TEST_MEDIA_TYPE). statusCode(Response.Status.OK.getStatusCode()). body("test.link.find {it.@rel == 'bookmark'}.size()", equalTo(1)). body("test.link.@href", equalTo(new URL(baseURL, "api/bookmark/test/200").toExternalForm())). when(). get(baseURL + "api/test/200"); }
/** * Should return the example from the specification when the script triggers an HTTP 201 Created status code. * * @throws Exception */ @Test public void testServeScriptedExample() throws Exception { given() .log().everything() // JSON content type in 'Accept' header matches specification example .accept(ContentType.JSON) .when() .put("/simple/apis") .then() .log().everything() .statusCode(HttpUtil.HTTP_CREATED) .body("result", equalTo("success")) .header("MyHeader","MyHeaderValue"); }
@Test public void testGetConnectors_badDefinition() throws Exception { given().expect() // .statusCode(400) // .log().ifValidationFails() // // TODO: check returned error .body(Matchers.containsString("definitionClass")) // .get(getVersionPrefix() + "/properties/{name}/connectors", DATA_SET_DEFINITION_NAME); }
@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 = 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 public void testGetIcon_pngImageTypeFound() throws Exception { given().expect() // .contentType(IMAGE_PNG_VALUE) // .body(Matchers.startsWith("\uFFFDPNG")) // Magic header for PNG files. .statusCode(200).log().ifError() // .get(getVersionPrefix() + "/properties/{name}/icon/{type}", DATA_STORE_DEFINITION_NAME, DefinitionImageType.PALETTE_ICON_32X32); }
@Test public void testGetDatasetPropertiesFromSer() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreSerProps()) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/dataset"); }
@Test public void badChildCollectionId() { given().when().get("/user/1/oops/1").then().statusCode(Status.NOT_FOUND.getStatusCode()); } }
String id = given() .contentType(contentType) .body(objectMapper.writeValueAsString(new CreateTodoRequest("testcreate", false, 0))) .when() .post(baseUrl() + "/todos") .then() .statusCode(200) given() .contentType(contentType) .body(objectMapper.writeValueAsString(new UpdateTodoRequest("testupdate", false, 0))) .when() .put(baseUrl() + "/todos/{id}", id) .then() .statusCode(200); }); given() .when() .delete(baseUrl() + "/todos/{id}", id) .then() .statusCode(200);
@Test @InSequence(3) public void shouldBeAbleToRemoveRelation() throws Exception { given(). contentType(BASE_JSON_MEDIA_TYPE). body(new ResourceLink("test", URI.create("http://test.org/api/test/" + TARGET_ID + "/"))). then(). statusCode(Status.NO_CONTENT.getStatusCode()). when(). delete(baseURL + "api/rel/{sourceObj}/{source}/{rel}/{targetObj}/", "sourceobject", SOURCE_ID, type, "targetobject"); }
.expect() .statusCode(isSuccessful()) .header(ETAG, isValidEntityTag()) .when() .get(resourceUri); .header(IF_MATCH, getResponse.getHeader(ETAG)) .contentType(getResponse.contentType()) .body(getResponse.asByteArray()) .when() .put(resourceUri); if (!isSuccessful().matches(ifMatchResponse.getStatusCode())) { throw new SkipException(Thread.currentThread().getStackTrace()[1].getMethodName(), .contentType(getResponse.contentType()) .body(getResponse.asByteArray()) .when() .put(resourceUri); if (isSuccessful().matches(noIfMatchResponse.getStatusCode())) {
protected static void assertCreateUser(User user){ given() .contentType("application/json;charset=UTF-8") .accept("application/json") .body(user) .expect().log().ifError() .statusCode(HttpStatus.SC_CREATED) .when() .post(getHost() + CONTEXT_PATH + "/users"); }