Skip to content

Commit

Permalink
Merge 934f016 into 69b23f4
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe444 committed Jun 17, 2020
2 parents 69b23f4 + 934f016 commit 324cb38
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class ContractTestsGeneratorIT extends Specification {

def "should generate pact file"() {
expect:
pactGenerator.writePactFiles("com.hltech.contracts.judged.agent", "judge-d-agent", objectMapper, new File("target/pacts"))
pactGenerator.writePactFiles("com.hltech.judged.agent", "judge-d-agent", objectMapper, new File("target/pacts"))
}
}
5 changes: 0 additions & 5 deletions judge-d-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
<name>Judge-D-Core</name>

<dependencies>
<dependency>
<groupId>com.atlassian.oai</groupId>
<artifactId>swagger-request-validator-pact</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,18 @@ class RestContractValidatorUT extends Specification {
}
}
}

def 'should validate contracts specified in openapi v3'() {
given:
def swagger = new String(toByteArray(getClass().getResourceAsStream("/swagger-openapi3.json")))
def pact = (RequestResponsePact) loadPact(getClass().getResourceAsStream("/pact.json"))
when:
def validationResult = validator.validate(pact, swagger)
then:
for (report in validationResult) {
with(report) {
status == OK
}
}
}
}
34 changes: 34 additions & 0 deletions judge-d-server/src/test/resources/pact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"provider": {
"name": "judge-d-server"
},
"consumer": {
"name": "judge-d-agent"
},
"interactions": [
{
"description": "publish request; 200 OK response",
"request": {
"method": "PUT",
"path": "environments/nPUmfl0iF1",
"headers": {
"X-JUDGE-D-AGENT-SPACE": "dli0ONzhUW"
},
"query": "",
"body": [
{
"name": "_uss5_lSrR",
"version": "6PPZwQAg8G"
}
]
},
"response": {
"status": "200",
"headers": {}
}
}
],
"metadata": {
"pactSpecificationVersion": "1.0.0"
}
}
142 changes: 142 additions & 0 deletions judge-d-server/src/test/resources/swagger-openapi3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"paths": {
"/environments/{name}": {
"get": {
"tags": [
"environment-controller"
],
"operationId": "getEnvironment",
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ServiceDto"
}
}
}
}
}
}
},
"put": {
"tags": [
"environment-controller"
],
"operationId": "overwriteEnvironment",
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "X-JUDGE-D-AGENT-SPACE",
"in": "header",
"required": false,
"schema": {
"type": "string",
"default": "default"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/ServiceForm"
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/environments": {
"get": {
"tags": [
"environment-controller"
],
"operationId": "getEnvironmentNames",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"uniqueItems": true,
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"ServiceForm": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
}
}
},
"ServiceDto": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<groovyAllVersion>2.4.7</groovyAllVersion>
<groovyAllVersion>2.4.12</groovyAllVersion>
<lombokVersion>1.18.12</lombokVersion>
<spockVersion>1.1-groovy-2.4</spockVersion>
<version.number>1.${git.total.commit.count}.0_${git.commit.id.abbrev}</version.number>
Expand Down

0 comments on commit 324cb38

Please sign in to comment.