This commit is contained in:
Tom Hombergs
2018-05-27 21:10:15 +02:00
parent a4d70d5835
commit 4d67dd44d0
40 changed files with 823 additions and 101 deletions

View File

@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="Gradle: com.google.guava:guava:25.0-jre">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/25.0-jre/7319c34fa5866a85b6bad445adad69d402323129/guava-25.0-jre.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/25.0-jre/30ade485699e7782cc2369b0e5d3d8e0bfc317c/guava-25.0-jre-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="Gradle: org.projectlombok:lombok:1.16.20">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.16.20/ac76d9b956045631d1561a09289cbf472e077c01/lombok-1.16.20.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.16.20/69ebf81bb97bdb3c9581c171762bb4929cb5289c/lombok-1.16.20-sources.jar!/" />
</SOURCES>
</library>
</component>

9
.idea/modules/spring-boot-testing.iml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="spring-boot-testing" external.linked.project.path="$MODULE_DIR$/../../spring-boot/spring-boot-testing" external.root.project.path="$MODULE_DIR$/../../spring-boot/spring-boot-testing" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../../spring-boot/spring-boot-testing" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":spring-boot:modularizing" external.linked.project.path="$MODULE_DIR$/../../../../spring-boot/modularizing" external.root.project.path="$MODULE_DIR$/../../../.." external.system.id="GRADLE" external.system.module.group="code-examples2.spring-boot" external.system.module.version="0.0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../../../../spring-boot/modularizing">
<excludeFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/build" />
<excludeFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/out" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":spring-boot:modularizing:main" external.linked.project.path="$MODULE_DIR$/../../../../spring-boot/modularizing" external.root.project.path="$MODULE_DIR$/../../../.." external.system.id="GRADLE" external.system.module.group="code-examples2.spring-boot" external.system.module.type="sourceSet" external.system.module.version="0.0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/out/production/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/src/main">
<sourceFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/src/main/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":spring-boot:modularizing:test" external.linked.project.path="$MODULE_DIR$/../../../../spring-boot/modularizing" external.root.project.path="$MODULE_DIR$/../../../.." external.system.id="GRADLE" external.system.module.group="code-examples2.spring-boot" external.system.module.type="sourceSet" external.system.module.version="0.0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output-test url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/out/test/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/src/test">
<sourceFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../../spring-boot/modularizing/src/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="modularizing_main" />
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-test:1.5.4.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-test-autoconfigure:1.5.4.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-test:1.5.4.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: com.jayway.jsonpath:json-path:2.2.0" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Gradle: org.assertj:assertj-core:2.6.0" level="project" />
<orderEntry type="library" name="Gradle: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Gradle: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" name="Gradle: org.springframework:spring-test:4.3.9.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-autoconfigure:1.5.4.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot:1.5.4.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework:spring-context:4.3.9.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework:spring-aop:4.3.9.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework:spring-beans:4.3.9.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework:spring-expression:4.3.9.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: org.springframework:spring-core:4.3.9.RELEASE" level="project" />
<orderEntry type="library" name="Gradle: net.minidev:json-smart:2.2.1" level="project" />
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Gradle: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" name="Gradle: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Gradle: net.minidev:accessors-smart:1.1" level="project" />
<orderEntry type="library" name="Gradle: org.ow2.asm:asm:5.0.3" level="project" />
</component>
<component name="TestModuleProperties" production-module="modularizing_main" />
</module>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":spring-boot:spring-boot-test" external.linked.project.path="$MODULE_DIR$/../../../../spring-boot/spring-boot-test" external.root.project.path="$MODULE_DIR$/../../../.." external.system.id="GRADLE" external.system.module.group="code-examples2.spring-boot" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../../../../spring-boot/spring-boot-test">
<excludeFolder url="file://$MODULE_DIR$/../../../../spring-boot/spring-boot-test/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/../../../../spring-boot/spring-boot-test/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,4 @@
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

View File

