io.restassured.http.Headers Java Examples

The following examples show how to use io.restassured.http.Headers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaceholderHandlerTest.java    From heat with Apache License 2.0 6 votes vote down vote up
private Response buildResponse() {
    ResponseBuilder rspBuilder = new ResponseBuilder();
    rspBuilder.setStatusCode(200);
    rspBuilder.setBody("{\"field_path\":\"field_value\",\"array1\":[{\"array_field1\":\"array_field_value1\"}]}");

    List<Header> headerList = new ArrayList();
    Header header1 = new Header("test_header", "test_value");
    Header header2 = new Header("test_header2", "test_value2");
    headerList.add(header1);
    headerList.add(header2);
    Headers headers = new Headers(headerList);
    rspBuilder.setHeaders(headers);

    List<Cookie> cookieList = new ArrayList();
    Cookie cookie1 = new Cookie.Builder("test_cookie", "test_value").build();
    Cookie cookie2 = new Cookie.Builder("test_cookie2", "test_value2").build();
    cookieList.add(cookie1);
    cookieList.add(cookie2);
    Cookies cookies = new Cookies(cookieList);
    rspBuilder.setCookies(cookies);

    return rspBuilder.build();
}
 
Example #2
Source File: CalorieTrackingApiTest.java    From springboot-rest-h2-swagger with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAddFood() {
	Headers headers = populateAdminHeaders();
	Response response = RestAssured.given()
			.headers(headers)
			.contentType(MediaType.APPLICATION_JSON_VALUE)
			.body(this.createMockFood())
			.when().post("/calTracking/admin/addFood");
	
	assertEquals("200 must be returned", HttpStatus.CREATED.value(), response.statusCode());
}
 
Example #3
Source File: TracksResponse.java    From tracksrestcasestudy with MIT License 5 votes vote down vote up
public TracksResponse(Response response) {
    this.statusCode = response.getStatusCode();

    this.responseHeaders = new HashMap<>();
    Headers headers = response.getHeaders();
    for(Header header: headers){
        responseHeaders.put(header.getName(), header.getValue());
    }

    this.body = response.body().asString();
}
 
Example #4
Source File: RestHelper.java    From apicurio-studio with Apache License 2.0 5 votes vote down vote up
public static SessionInfo createEditingSession(RequestSpecification given, ApiDesign apiDesign) {
    // Create editing session
    Headers editingSession = given.expect().statusCode(200)
            .when()
            .get("/api-hub/designs/" + apiDesign.getId() + "/session")
            .getHeaders();
    // Editing session information
    return new SessionInfo(editingSession);
}
 
Example #5
Source File: HttpResponseFacade.java    From cukes with Apache License 2.0 5 votes vote down vote up
private void cacheHeaders(Response response) {
    clearOldHeaders();
    Headers headers = response.getHeaders();
    for (Header header : headers) {
        String headerName = CukesOptions.HEADER_PREFIX + header.getName();
        world.put(headerName, header.getValue());
    }
}
 
Example #6
Source File: WebCustomRequestMapperTest.java    From cukes with Apache License 2.0 5 votes vote down vote up
@Test
public void snapshotNumberShouldBeLessThan10Digits() {
    FilterableRequestSpecification requestSpec = mock(FilterableRequestSpecification.class);
    when(requestSpec.getURI()).thenReturn("http://www.google.com");
    when(requestSpec.getHeaders()).thenReturn(new Headers());

    WebCustomRequest request = mapper.map(requestSpec);
    assertThat(request, hasProperty("snapshot", CustomMatchers.stringWithLength(lessThanOrEqualTo(15)))); //10 digits + t + .inf
}
 
Example #7
Source File: RestAssuredRamlMessage.java    From raml-tester with Apache License 2.0 5 votes vote down vote up
protected Values headersToValues(Headers headers) {
    final Values headerValues = new Values();
    for (final Header header : headers) {
        headerValues.addValue(header.getName(), header.getValue());
    }
    return headerValues;
}
 
Example #8
Source File: SessionInfo.java    From apicurio-studio with Apache License 2.0 4 votes vote down vote up
public SessionInfo(Headers editingSession) {
    editingSessionUuid = editingSession.get("X-Apicurio-EditingSessionUuid").getValue();
    contentVersion = editingSession.get("X-Apicurio-ContentVersion").getValue();
    contentType = editingSession.get("Content-Type").getValue();
    contentLength = Integer.valueOf(editingSession.get("Content-Length").getValue());
}
 
Example #9
Source File: CalorieTrackingApiTest.java    From springboot-rest-h2-swagger with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 
 * @return
 */
private Headers populateAdminHeaders() {
	return new Headers(new Header("consumer-key", "admin"));
}