Fixed the build
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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'))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user