Fixed the build

This commit is contained in:
Marcin Grzejszczak
2016-07-27 11:59:21 +02:00
parent 6fd4b52ea9
commit 1aba428aaf
6 changed files with 21 additions and 76 deletions

View File

@@ -7,8 +7,8 @@
<artifactId>http-client-restdocs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring Cloud Contract Verifier Http Client Sample</name>
<description>Spring Cloud Contract Verifier Http Client Sample</description>
<name>Spring Cloud Contract RestDocs Http Client Sample</name>
<description>Spring Cloud Contract RestDocs Http Client Sample</description>
<parent>
<groupId>org.springframework.boot</groupId>

View File

@@ -11,7 +11,6 @@ buildscript {
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
}
}
@@ -39,10 +38,6 @@ dependencyManagement {
}
}
contracts {
baseClassForTests = 'com.example.fraud.MvcTest'
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")

View File

@@ -7,8 +7,8 @@
<artifactId>http-server-restdocs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring Cloud Contract Verifier Http Server Sample</name>
<description>Spring Cloud Contract Verifier Http Server Sample</description>
<name>Spring Cloud Contract RestDocs Http Server Sample</name>
<description>Spring Cloud RestDocs Verifier Http Server Sample</description>
<parent>
<groupId>org.springframework.boot</groupId>
@@ -49,6 +49,11 @@
<artifactId>spring-cloud-contract-wiremock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>

View File

@@ -1,10 +1,8 @@
package com.example.fraud;
import static org.springframework.cloud.contract.wiremock.restdocs.WireMockRestDocs.verify;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import java.math.BigDecimal;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +18,10 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.example.fraud.model.FraudCheck;
import com.fasterxml.jackson.databind.ObjectMapper;
import static org.springframework.cloud.contract.wiremock.restdocs.WireMockRestDocs.verify;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@@ -34,6 +36,13 @@ public class StubGeneratorTests {
private JacksonTester<FraudCheck> json;
@Before
public void setup() {
ObjectMapper objectMappper = new ObjectMapper();
// Possibly configure the mapper
JacksonTester.initFields(this, objectMappper);
}
@Test
public void shouldMarkClientAsFraud() throws Exception {
FraudCheck fraudCheck = new FraudCheck();

View File

@@ -1,31 +0,0 @@
package contracts
org.springframework.cloud.contract.spec.Contract.make {
request {
method 'PUT'
url '/fraudcheck'
body("""
{
"clientId":"${value(consumer(regex('[0-9]{10}')))}",
"loanAmount":99999}
"""
)
headers {
header('Content-Type', 'application/vnd.fraud.v1+json')
}
}
response {
status 200
body( """{
"fraudCheckStatus": "FRAUD",
"rejectionReason": "Amount too high"
}""")
headers {
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}
}

View File

@@ -1,33 +0,0 @@
package contracts
org.springframework.cloud.contract.spec.Contract.make {
request {
method 'PUT'
url '/fraudcheck'
body("""
{
"clientId":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}",
"loanAmount":123.123
}
"""
)
headers {
header('Content-Type', 'application/vnd.fraud.v1+json')
}
}
response {
status 200
body(
fraudCheckStatus: "OK",
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}
}