@@ -0,0 +1,94 @@
package org.springframework.cloud.contract.verifier.tests;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import io.reflectoring.UserServiceBase;
import io.restassured.module.mockmvc.specification.MockMvcRequestSpecification;
import io.restassured.response.ResponseOptions;
import org.junit.Test;
import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;
import static io.restassured.module.mockmvc.RestAssuredMockMvc.*;
import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat;
public class UserserviceTest extends UserServiceBase {
@Test
public void validate_pactContract_0() throws Exception {
// given:
MockMvcRequestSpecification request = given()
.header("Content-Type", "application/json")
.body("{\"firstName\":\"Arthur\",\"lastName\":\"Dent\"}");
// when:
ResponseOptions response = given().spec(request)
.post("/user-service/users");
// then:
assertThat(response.statusCode()).isEqualTo(201);
assertThat(response.header("Content-Type")).isEqualTo("application/json;charset=UTF-8");
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
// and:
assertThat((Object) parsedJson.read("$.['id']")).isInstanceOf(java.lang.Integer.class);
}
@Test
public void validate_pactContract_1() throws Exception {
// given:
MockMvcRequestSpecification request = given()
.header("Content-Type", "application/json")
.body("{\"firstName\":\"Zaphod\",\"lastName\":\"Beeblebrox\"}");
// when:
ResponseOptions response = given().spec(request)
.put("/user-service/users/42");
// then:
assertThat(response.statusCode()).isEqualTo(200);
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
// and:
assertThat((Object) parsedJson.read("$.['lastName']")).isInstanceOf(java.lang.String.class);
assertThat((Object) parsedJson.read("$.['firstName']")).isInstanceOf(java.lang.String.class);
}
@Test
public void validate_shouldSaveUser() throws Exception {
// given:
MockMvcRequestSpecification request = given()
.header("Content-Type", "application/json")
.body("{\"firstName\":\"Arthur\",\"lastName\":\"Dent\"}");
// when:
ResponseOptions response = given().spec(request)
.post("/user-service/users");
// then:
assertThat(response.statusCode()).isEqualTo(201);
assertThat(response.header("Content-Type")).matches("application/json.*");
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
assertThatJson(parsedJson).field("['id']").isEqualTo(42);
}
@Test
public void validate_shouldUpdateUser() throws Exception {
// given:
MockMvcRequestSpecification request = given()
.header("Content-Type", "application/json")
.body("{\"firstName\":\"Arthur\",\"lastName\":\"Dent\"}");
// when:
ResponseOptions response = given().spec(request)
.put("/user-service/users/42");
// then:
assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).matches("application/json.*");
// and:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
assertThatJson(parsedJson).field("['id']").isEqualTo(42);
}
}

View File

