Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: serenity-rest added tests for using chains of given, and, when,…
… with based on request instance
- Loading branch information
1 parent
5cc45f3
commit 7f439d2
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
.../src/test/groovy/net/serenitybdd/rest/staging/WhenUseChainOfRequestInitialisations.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package net.serenitybdd.rest.staging | ||
|
||
import com.github.tomakehurst.wiremock.client.WireMock | ||
import com.github.tomakehurst.wiremock.junit.WireMockRule | ||
import com.jayway.restassured.specification.FilterableRequestSpecification | ||
import net.serenitybdd.rest.staging.decorators.ResponseDecorated | ||
import net.serenitybdd.rest.staging.decorators.ResponseSpecificationDecorated | ||
import net.serenitybdd.rest.staging.decorators.request.RequestSpecificationDecorated | ||
import net.serenitybdd.rest.staging.rules.RestConfigurationAction | ||
import net.serenitybdd.rest.staging.rules.RestConfigurationRule | ||
import org.junit.Rule | ||
import spock.lang.Specification | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.* | ||
import static net.serenitybdd.rest.staging.SerenityRest.given | ||
import static net.serenitybdd.rest.staging.SerenityRest.reset | ||
|
||
/** | ||
* User: YamStranger | ||
* Date: 3/30/16 | ||
* Time: 9:57 AM | ||
*/ | ||
class WhenUseChainOfRequestInitialisations extends Specification { | ||
|
||
@Rule | ||
def RestConfigurationRule rule = new RestConfigurationRule(new RestConfigurationAction() { | ||
@Override | ||
void apply() { | ||
reset() | ||
} | ||
},) | ||
|
||
def "should be returned wrapped request specification after given operation"() { | ||
given: "request initialised" | ||
def request = (FilterableRequestSpecification) given(); | ||
when: "executing given from request specification" | ||
def requestAfterLog = request.given() | ||
then: "same request should be returned after given operation" | ||
requestAfterLog == request | ||
and: "request should be wrapped" | ||
requestAfterLog instanceof RequestSpecificationDecorated | ||
} | ||
|
||
def "should be returned wrapped request specification after when operation"() { | ||
given: "request initialised" | ||
def request = (FilterableRequestSpecification) given(); | ||
when: "executing when from request specification" | ||
def requestAfterLog = request.when() | ||
then: "same request should be returned after when operation" | ||
requestAfterLog == request | ||
and: "request should be wrapped" | ||
requestAfterLog instanceof RequestSpecificationDecorated | ||
} | ||
|
||
def "should be returned wrapped request specification after AND operation"() { | ||
given: "request initialised" | ||
def request = (FilterableRequestSpecification) given(); | ||
when: "executing when from request specification" | ||
def requestAfterLog = request.and() | ||
then: "same request should be returned after and operation" | ||
requestAfterLog == request | ||
and: "request should be wrapped" | ||
requestAfterLog instanceof RequestSpecificationDecorated | ||
} | ||
|
||
def "should be returned wrapped request specification after with operation"() { | ||
given: "request initialised" | ||
def request = (FilterableRequestSpecification) given(); | ||
when: "executing when from request specification" | ||
def requestAfterLog = request.with() | ||
then: "same request should be returned after with operation" | ||
requestAfterLog == request | ||
and: "request should be wrapped" | ||
requestAfterLog instanceof RequestSpecificationDecorated | ||
} | ||
} |