File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
core/model/src/main/kotlin/au/com/dius/pact/core/model
pact-specification-test/src
main/resources/v4/response/headers
test/groovy/specification Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,7 @@ data class HttpResponse @JvmOverloads constructor(
235
235
}
236
236
237
237
companion object {
238
+ @JvmStatic
238
239
fun fromJson (json : JsonValue ): HttpResponse {
239
240
val status = when {
240
241
json.has(" status" ) -> {
Original file line number Diff line number Diff line change 3
3
"comment" : " Headers values are case sensitive" ,
4
4
"expected" : {
5
5
"headers" : {
6
- "Accept" : " alligators"
6
+ "X- Accept" : " alligators"
7
7
}
8
8
},
9
9
"actual" : {
10
10
"headers" : {
11
- "Accept" : " Alligators"
11
+ "X- Accept" : " Alligators"
12
12
}
13
13
}
14
14
}
Original file line number Diff line number Diff line change 1
1
package specification
2
2
3
3
import au.com.dius.pact.core.model.DefaultPactReader
4
+ import au.com.dius.pact.core.model.HttpResponse
4
5
import au.com.dius.pact.core.support.Json
5
6
import au.com.dius.pact.core.support.json.JsonParser
6
7
import groovy.util.logging.Slf4j
@@ -10,7 +11,7 @@ import spock.lang.Specification
10
11
class BaseResponseSpec extends Specification {
11
12
12
13
static List loadTestCases (String testDir ) {
13
- def resources = ResponseSpecificationV1Spec . getResource(testDir)
14
+ def resources = BaseResponseSpec . getResource(testDir)
14
15
def file = new File (resources. toURI())
15
16
def result = []
16
17
file. eachDir { d ->
@@ -31,4 +32,28 @@ class BaseResponseSpec extends Specification {
31
32
result
32
33
}
33
34
35
+ static List loadV4TestCases (String testDir ) {
36
+ def resources = BaseRequestSpec . getResource(testDir)
37
+ def file = new File (resources. toURI())
38
+ def result = []
39
+ file. eachDir { d ->
40
+ d. eachFile { f ->
41
+ def json = f. withReader { JsonParser . INSTANCE . parseReader(it) }
42
+ def jsonMap = Json . INSTANCE . toMap(json)
43
+ def expected = HttpResponse . fromJson(json. asObject(). get(' expected' ))
44
+ def actual = HttpResponse . fromJson(json. asObject(). get(' actual' ))
45
+ result << [
46
+ d. name,
47
+ f. name,
48
+ jsonMap. comment,
49
+ jsonMap. match,
50
+ jsonMap. match ? ' should match' : ' should not match' ,
51
+ expected,
52
+ actual
53
+ ]
54
+ }
55
+ }
56
+ result
57
+ }
58
+
34
59
}
You can’t perform that action at this time.
0 commit comments