@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
<title>Test results - Package org.springframework.cloud.contract.verifier.tests</title>
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<script src="../js/report.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
<h1>Package org.springframework.cloud.contract.verifier.tests</h1>
<div class="breadcrumbs">
<a href="../index.html">all</a> &gt; org.springframework.cloud.contract.verifier.tests</div>
<div id="summary">
<table>
<tr>
<td>
<div class="summaryGroup">
<table>
<tr>
<td>
<div class="infoBox" id="tests">
<div class="counter">4</div>
<p>tests</p>
</div>
</td>
<td>
<div class="infoBox" id="failures">
<div class="counter">0</div>
<p>failures</p>
</div>
</td>
<td>
<div class="infoBox" id="ignored">
<div class="counter">0</div>
<p>ignored</p>
</div>
</td>
<td>
<div class="infoBox" id="duration">
<div class="counter">0.438s</div>
<p>duration</p>
</div>
</td>
</tr>
</table>
</div>
</td>
<td>
<div class="infoBox success" id="successRate">
<div class="percent">100%</div>
<p>successful</p>
</div>
</td>
</tr>
</table>
</div>
<div id="tabs">
<ul class="tabLinks">
<li>
<a href="#tab0">Classes</a>
</li>
</ul>
<div id="tab0" class="tab">
<h2>Classes</h2>
<table>
<thread>
<tr>
<th>Class</th>
<th>Tests</th>
<th>Failures</th>
<th>Ignored</th>
<th>Duration</th>
<th>Success rate</th>
</tr>
</thread>
<tr>
<td class="success">
<a href="../classes/org.springframework.cloud.contract.verifier.tests.UserserviceTest.html">UserserviceTest</a>
</td>
<td>4</td>
<td>0</td>
<td>0</td>
<td>0.438s</td>
<td class="success">100%</td>
</tr>
</table>
</div>
</div>
<div id="footer">
<p>
<div>
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 4.2</a> at 13.01.2018 12:52:28</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,78 @@
{
"consumer": {
"name": "ui"
},
"provider": {
"name": "userservice"
},
"interactions": [
{
"description": "a request to POST a person",
"providerState": "provider accepts a new person",
"request": {
"method": "POST",
"path": "/user-service/users",
"headers": {
"Content-Type": "application/json"
},
"body": {
"firstName": "Arthur",
"lastName": "Dent"
}
},
"response": {
"status": 201,
"headers": {
"Content-Type": "application/json;charset=UTF-8"
},
"body": {
"id": 42
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
},
{
"description": "a request to PUT a person",
"providerState": "person 42 exists",
"request": {
"method": "PUT",
"path": "/user-service/users/42",
"headers": {
"Content-Type": "application/json"
},
"body": {
"firstName": "Zaphod",
"lastName": "Beeblebrox"
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
},
"response": {
"status": 200,
"headers": {
},
"body": {
"firstName": "Zaphod",
"lastName": "Beeblebrox"
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}

View File

@@ -0,0 +1,78 @@
{
"consumer": {
"name": "ui"
},
"provider": {
"name": "userservice"
},
"interactions": [
{
"description": "a request to POST a person",
"providerState": "provider accepts a new person",
"request": {
"method": "POST",
"path": "/user-service/users",
"headers": {
"Content-Type": "application/json"
},
"body": {
"firstName": "Arthur",
"lastName": "Dent"
}
},
"response": {
"status": 201,
"headers": {
"Content-Type": "application/json;charset=UTF-8"
},
"body": {
"id": 42
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
},
{
"description": "a request to PUT a person",
"providerState": "person 42 exists",
"request": {
"method": "PUT",
"path": "/user-service/users/42",
"headers": {
"Content-Type": "application/json"
},
"body": {
"firstName": "Zaphod",
"lastName": "Beeblebrox"
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
},
"response": {
"status": 200,
"headers": {
},
"body": {
"firstName": "Zaphod",
"lastName": "Beeblebrox"
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}

View File

@@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@@ -0,0 +1,81 @@
{
"consumer": {
"name": "ui"
},
"provider": {
"name": "userservice"
},
"interactions": [
{
"description": "a request to POST a person",
"providerState": "provider accepts a new person",
"request": {
"method": "POST",
"path": "/user-service/users",
"headers": {
"Content-Type": "application/json"
},
"body": {
"firstName": "Arthur",
"lastName": "Dent"
}
},
"response": {
"status": 201,
"headers": {
"Content-Type": "application/json;charset=UTF-8"
},
"body": {
"id": 42
},
"matchingRules": {
"$.body": {
"match": "type"
},
"$.headers.Content-Type": {
"regex": "^application/json.*"
}
}
}
},
{
"description": "a request to PUT a person",
"providerState": "person 42 exists",
"request": {
"method": "PUT",
"path": "/user-service/users/42",
"headers": {
"Content-Type": "application/json"
},
"body": {
"firstName": "Zaphod",
"lastName": "Beeblebrox"
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
},
"response": {
"status": 200,
"headers": {
},
"body": {
"firstName": "Zaphod",
"lastName": "Beeblebrox"
},
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}

View File

@@ -1,26 +0,0 @@
{
"id" : "90f75764-c4c3-4e8c-8bdb-876d31a28fec",
"request" : {
"url" : "/user-service/users",
"method" : "POST",
"headers" : {
"Content-Type" : {
"equalTo" : "application/json"
}
},
"bodyPatterns" : [ {
"matchesJsonPath" : "$[?(@.['lastName'] == 'Dent')]"
}, {
"matchesJsonPath" : "$[?(@.['firstName'] == 'Arthur')]"
} ]
},
"response" : {
"status" : 201,
"body" : "{\"id\":42}",
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
},
"transformers" : [ "response-template" ]
},
"uuid" : "90f75764-c4c3-4e8c-8bdb-876d31a28fec"
}

View File

@@ -1,23 +0,0 @@
{
"id" : "ca60467b-7665-4f28-b801-73d8af8125b1",
"request" : {
"url" : "/user-service/users/42",
"method" : "PUT",
"headers" : {
"Content-Type" : {
"equalTo" : "application/json"
}
},
"bodyPatterns" : [ {
"matchesJsonPath" : "$[?(@.['lastName'] == 'Beeblebrox')]"
}, {
"matchesJsonPath" : "$[?(@.['firstName'] == 'Zaphod')]"
} ]
},
"response" : {
"status" : 200,
"body" : "{\"firstName\":\"Zaphod\",\"lastName\":\"Beeblebrox\"}",
"transformers" : [ "response-template" ]
},
"uuid" : "ca60467b-7665-4f28-b801-73d8af8125b1"
}

View File

@@ -1,26 +0,0 @@
{
"id" : "24699071-7724-459a-9e15-6d0340082230",
"request" : {
"url" : "/user-service/users",
"method" : "POST",
"headers" : {
"Content-Type" : {
"matches" : "application/json.*"
}
},
"bodyPatterns" : [ {
"matchesJsonPath" : "$[?(@.['lastName'] == 'Dent')]"
}, {
"matchesJsonPath" : "$[?(@.['firstName'] == 'Arthur')]"
} ]
},
"response" : {
"status" : 201,
"body" : "{\"id\":42}",
"headers" : {
"Content-Type" : "application/json"
},
"transformers" : [ "response-template" ]
},
"uuid" : "24699071-7724-459a-9e15-6d0340082230"
}

View File

@@ -1,26 +0,0 @@
{
"id" : "a74535f2-8b30-44e5-ad3c-074c8cc51ee0",
"request" : {
"url" : "/user-service/users/42",
"method" : "PUT",
"headers" : {
"Content-Type" : {
"matches" : "application/json.*"
}
},
"bodyPatterns" : [ {
"matchesJsonPath" : "$[?(@.['lastName'] == 'Dent')]"
}, {
"matchesJsonPath" : "$[?(@.['firstName'] == 'Arthur')]"
} ]
},
"response" : {
"status" : 200,
"body" : "{\"id\":42}",
"headers" : {
"Content-Type" : "application/json"
},
"transformers" : [ "response-template" ]
},
"uuid" : "a74535f2-8b30-44e5-ad3c-074c8cc51ee0"
}