com.jayway.restassured.internal.TestSpecificationImpl.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-assured Show documentation
Show all versions of rest-assured Show documentation
Java DSL for easy testing of REST services
/*
* Copyright 2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jayway.restassured.internal;
import com.jayway.restassured.assertion.AssertParameter
import com.jayway.restassured.response.Response
import com.jayway.restassured.specification.RequestSender
import com.jayway.restassured.specification.RequestSpecification
import com.jayway.restassured.specification.ResponseSpecification
/**
* A test com.jayway.restassured.specification contains a {@link ResponseSpecification} and a {@link RequestSpecification}. It's
* mainly used when you have long specifications, e.g.
*
* RequestSpecification requestSpecification = with().parameters("firstName", "John", "lastName", "Doe");
* ResponseSpecification responseSpecification = expect().body("greeting", equalTo("Greetings John Doe"));
* given(requestSpecification, responseSpecification).get("/greet");
*
*
* This will perform a GET request to "/greet" and verify it according to the responseSpecification
.
*/
class TestSpecificationImpl implements RequestSender {
def final RequestSpecification requestSpecification
def final ResponseSpecification responseSpecification
TestSpecificationImpl(RequestSpecification requestSpecification, ResponseSpecification responseSpecification) {
AssertParameter.notNull requestSpecification, "requestSpecification"
AssertParameter.notNull responseSpecification, "responseSpecification"
this.requestSpecification = requestSpecification
this.responseSpecification = responseSpecification;
responseSpecification.requestSpecification = requestSpecification
requestSpecification.responseSpecification = responseSpecification
}
/**
* {@inheritDoc}
*/
Response get(String path) {
requestSpecification.get path
}
/**
* {@inheritDoc}
*/
Response post(String path) {
requestSpecification.post path
}
/**
* {@inheritDoc}
*/
Response put(String path) {
requestSpecification.put path
}
/**
* {@inheritDoc}
*/
Response delete(String path) {
requestSpecification.delete path
}
/**
* {@inheritDoc}
*/
Response head(String path) {
requestSpecification.head path
}
def RequestSpecification getRequestSpecification() {
requestSpecification
}
def ResponseSpecification getResponseSpecification() {
responseSpecification
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy