
com.jayway.restassured.internal.SpecificationMerger.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 2011 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 static com.jayway.restassured.assertion.AssertParameter.notNull
class SpecificationMerger {
/**
* Merge this builder with settings from another specification. Note that the supplied specification
* can overwrite data in the current specification. The following settings are overwritten:
*
* - Content type
* - Root path
*
- Status code
* - Status line
*
* The following settings are merged:
*
* - Response body expectations
* - Cookies
* - Headers
*
*/
def static void merge(ResponseSpecificationImpl thisOne, ResponseSpecificationImpl with) {
notNull thisOne, "Specification to merge"
notNull with, "Specification to merge with"
thisOne.contentType = with.contentType
thisOne.bodyMatchers << with.bodyMatchers
thisOne.bodyRootPath = with.bodyRootPath
thisOne.cookieAssertions.addAll(with.cookieAssertions)
thisOne.expectedStatusCode = with.expectedStatusCode
thisOne.expectedStatusLine = with.expectedStatusLine
thisOne.headerAssertions.addAll(with.headerAssertions)
}
/**
* Merge this builder with settings from another specification. Note that the supplied specification
* can overwrite data in the current specification. The following settings are overwritten:
*
* - Port
* - Authentication scheme
*
- Content type
* - Request body
* - Keystore
* - URL Encoding enabled/disabled
*
* The following settings are merged:
*
* - Parameters
* - Query Parameters
* - Form Parameters
* - Path parameters
* - Multi-part form data parameters
* - Cookies
* - Headers
* - Filters
*
*/
def static void merge(RequestSpecificationImpl thisOne, RequestSpecificationImpl with) {
notNull thisOne, "Specification to merge"
notNull with, "Specification to merge with"
thisOne.port = with.port
thisOne.requestParameters.putAll(with.requestParameters)
thisOne.queryParams.putAll(with.queryParams)
thisOne.formParams.putAll(with.formParams)
thisOne.pathParams.putAll(with.pathParams)
thisOne.multiParts.addAll(with.multiParts)
thisOne.authenticationScheme = with.authenticationScheme
thisOne.keyStoreSpec = with.keyStoreSpec
thisOne.contentType = with.contentType
thisOne.requestHeaders.putAll(with.requestHeaders)
thisOne.cookies.putAll(with.cookies)
thisOne.requestBody = with.requestBody
thisOne.filters.addAll(with.filters)
thisOne.urlEncodingEnabled = with.urlEncodingEnabled
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy