Files
spring-cloud-static/spring-cloud-contract/1.2.3.RELEASE/spring-cloud-contract-maven-plugin/complex.html
2018-02-09 16:08:45 +00:00

465 lines
25 KiB
HTML

<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.6 at 2018-02-09
| Rendered using Apache Maven Fluido Skin 1.5
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20180209" />
<meta http-equiv="Content-Language" content="en" />
<title>Spring Cloud Contract Maven Plugin &#x2013; </title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.5.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/apache-maven-fluido-1.5.min.js"></script>
</head>
<body class="topBarEnabled">
<a href="https://github.com/spring-cloud/spring-cloud-contract">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"
alt="Fork me on GitHub">
</a>
<div id="topbar" class="navbar navbar-fixed-top ">
<div class="navbar-inner">
<div class="container-fluid">
<a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<ul class="nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Overview <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="index.html" title="Introduction">Introduction</a>
</li>
<li> <a href="usage.html" title="Usage">Usage</a>
</li>
<li> <a href="plugin-info.html" title="Goals">Goals</a>
</li>
<li> <a href="junit.html" title="JUnit Configuration">JUnit Configuration</a>
</li>
<li> <a href="spock.html" title="Spock Configuration">Spock Configuration</a>
</li>
<li> <a href="complex.html" title="Complex Configuration">Complex Configuration</a>
</li>
<li> <a href="configs.html" title="Configuration snippets">Configuration snippets</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Related Projects <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="https://github.com/spring-cloud/spring-cloud-contract" title="Spring Cloud Contract">Spring Cloud Contract</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="project-info.html" title="Project Information">Project Information</a>
<ul class="dropdown-menu">
<li> <a href="integration.html" title="CI Management">CI Management</a>
</li>
<li> <a href="index.html" title="About">About</a>
</li>
<li> <a href="issue-tracking.html" title="Issue Management">Issue Management</a>
</li>
<li> <a href="license.html" title="Licenses">Licenses</a>
</li>
<li> <a href="plugin-management.html" title="Plugin Management">Plugin Management</a>
</li>
<li> <a href="plugins.html" title="Plugins">Plugins</a>
</li>
<li> <a href="team-list.html" title="Team">Team</a>
</li>
<li> <a href="source-repository.html" title="Source Code Management">Source Code Management</a>
</li>
<li> <a href="project-summary.html" title="Summary">Summary</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="project-reports.html" title="Project Reports">Project Reports</a>
<ul class="dropdown-menu">
<li> <a href="checkstyle.html" title="Checkstyle">Checkstyle</a>
</li>
<li> <a href="plugin-info.html" title="Plugin Documentation">Plugin Documentation</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div id="banner">
<div class="pull-left">
<div id="bannerLeft">
<h2>Spring Cloud Contract Maven Plugin</h2>
</div>
</div>
<div class="pull-right"> <div id="bannerRight">
<img src="" />
</div>
</div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2018-02-09
<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 1.2.3.RELEASE
</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li>
<a href="index.html" title="Introduction">
<span class="none"></span>
Introduction</a>
</li>
<li>
<a href="usage.html" title="Usage">
<span class="none"></span>
Usage</a>
</li>
<li>
<a href="plugin-info.html" title="Goals">
<span class="none"></span>
Goals</a>
</li>
<li>
<a href="junit.html" title="JUnit Configuration">
<span class="none"></span>
JUnit Configuration</a>
</li>
<li>
<a href="spock.html" title="Spock Configuration">
<span class="none"></span>
Spock Configuration</a>
</li>
<li class="active">
<a href="#"><span class="none"></span>Complex Configuration</a>
</li>
<li>
<a href="configs.html" title="Configuration snippets">
<span class="none"></span>
Configuration snippets</a>
</li>
<li class="nav-header">Related Projects</li>
<li>
<a href="https://github.com/spring-cloud/spring-cloud-contract" title="Spring Cloud Contract">
<span class="none"></span>
Spring Cloud Contract</a>
</li>
<li class="nav-header">Project Documentation</li>
<li>
<a href="project-info.html" title="Project Information">
<span class="icon-chevron-right"></span>
Project Information</a>
</li>
<li>
<a href="project-reports.html" title="Project Reports">
<span class="icon-chevron-right"></span>
Project Reports</a>
</li>
</ul>
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
</a>
</div>
</div>
</div>
<div id="bodyColumn" class="span10" >
<div class="sect1">
<h2 id="more_complex_plugin_configuration">More Complex Plugin Configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Sample more complex configuration for Java Project with JUnit tests.</p>
</div>
<div class="sect2">
<h3 id="project_configuration_for_spring_cloud_contract_verifier_with_junit_tests_and_stub_publishing">Project configuration for Spring Cloud Contract Verifier with JUnit tests and stub publishing</h3>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"> <span style="color:#070;font-weight:bold">&lt;plugin&gt;</span>
<span style="color:#070;font-weight:bold">&lt;groupId&gt;</span>org.springframework.cloud<span style="color:#070;font-weight:bold">&lt;/groupId&gt;</span>
<span style="color:#070;font-weight:bold">&lt;artifactId&gt;</span>spring-cloud-contract-maven-plugin<span style="color:#070;font-weight:bold">&lt;/artifactId&gt;</span>
<span style="color:#070;font-weight:bold">&lt;version&gt;</span>${spring-cloud-verifier-plugin.version}<span style="color:#070;font-weight:bold">&lt;/version&gt;</span>
<span style="color:#070;font-weight:bold">&lt;executions&gt;</span>
<span style="color:#070;font-weight:bold">&lt;execution&gt;</span>
<span style="color:#070;font-weight:bold">&lt;goals&gt;</span>
<span style="color:#070;font-weight:bold">&lt;goal&gt;</span>convert<span style="color:#070;font-weight:bold">&lt;/goal&gt;</span>
<span style="color:#070;font-weight:bold">&lt;goal&gt;</span>generateStubs<span style="color:#070;font-weight:bold">&lt;/goal&gt;</span>
<span style="color:#070;font-weight:bold">&lt;goal&gt;</span>generateTests<span style="color:#070;font-weight:bold">&lt;/goal&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/goals&gt;</span>
<span style="color:#070;font-weight:bold">&lt;configuration&gt;</span>
<span style="color:#070;font-weight:bold">&lt;contractsDirectory&gt;</span>src/test/contracts<span style="color:#070;font-weight:bold">&lt;/contractsDirectory&gt;</span>
<span style="color:#070;font-weight:bold">&lt;basePackageForTests&gt;</span>com.blogspot.toomuchcoding.frauddetection<span style="color:#070;font-weight:bold">&lt;/basePackageForTests&gt;</span>
<span style="color:#070;font-weight:bold">&lt;testMode&gt;</span>MOCKMVC<span style="color:#070;font-weight:bold">&lt;/testMode&gt;</span>
<span style="color:#070;font-weight:bold">&lt;testFramework&gt;</span>JUNIT<span style="color:#070;font-weight:bold">&lt;/testFramework&gt;</span>
<span style="color:#070;font-weight:bold">&lt;classifier&gt;</span>stubs<span style="color:#070;font-weight:bold">&lt;/classifier&gt;</span>
<span style="color:#070;font-weight:bold">&lt;nameSuffixForTests&gt;</span>Test<span style="color:#070;font-weight:bold">&lt;/nameSuffixForTests&gt;</span>
<span style="color:#070;font-weight:bold">&lt;ruleClassForTests&gt;</span>org.junit.rules.ErrorCollector<span style="color:#070;font-weight:bold">&lt;/ruleClassForTests&gt;</span>
<span style="color:#070;font-weight:bold">&lt;staticImports&gt;</span>
<span style="color:#070;font-weight:bold">&lt;staticImport&gt;</span>com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers.*<span style="color:#070;font-weight:bold">&lt;/staticImport&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/staticImports&gt;</span>
<span style="color:#070;font-weight:bold">&lt;imports&gt;</span>
<span style="color:#070;font-weight:bold">&lt;import&gt;</span>com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers<span style="color:#070;font-weight:bold">&lt;/import&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/imports&gt;</span>
<span style="color:#070;font-weight:bold">&lt;ignoredFiles&gt;</span>
<span style="color:#070;font-weight:bold">&lt;ignoredFile&gt;</span>broken**<span style="color:#070;font-weight:bold">&lt;/ignoredFile&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/ignoredFiles&gt;</span>
<span style="color:#070;font-weight:bold">&lt;excludedFiles&gt;</span>
<span style="color:#070;font-weight:bold">&lt;param&gt;</span>shouldMarkClientAsFraud.groovy<span style="color:#070;font-weight:bold">&lt;/param&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/excludedFiles&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/configuration&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/execution&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/executions&gt;</span>
<span style="color:#070;font-weight:bold">&lt;configuration&gt;</span>
<span style="color:#070;font-weight:bold">&lt;baseClassForTests&gt;</span>com.blogspot.toomuchcoding.frauddetection.BaseAccurest<span style="color:#070;font-weight:bold">&lt;/baseClassForTests&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/configuration&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/plugin&gt;</span></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="base_test_class">Base Test class</h3>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="java"><span style="color:#777">/**
*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</span>
<span style="color:#080;font-weight:bold">package</span> <span style="color:#707;font-weight:bold">com.blogspot.toomuchcoding.frauddetection</span>;
<span style="color:#080;font-weight:bold">import</span> <span style="color:#B44;font-weight:bold">io.restassured.module.mockmvc.RestAssuredMockMvc</span>;
<span style="color:#080;font-weight:bold">import</span> <span style="color:#B44;font-weight:bold">org.junit.Before</span>;
<span style="color:#088;font-weight:bold">public</span> <span style="color:#339;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">BaseAccurest</span> {
<span style="color:#007">@Before</span>
<span style="color:#088;font-weight:bold">public</span> <span style="color:#339;font-weight:bold">void</span> setup() {
RestAssuredMockMvc.standaloneSetup(<span style="color:#080;font-weight:bold">new</span> FraudDetectionController());
}
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="sample_additional_matcher">Sample additional matcher</h3>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="java"><span style="color:#777">/**
*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</span>
<span style="color:#080;font-weight:bold">package</span> <span style="color:#707;font-weight:bold">com.blogspot.toomuchcoding.frauddetection.matchers</span>;
<span style="color:#080;font-weight:bold">import</span> <span style="color:#B44;font-weight:bold">org.junit.Assert</span>;
<span style="color:#088;font-weight:bold">public</span> <span style="color:#339;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">CustomMatchers</span> {
<span style="color:#088;font-weight:bold">public</span> <span style="color:#088;font-weight:bold">static</span> <span style="color:#339;font-weight:bold">void</span> assertThatRejectionReasonIsNull(<span style="color:#0a8;font-weight:bold">String</span> rejectionReason) {
Assert.assertNull(rejectionReason);
}
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="sample_contract_using_matcher">Sample contract using matcher</h3>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="java"><span style="color:#777">/**
*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</span>
org.springframework.cloud.contract.spec.Contract.make {
request {
method <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">PUT</span><span style="color:#710">'</span></span>
url <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">/fraudcheck</span><span style="color:#710">'</span></span>
body(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#710">&quot;</span></span><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">
{
</span><span style="color:#710">&quot;</span></span>clientPesel<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">:</span><span style="color:#710">&quot;</span></span><span style="color:#F00;background-color:#FAA">$</span>{value(consumer(regex(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">[0-9]{10}</span><span style="color:#710">'</span></span>)), producer(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1234567890</span><span style="color:#710">'</span></span>))}<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">,
</span><span style="color:#710">&quot;</span></span>loanAmount<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">:123.123
}
</span><span style="color:#710">&quot;</span></span><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#710">&quot;</span></span>
)
headers {
header(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Content-Type</span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">application/vnd.fraud.v1+json</span><span style="color:#710">'</span></span>)
}
}
response {
status <span style="color:#00D">200</span>
body(
fraudCheckStatus: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">OK</span><span style="color:#710">&quot;</span></span>,
rejectionReason: <span style="color:#F00;background-color:#FAA">$</span>(consumer(<span style="color:#069">null</span>), producer(execute(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">assertThatRejectionReasonIsNull($it)</span><span style="color:#710">'</span></span>)))
)
headers {
header(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Content-Type</span><span style="color:#710">'</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">application/vnd.fraud.v1+json</span><span style="color:#710">'</span></span>)
}
}
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="project_source_code">Project source code</h3>
<div class="paragraph">
<p><a href="https://github.com/Codearte/accurest-maven-plugin/tree/master/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/test/projects/complex-configuration" class="bare">https://github.com/Codearte/accurest-maven-plugin/tree/master/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/test/projects/complex-configuration</a></p>
</div>
</div>
<div class="sect2">
<h3 id="more_samples">More samples</h3>
<div class="paragraph">
<p>You can check out the <a href="https://github.com/spring-cloud-samples/spring-cloud-contract-samples">Spring Cloud Contract Samples project</a> for
more examples of Maven plugin setup.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p >Copyright &copy; 2016&#x2013;2018
<a href="https://spring.io/">Spring</a>.
All rights reserved.
</p>
</div>
</div>
</footer>
</body>
</html>