Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe444 committed Oct 27, 2020
1 parent 30463fa commit bf30160
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 43 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- mvn validate docker:build@build-docker -P docker-app -f ./judge-d-server/pom.xml
- mvn validate docker:build@build-docker -P docker-app -f ./judge-d-agent/pom.xml
- stage: build & publish docker image for server
if: branch = master AND NOT type IN (pull_request)
script:
- mvn validate docker:build@build-docker -P docker-app -f ./judge-d-server/pom.xml
- echo "Pushing to docker registry"
Expand Down
8 changes: 7 additions & 1 deletion judge-d-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
<dependency>
<groupId>com.atlassian.oai</groupId>
<artifactId>swagger-request-validator-pact</artifactId>
<version>2.10.2</version>
<version>1.4.6</version>
<exclusions>
<exclusion>
<artifactId>sdfsdf</artifactId>
<groupId>org.scala-lang</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import au.com.dius.pact.model.RequestResponseInteraction;
import au.com.dius.pact.model.RequestResponsePact;
import com.atlassian.oai.validator.OpenApiInteractionValidator;
import com.atlassian.oai.validator.SwaggerRequestResponseValidator;
import com.atlassian.oai.validator.pact.PactResponse;
import com.atlassian.oai.validator.report.ValidationReport;
import com.hltech.judged.server.domain.validation.InterfaceContractValidator;
Expand All @@ -27,7 +27,7 @@ public RestContractValidator() {

@Override
public List<InteractionValidationResult> validate(RequestResponsePact pact, String capabilities) {
OpenApiInteractionValidator swaggerValidator = OpenApiInteractionValidator.createForInlineApiSpecification(capabilities).build();
SwaggerRequestResponseValidator swaggerValidator = SwaggerRequestResponseValidator.createFor(capabilities).build();

Map<RequestResponseInteraction, ValidationReport> validationReports = pact.getInteractions()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,4 @@ class RestContractValidatorUT extends Specification {
}
}

def 'should validate contracts specified in openapi v3 - should find failures when media type is specified'() {
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:
validationResult.size() == 2
validationResult.any { result ->
result.name == 'get envs; 200 OK response' &&
result.status == FAILED &&
result.errors.get(0) == "[Path '/0'] Instance type (integer) does not match any allowed primitive type (allowed: [\"string\"])"
}
validationResult.any { result ->
result.name == 'publish request; 200 OK response' &&
result.status == FAILED &&
result.errors.get(0) == "[Path '/0'] Object instance has properties which are not allowed by the schema: [\"gyyigi\"]"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,6 @@ class ServiceIdContractsRepositoryImplIT extends Specification {
@Autowired
private ServiceContractsRepository repository

def 'should find what was saved'() {
given:
def serviceContracts = new ServiceContracts(
new ServiceId('provider', '1.0'),
[new Capability('ping', new Contract('654321', MediaType.APPLICATION_JSON_VALUE))],
[new Expectation('some-other-provider', 'ping', new Contract("098765", MediaType.APPLICATION_JSON_VALUE))]
)
repository.persist(serviceContracts)
when:
def retrieved = repository.findOne(new ServiceId(serviceContracts.name, serviceContracts.version))
then:
retrieved.get().id.name == 'provider'
retrieved.get().id.version == '1.0'
retrieved.isPresent()
with(retrieved.get()) {
getMappedCapabilities("ping", identity()).get() == "654321"
getMappedExpectations('some-other-provider', "ping", identity()).get() == "098765"
}
}

def 'should find all persisted service names'() {
given:
Expand Down
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.12</groovyAllVersion>
<groovyAllVersion>2.4.7</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 bf30160

Please sign in to comment.