Applied checkstyle rules

This commit is contained in:
Marcin Grzejszczak
2016-08-29 12:04:21 +02:00
parent c7a44b92ae
commit bfc2172d66
86 changed files with 509 additions and 482 deletions

92
pom.xml
View File

@@ -205,9 +205,52 @@
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build-tools</artifactId>
<version>${spring-cloud-build.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<excludes>${project.build.directory}/**</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
<excludes>${project.build.directory}/**</excludes>
</configuration>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>spring</id>
@@ -312,55 +355,6 @@
</plugins>
</build>
</profile>
<profile>
<id>checkstyle</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build-tools</artifactId>
<version>${spring-cloud-build.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
</project>

View File

@@ -54,7 +54,7 @@ class Service {
}
public String getBase() {
return base;
return this.base;
}
public void setBase(String base) {

View File

@@ -2,13 +2,13 @@
* Copyright 2009 Wilfred Springer
* Copyright 2012 Jason Pell
* Copyright 2013 Antonio García-Domínguez
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,23 +17,22 @@
*/
package repackaged.nl.flotsam.xeger;
import java.util.Random;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.util.Random;
import static org.junit.Assert.assertThat;
public class XegerUtilsTest {
@Test
public void shouldGenerateRandomNumberCorrectly() {
Random random = new Random();
for (int i = 0; i < 100; i++) {
int number = Xeger.getRandomInt(3, 7, random);
assertThat(number, Matchers.greaterThanOrEqualTo(3));
assertThat(number, Matchers.lessThanOrEqualTo(7));
}
}
@Test public void shouldGenerateRandomNumberCorrectly() {
Random random = new Random();
for (int i = 0; i < 100; i++) {
int number = Xeger.getRandomInt(3, 7, random);
assertThat(number, Matchers.greaterThanOrEqualTo(3));
assertThat(number, Matchers.lessThanOrEqualTo(7));
}
}
}

View File

@@ -0,0 +1 @@
/.apt_generated/

View File

@@ -184,7 +184,7 @@ public class AetherStubDownloader implements StubDownloader {
Artifact artifact = new DefaultArtifact(stubsGroup, stubsModule, classifier,
ARTIFACT_EXTENSION, LATEST_ARTIFACT_VERSION);
VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact,
remoteRepos, null);
this.remoteRepos, null);
VersionRangeResult rangeResult;
try {
rangeResult = this.repositorySystem.resolveVersionRange(this.session,
@@ -207,7 +207,7 @@ public class AetherStubDownloader implements StubDownloader {
String version, String classifier) {
Artifact artifact = new DefaultArtifact(stubsGroup, stubsModule, classifier,
ARTIFACT_EXTENSION, version);
VersionRequest versionRequest = new VersionRequest(artifact, remoteRepos, null);
VersionRequest versionRequest = new VersionRequest(artifact, this.remoteRepos, null);
VersionResult versionResult;
try {
versionResult = this.repositorySystem.resolveVersion(this.session, versionRequest);

View File

@@ -38,14 +38,14 @@ class Arguments {
}
public StubRunnerOptions getStubRunnerOptions() {
return stubRunnerOptions;
return this.stubRunnerOptions;
}
public String getRepositoryPath() {
return repositoryPath;
return this.repositoryPath;
}
public StubConfiguration getStub() {
return stub;
return this.stub;
}
}

View File

@@ -54,22 +54,22 @@ class AvailablePortScanner {
}
public <T> T tryToExecuteWithFreePort(PortCallback<T> closure) {
for (int i = 0; i < maxRetryCount; i++) {
for (int i = 0; i < this.maxRetryCount; i++) {
try {
int numberOfPortsToBind = maxPortNumber - minPortNumber + 1;
int numberOfPortsToBind = this.maxPortNumber - this.minPortNumber + 1;
int portToScan = new Random().nextInt(numberOfPortsToBind)
+ minPortNumber;
+ this.minPortNumber;
checkIfPortIsAvailable(portToScan);
return executeLogicForAvailablePort(portToScan, closure);
}
catch (IOException exception) {
if (log.isDebugEnabled()) {
log.debug("Failed to execute callback (try: " + i + "/" + maxRetryCount
log.debug("Failed to execute callback (try: " + i + "/" + this.maxRetryCount
+ ")", exception);
}
}
}
throw new NoPortAvailableException(minPortNumber, maxPortNumber);
throw new NoPortAvailableException(this.minPortNumber, this.maxPortNumber);
}
private <T> T executeLogicForAvailablePort(int portToScan, PortCallback<T> closure) throws IOException {

View File

@@ -42,7 +42,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public RunningStubs runStubs() {
Map<StubConfiguration, Integer> map = new LinkedHashMap<>();
for (StubRunner value : stubRunners) {
for (StubRunner value : this.stubRunners) {
RunningStubs runningStubs = value.runStubs();
map.putAll(runningStubs.validNamesAndPorts());
}
@@ -51,7 +51,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public URL findStubUrl(String groupId, String artifactId) {
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
URL url = stubRunner.findStubUrl(groupId, artifactId);
if (url != null) {
return url;
@@ -75,7 +75,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public RunningStubs findAllRunningStubs() {
Collection<RunningStubs> running = new LinkedHashSet<>();
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
running.add(stubRunner.findAllRunningStubs());
}
return new RunningStubs(running);
@@ -84,7 +84,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public Map<StubConfiguration, Collection<Contract>> getContracts() {
Map<StubConfiguration, Collection<Contract>> map = new LinkedHashMap<>();
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
for (Entry<StubConfiguration, Collection<Contract>> entry : stubRunner
.getContracts().entrySet()) {
if (map.containsKey(entry.getKey())) {
@@ -101,7 +101,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public boolean trigger(String ivyNotation, String labelName) {
boolean success = false;
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
if (stubRunner.trigger(ivyNotation, labelName)) {
success = true;
}
@@ -130,7 +130,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public boolean trigger(String labelName) {
boolean success = false;
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
if (stubRunner.trigger(labelName)) {
success = true;
}
@@ -147,7 +147,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public boolean trigger() {
boolean success = false;
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
if (stubRunner.trigger()) {
success = true;
}
@@ -158,7 +158,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public Map<String, Collection<String>> labels() {
Map<String, Collection<String>> map = new LinkedHashMap<>();
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
for (Entry<String, Collection<String>> entry : stubRunner.labels()
.entrySet()) {
if (map.containsKey(entry.getKey())) {
@@ -174,7 +174,7 @@ public class BatchStubRunner implements StubRunning {
@Override
public void close() throws IOException {
for (StubRunner stubRunner : stubRunners) {
for (StubRunner stubRunner : this.stubRunners) {
stubRunner.close();
}
}

View File

@@ -46,7 +46,7 @@ public class BatchStubRunnerFactory {
}
public BatchStubRunner buildBatchStubRunner() {
StubRunnerFactory stubRunnerFactory = new StubRunnerFactory(stubRunnerOptions, stubDownloader, contractVerifierMessaging);
StubRunnerFactory stubRunnerFactory = new StubRunnerFactory(this.stubRunnerOptions, this.stubDownloader, this.contractVerifierMessaging);
return new BatchStubRunner(stubRunnerFactory.createStubsFromServiceConfiguration());
}

View File

@@ -46,7 +46,7 @@ public class RunningStubs {
}
public Map.Entry<StubConfiguration, Integer> getEntry(String artifactId) {
for (Entry<StubConfiguration, Integer> it : namesAndPorts.entrySet()) {
for (Entry<StubConfiguration, Integer> it : this.namesAndPorts.entrySet()) {
if (it.getKey().matchesIvyNotation(artifactId)) {
return it;
}
@@ -55,7 +55,7 @@ public class RunningStubs {
}
public Integer getPort(String groupId, String artifactId) {
for (Entry<StubConfiguration, Integer> it : namesAndPorts.entrySet()) {
for (Entry<StubConfiguration, Integer> it : this.namesAndPorts.entrySet()) {
if (it.getKey().matchesIvyNotation(groupId + ":" + artifactId)) {
return it.getValue();
}
@@ -72,12 +72,12 @@ public class RunningStubs {
}
public Set<StubConfiguration> getAllServices() {
return namesAndPorts.keySet();
return this.namesAndPorts.keySet();
}
public Set<String> getAllServicesNames() {
Set<String> result = new LinkedHashSet<>();
for (Entry<StubConfiguration, Integer> it : namesAndPorts.entrySet()) {
for (Entry<StubConfiguration, Integer> it : this.namesAndPorts.entrySet()) {
result.add(it.getKey().artifactId);
}
return result;
@@ -85,7 +85,7 @@ public class RunningStubs {
public Map<String, Integer> toIvyToPortMapping() {
Map<String, Integer> result = new LinkedHashMap<>();
for (Entry<StubConfiguration, Integer> it : namesAndPorts.entrySet()) {
for (Entry<StubConfiguration, Integer> it : this.namesAndPorts.entrySet()) {
result.put(it.getKey().toColonSeparatedDependencyNotation(), it.getValue());
}
return result;
@@ -93,7 +93,7 @@ public class RunningStubs {
public Map<StubConfiguration, Integer> validNamesAndPorts() {
Map<StubConfiguration, Integer> result = new LinkedHashMap<>();
for (Entry<StubConfiguration, Integer> it : namesAndPorts.entrySet()) {
for (Entry<StubConfiguration, Integer> it : this.namesAndPorts.entrySet()) {
if (it.getValue() != null && it.getValue() >= 0) {
result.put(it.getKey(), it.getValue());
}
@@ -103,7 +103,7 @@ public class RunningStubs {
@Override
public String toString() {
return "RunningStubs [namesAndPorts=" + namesAndPorts + "]";
return "RunningStubs [namesAndPorts=" + this.namesAndPorts + "]";
}
@Override
@@ -111,7 +111,7 @@ public class RunningStubs {
final int prime = 31;
int result = 1;
result = prime * result
+ ((namesAndPorts == null) ? 0 : namesAndPorts.hashCode());
+ ((this.namesAndPorts == null) ? 0 : this.namesAndPorts.hashCode());
return result;
}
@@ -124,11 +124,11 @@ public class RunningStubs {
if (getClass() != obj.getClass())
return false;
RunningStubs other = (RunningStubs) obj;
if (namesAndPorts == null) {
if (this.namesAndPorts == null) {
if (other.namesAndPorts != null)
return false;
}
else if (!namesAndPorts.equals(other.namesAndPorts))
else if (!this.namesAndPorts.equals(other.namesAndPorts))
return false;
return true;
}

View File

@@ -83,7 +83,7 @@ public class StubConfiguration {
}
private boolean isDefined() {
return StringUtils.hasText(groupId) && StringUtils.hasText(this.artifactId);
return StringUtils.hasText(this.groupId) && StringUtils.hasText(this.artifactId);
}
public String toColonSeparatedDependencyNotation() {
@@ -91,7 +91,7 @@ public class StubConfiguration {
return "";
}
return StringUtils.arrayToDelimitedString(
new String[] { groupId, artifactId, version, classifier },
new String[] { this.groupId, this.artifactId, this.version, this.classifier },
STUB_COLON_DELIMITER);
}
@@ -106,23 +106,23 @@ public class StubConfiguration {
}
public String getGroupId() {
return groupId;
return this.groupId;
}
public String getArtifactId() {
return artifactId;
return this.artifactId;
}
public String getClassifier() {
return classifier;
return this.classifier;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode());
result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
result = prime * result + ((this.artifactId == null) ? 0 : this.artifactId.hashCode());
result = prime * result + ((this.groupId == null) ? 0 : this.groupId.hashCode());
return result;
}
@@ -135,17 +135,17 @@ public class StubConfiguration {
if (getClass() != obj.getClass())
return false;
StubConfiguration other = (StubConfiguration) obj;
if (artifactId == null) {
if (this.artifactId == null) {
if (other.artifactId != null)
return false;
}
else if (!artifactId.equals(other.artifactId))
else if (!this.artifactId.equals(other.artifactId))
return false;
if (groupId == null) {
if (this.groupId == null) {
if (other.groupId != null)
return false;
}
else if (!groupId.equals(other.groupId))
else if (!this.groupId.equals(other.groupId))
return false;
return true;
}
@@ -153,18 +153,18 @@ public class StubConfiguration {
public boolean matchesIvyNotation(String ivyNotationAsString) {
String[] strings = ivyNotationAsString.split(":");
if (strings.length == 1) {
return artifactId.equals(ivyNotationAsString);
return this.artifactId.equals(ivyNotationAsString);
}
else if (strings.length == 2) {
return groupId.equals(strings[0]) && artifactId.equals(strings[1]);
return this.groupId.equals(strings[0]) && this.artifactId.equals(strings[1]);
}
else if (strings.length == 3) {
return groupId.equals(strings[0]) && artifactId.equals(strings[1])
&& (strings[2].equals(DEFAULT_VERSION) || version.equals(strings[2]));
return this.groupId.equals(strings[0]) && this.artifactId.equals(strings[1])
&& (strings[2].equals(DEFAULT_VERSION) || this.version.equals(strings[2]));
}
return groupId.equals(strings[0]) && artifactId.equals(strings[1])
&& (strings[2].equals(DEFAULT_VERSION) || version.equals(strings[2]))
&& classifier.equals(strings[3]);
return this.groupId.equals(strings[0]) && this.artifactId.equals(strings[1])
&& (strings[2].equals(DEFAULT_VERSION) || this.version.equals(strings[2]))
&& this.classifier.equals(strings[3]);
}
private String[] ivyNotationFrom(String ivyNotation) {

View File

@@ -56,15 +56,15 @@ class StubRepository {
}
public File getPath() {
return path;
return this.path;
}
public List<WiremockMappingDescriptor> getProjectDescriptors() {
return projectDescriptors;
return this.projectDescriptors;
}
public Collection<Contract> getContracts() {
return contracts;
return this.contracts;
}
/**
@@ -87,7 +87,7 @@ class StubRepository {
}
private List<WiremockMappingDescriptor> contextDescriptors() {
return path.exists() ? collectMappingDescriptors(path)
return this.path.exists() ? collectMappingDescriptors(this.path)
: Collections.<WiremockMappingDescriptor>emptyList();
}
@@ -116,7 +116,7 @@ class StubRepository {
}
private Collection<Contract> contractDescriptors() {
return (path.exists() ? collectContractDescriptors(path)
return (this.path.exists() ? collectContractDescriptors(this.path)
: Collections.<Contract>emptySet());
}

View File

@@ -64,13 +64,13 @@ public class StubRunner implements StubRunning {
@Override
public RunningStubs runStubs() {
registerShutdownHook();
return localStubRunner.runStubs(stubRunnerOptions, stubRepository,
stubsConfiguration);
return this.localStubRunner.runStubs(this.stubRunnerOptions, this.stubRepository,
this.stubsConfiguration);
}
@Override
public URL findStubUrl(String groupId, String artifactId) {
return localStubRunner.findStubUrl(groupId, artifactId);
return this.localStubRunner.findStubUrl(groupId, artifactId);
}
@Override
@@ -85,32 +85,32 @@ public class StubRunner implements StubRunning {
@Override
public RunningStubs findAllRunningStubs() {
return localStubRunner.findAllRunningStubs();
return this.localStubRunner.findAllRunningStubs();
}
@Override
public Map<StubConfiguration, Collection<Contract>> getContracts() {
return localStubRunner.getContracts();
return this.localStubRunner.getContracts();
}
@Override
public boolean trigger(String ivyNotation, String labelName) {
return localStubRunner.trigger(ivyNotation, labelName);
return this.localStubRunner.trigger(ivyNotation, labelName);
}
@Override
public boolean trigger(String labelName) {
return localStubRunner.trigger(labelName);
return this.localStubRunner.trigger(labelName);
}
@Override
public boolean trigger() {
return localStubRunner.trigger();
return this.localStubRunner.trigger();
}
@Override
public Map<String, Collection<String>> labels() {
return localStubRunner.labels();
return this.localStubRunner.labels();
}
private void registerShutdownHook() {
@@ -129,8 +129,8 @@ public class StubRunner implements StubRunning {
@Override
public void close() throws IOException {
if (localStubRunner != null) {
localStubRunner.shutdown();
if (this.localStubRunner != null) {
this.localStubRunner.shutdown();
}
}
}

View File

@@ -74,12 +74,12 @@ class StubRunnerExecutor implements StubFinder {
private RunningStubs runningStubs() {
return new RunningStubs(Collections
.singletonMap(stubServer.getStubConfiguration(), stubServer.getPort()));
.singletonMap(this.stubServer.getStubConfiguration(), this.stubServer.getPort()));
}
public void shutdown() {
if (stubServer != null) {
stubServer.stop();
if (this.stubServer != null) {
this.stubServer.stop();
}
}
@@ -87,11 +87,11 @@ class StubRunnerExecutor implements StubFinder {
public URL findStubUrl(String groupId, String artifactId) {
if (groupId == null) {
return returnStubUrlIfMatches(
artifactId.equals(stubServer.stubConfiguration.artifactId));
artifactId.equals(this.stubServer.stubConfiguration.artifactId));
}
return returnStubUrlIfMatches(
artifactId.equals(stubServer.stubConfiguration.artifactId)
&& groupId.equals(stubServer.stubConfiguration.groupId));
artifactId.equals(this.stubServer.stubConfiguration.artifactId)
&& groupId.equals(this.stubServer.stubConfiguration.groupId));
}
@Override
@@ -105,14 +105,14 @@ class StubRunnerExecutor implements StubFinder {
@Override
public RunningStubs findAllRunningStubs() {
return new RunningStubs(Collections.singletonMap(stubServer.stubConfiguration,
stubServer.getPort()));
return new RunningStubs(Collections.singletonMap(this.stubServer.stubConfiguration,
this.stubServer.getPort()));
}
@Override
public Map<StubConfiguration, Collection<Contract>> getContracts() {
return Collections.singletonMap(stubServer.stubConfiguration,
stubServer.getContracts());
return Collections.singletonMap(this.stubServer.stubConfiguration,
this.stubServer.getContracts());
}
@Override
@@ -185,7 +185,7 @@ class StubRunnerExecutor implements StubFinder {
}
DslProperty<?> body = outputMessage.getBody();
Headers headers = outputMessage.getHeaders();
contractVerifierMessaging.send(
this.contractVerifierMessaging.send(
JsonOutput.toJson(BodyExtractor.extractClientValueFromBody(
body == null ? null : body.getClientValue())),
headers == null ? null : headers.asStubSideMap(),
@@ -193,7 +193,7 @@ class StubRunnerExecutor implements StubFinder {
}
private URL returnStubUrlIfMatches(boolean condition) {
return condition ? stubServer.getStubUrl() : null;
return condition ? this.stubServer.getStubUrl() : null;
}
private void startStubServers(StubRunnerOptions stubRunnerOptions,
@@ -206,7 +206,7 @@ class StubRunnerExecutor implements StubFinder {
if (log.isDebugEnabled()) {
log.debug("There are no HTTP related contracts. Won't start any servers");
}
stubServer = new StubServer(stubConfiguration, mappings, contracts, new NoOpHttpServerStub());
this.stubServer = new StubServer(stubConfiguration, mappings, contracts, new NoOpHttpServerStub());
return;
}
if (contracts.isEmpty()) {
@@ -215,10 +215,10 @@ class StubRunnerExecutor implements StubFinder {
+ "that's why will start the server - maybe you know what you're doing...");
}
if (port != null && port >= 0) {
stubServer = new StubServer(stubConfiguration, mappings, contracts,
this.stubServer = new StubServer(stubConfiguration, mappings, contracts,
new WireMockHttpServerStub(port));
} else {
stubServer = portScanner
this.stubServer = this.portScanner
.tryToExecuteWithFreePort(new PortCallback<StubServer>() {
@Override
public StubServer call(int availablePort) {
@@ -228,7 +228,7 @@ class StubRunnerExecutor implements StubFinder {
}
});
}
stubServer = stubServer.start();
this.stubServer = this.stubServer.start();
}
private boolean hasRequest(Collection<Contract> contracts) {

View File

@@ -55,9 +55,9 @@ class StubRunnerFactory {
+ "them either via annotation or a property");
}
Collection<StubRunner> result = new ArrayList<>();
for (StubConfiguration stubsConfiguration : stubRunnerOptions.getDependencies()) {
Map.Entry<StubConfiguration, File> entry = stubDownloader
.downloadAndUnpackStubJar(stubRunnerOptions, stubsConfiguration);
for (StubConfiguration stubsConfiguration : this.stubRunnerOptions.getDependencies()) {
Map.Entry<StubConfiguration, File> entry = this.stubDownloader
.downloadAndUnpackStubJar(this.stubRunnerOptions, stubsConfiguration);
if (log.isDebugEnabled()) {
log.debug("For stub configuration [" + stubsConfiguration + "] the downloaded entry is [" + entry + "]");
}
@@ -74,13 +74,13 @@ class StubRunnerFactory {
if (unzipedStubDir == null) {
return null;
}
return createStubRunner(unzipedStubDir, stubsConfiguration, stubRunnerOptions);
return createStubRunner(unzipedStubDir, stubsConfiguration, this.stubRunnerOptions);
}
private StubRunner createStubRunner(File unzippedStubsDir,
StubConfiguration stubsConfiguration, StubRunnerOptions stubRunnerOptions) {
return new StubRunner(stubRunnerOptions, unzippedStubsDir.getPath(),
stubsConfiguration, contractVerifierMessaging);
stubsConfiguration, this.contractVerifierMessaging);
}
}

View File

@@ -93,11 +93,11 @@ public class StubRunnerMain {
private void execute() {
try {
if (log.isDebugEnabled()) {
log.debug("Launching StubRunner with args: " + arguments);
log.debug("Launching StubRunner with args: " + this.arguments);
}
// TODO: Pass StubsToRun either from String or File
BatchStubRunner stubRunner = new BatchStubRunnerFactory(
arguments.getStubRunnerOptions()).buildBatchStubRunner();
this.arguments.getStubRunnerOptions()).buildBatchStubRunner();
RunningStubs runningCollaborators = stubRunner.runStubs();
log.info(runningCollaborators.toString());
}

View File

@@ -75,48 +75,48 @@ public class StubRunnerOptions {
}
public Integer port(StubConfiguration stubConfiguration) {
if (stubIdsToPortMapping!=null) {
return stubIdsToPortMapping.get(stubConfiguration);
if (this.stubIdsToPortMapping!=null) {
return this.stubIdsToPortMapping.get(stubConfiguration);
} else {
return null;
}
}
public Integer getMinPortValue() {
return minPortValue;
return this.minPortValue;
}
public Integer getMaxPortValue() {
return maxPortValue;
return this.maxPortValue;
}
public String getStubRepositoryRoot() {
return stubRepositoryRoot;
return this.stubRepositoryRoot;
}
public boolean isWorkOffline() {
return workOffline;
return this.workOffline;
}
public String getStubsClassifier() {
return stubsClassifier;
return this.stubsClassifier;
}
public Collection<StubConfiguration> getDependencies() {
return dependencies;
return this.dependencies;
}
public Map<StubConfiguration, Integer> getStubIdsToPortMapping() {
return stubIdsToPortMapping;
return this.stubIdsToPortMapping;
}
@Override
public String toString() {
return "StubRunnerOptions [minPortValue=" + minPortValue + ", maxPortValue="
+ maxPortValue + ", stubRepositoryRoot=" + stubRepositoryRoot
+ ", workOffline=" + workOffline + ", stubsClassifier=" + stubsClassifier
+ ", dependencies=" + dependencies + ", stubIdsToPortMapping="
+ stubIdsToPortMapping + "]";
return "StubRunnerOptions [minPortValue=" + this.minPortValue + ", maxPortValue="
+ this.maxPortValue + ", stubRepositoryRoot=" + this.stubRepositoryRoot
+ ", workOffline=" + this.workOffline + ", stubsClassifier=" + this.stubsClassifier
+ ", dependencies=" + this.dependencies + ", stubIdsToPortMapping="
+ this.stubIdsToPortMapping + "]";
}
}

View File

@@ -90,7 +90,7 @@ public class StubRunnerOptionsBuilder {
}
public StubRunnerOptionsBuilder withPort(Integer port) {
String lastStub = stubs.peekLast();
String lastStub = this.stubs.peekLast();
addPort(lastStub + DELIMITER + port);
return this;
}
@@ -105,12 +105,12 @@ public class StubRunnerOptionsBuilder {
}
public StubRunnerOptions build() {
return new StubRunnerOptions(minPortValue, maxPortValue, stubRepositoryRoot,
workOffline, stubsClassifier, buildDependencies(), stubIdsToPortMapping);
return new StubRunnerOptions(this.minPortValue, this.maxPortValue, this.stubRepositoryRoot,
this.workOffline, this.stubsClassifier, buildDependencies(), this.stubIdsToPortMapping);
}
private Collection<StubConfiguration> buildDependencies() {
return StubsParser.fromString(stubs, stubsClassifier);
return StubsParser.fromString(this.stubs, this.stubsClassifier);
}
private static List<String> stubsToList(String[] stubIdsToPortMapping) {
@@ -130,10 +130,10 @@ public class StubRunnerOptionsBuilder {
private void addStub(String notation) {
if (StubsParser.hasPort(notation)) {
addPort(notation);
stubs.add(StubsParser.ivyFromStringWithPort(notation));
this.stubs.add(StubsParser.ivyFromStringWithPort(notation));
}
else {
stubs.add(notation);
this.stubs.add(notation);
}
}

View File

@@ -45,8 +45,8 @@ class StubServer {
public StubServer start() {
this.httpServerStub.start();
log.info("Started stub server for project [" + stubConfiguration.toColonSeparatedDependencyNotation() +
"] on port " + httpServerStub.port());
log.info("Started stub server for project [" + this.stubConfiguration.toColonSeparatedDependencyNotation() +
"] on port " + this.httpServerStub.port());
registerStubMappings();
return this;
}
@@ -56,8 +56,8 @@ class StubServer {
}
public int getPort() {
if (httpServerStub.isRunning()) {
return httpServerStub.port();
if (this.httpServerStub.isRunning()) {
return this.httpServerStub.port();
}
if (log.isDebugEnabled()) {
log.debug("The HTTP Server stub is not running... That means that the " +
@@ -76,17 +76,17 @@ class StubServer {
}
public StubConfiguration getStubConfiguration() {
return stubConfiguration;
return this.stubConfiguration;
}
public Collection<Contract> getContracts() {
return contracts;
return this.contracts;
}
private void registerStubMappings() {
WireMock wireMock = new WireMock("localhost", httpServerStub.port());
WireMock wireMock = new WireMock("localhost", this.httpServerStub.port());
registerDefaultHealthChecks(wireMock);
registerStubs(mappings, wireMock);
registerStubs(this.mappings, wireMock);
}
private void registerDefaultHealthChecks(WireMock wireMock) {

View File

@@ -40,7 +40,7 @@ class WiremockMappingDescriptor {
public StubMapping getMapping() {
try {
return StubMapping.buildFrom(StreamUtils.copyToString(
new FileInputStream(descriptor), Charset.forName("UTF-8")));
new FileInputStream(this.descriptor), Charset.forName("UTF-8")));
}
catch (IOException e) {
throw new IllegalStateException("Cannot read file", e);
@@ -49,14 +49,14 @@ class WiremockMappingDescriptor {
@Override
public String toString() {
return "WiremockMappingDescriptor [descriptor=" + descriptor + "]";
return "WiremockMappingDescriptor [descriptor=" + this.descriptor + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((descriptor == null) ? 0 : descriptor.hashCode());
result = prime * result + ((this.descriptor == null) ? 0 : this.descriptor.hashCode());
return result;
}
@@ -69,11 +69,11 @@ class WiremockMappingDescriptor {
if (getClass() != obj.getClass())
return false;
WiremockMappingDescriptor other = (WiremockMappingDescriptor) obj;
if (descriptor == null) {
if (this.descriptor == null) {
if (other.descriptor != null)
return false;
}
else if (!descriptor.equals(other.descriptor))
else if (!this.descriptor.equals(other.descriptor))
return false;
return true;
}

View File

@@ -25,6 +25,7 @@ import java.util.Map;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.springframework.cloud.contract.spec.Contract;
import org.springframework.cloud.contract.stubrunner.BatchStubRunner;
import org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory;
import org.springframework.cloud.contract.stubrunner.RunningStubs;
@@ -32,7 +33,6 @@ import org.springframework.cloud.contract.stubrunner.StubConfiguration;
import org.springframework.cloud.contract.stubrunner.StubFinder;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptionsBuilder;
import org.springframework.cloud.contract.spec.Contract;
/**
* JUnit class rule that allows you to download the provided stubs.
@@ -53,12 +53,13 @@ public class StubRunnerRule implements TestRule, StubFinder {
public void evaluate() throws Throwable {
before();
base.evaluate();
stubFinder.close();
StubRunnerRule.this.stubFinder.close();
}
private void before() {
stubFinder = new BatchStubRunnerFactory(stubRunnerOptionsBuilder.build()).buildBatchStubRunner();
stubFinder.runStubs();
StubRunnerRule.this.stubFinder = new BatchStubRunnerFactory(
StubRunnerRule.this.stubRunnerOptionsBuilder.build()).buildBatchStubRunner();
StubRunnerRule.this.stubFinder.runStubs();
}
};
}
@@ -80,7 +81,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* @see StubRunnerOptions
*/
public StubRunnerRule options(StubRunnerOptions stubRunnerOptions) {
stubRunnerOptionsBuilder.withOptions(stubRunnerOptions);
this.stubRunnerOptionsBuilder.withOptions(stubRunnerOptions);
return this;
}
@@ -88,7 +89,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Min value of port for WireMock server
*/
public StubRunnerRule minPort(int minPort) {
stubRunnerOptionsBuilder.withMinPort(minPort);
this.stubRunnerOptionsBuilder.withMinPort(minPort);
return this;
}
@@ -96,7 +97,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Max value of port for WireMock server
*/
public StubRunnerRule maxPort(int maxPort) {
stubRunnerOptionsBuilder.withMaxPort(maxPort);
this.stubRunnerOptionsBuilder.withMaxPort(maxPort);
return this;
}
@@ -104,7 +105,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* String URI of repository containing stubs
*/
public StubRunnerRule repoRoot(String repoRoot) {
stubRunnerOptionsBuilder.withStubRepositoryRoot(repoRoot);
this.stubRunnerOptionsBuilder.withStubRepositoryRoot(repoRoot);
return this;
}
@@ -112,7 +113,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Should download stubs or use only the local repository
*/
public StubRunnerRule workOffline(boolean workOffline) {
stubRunnerOptionsBuilder.withWorkOffline(workOffline);
this.stubRunnerOptionsBuilder.withWorkOffline(workOffline);
return this;
}
@@ -120,7 +121,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Group Id, artifact Id, version and classifier of a single stub to download
*/
public StubRunnerRule downloadStub(String groupId, String artifactId, String version, String classifier) {
stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId + DELIMITER + version + DELIMITER + classifier);
this.stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId + DELIMITER + version + DELIMITER + classifier);
return this;
}
@@ -128,7 +129,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Group Id, artifact Id and classifier of a single stub to download in the latest version
*/
public StubRunnerRule downloadLatestStub(String groupId, String artifactId, String classifier) {
stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId + DELIMITER + LATEST_VERSION + DELIMITER + classifier);
this.stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId + DELIMITER + LATEST_VERSION + DELIMITER + classifier);
return this;
}
@@ -136,7 +137,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Group Id, artifact Id and version of a single stub to download
*/
public StubRunnerRule downloadStub(String groupId, String artifactId, String version) {
stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId + DELIMITER + version);
this.stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId + DELIMITER + version);
return this;
}
@@ -144,7 +145,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Group Id, artifact Id of a single stub to download. Default classifier will be picked.
*/
public StubRunnerRule downloadStub(String groupId, String artifactId) {
stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId);
this.stubRunnerOptionsBuilder.withStubs(groupId + DELIMITER + artifactId);
return this;
}
@@ -152,7 +153,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Ivy notation of a single stub to download.
*/
public StubRunnerRule downloadStub(String ivyNotation) {
stubRunnerOptionsBuilder.withStubs(ivyNotation);
this.stubRunnerOptionsBuilder.withStubs(ivyNotation);
return this;
}
@@ -160,7 +161,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Stubs to download in Ivy notations
*/
public StubRunnerRule downloadStubs(String... ivyNotations) {
stubRunnerOptionsBuilder.withStubs(Arrays.asList(ivyNotations));
this.stubRunnerOptionsBuilder.withStubs(Arrays.asList(ivyNotations));
return this;
}
@@ -168,7 +169,7 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Stubs to download in Ivy notations
*/
public StubRunnerRule downloadStubs(List<String> ivyNotations) {
stubRunnerOptionsBuilder.withStubs(ivyNotations);
this.stubRunnerOptionsBuilder.withStubs(ivyNotations);
return this;
}
@@ -176,48 +177,48 @@ public class StubRunnerRule implements TestRule, StubFinder {
* Appends port to last added stub
*/
public StubRunnerRule withPort(Integer port) {
stubRunnerOptionsBuilder.withPort(port);
this.stubRunnerOptionsBuilder.withPort(port);
return this;
}
@Override
public URL findStubUrl(String groupId, String artifactId) {
return stubFinder.findStubUrl(groupId, artifactId);
return this.stubFinder.findStubUrl(groupId, artifactId);
}
@Override
public URL findStubUrl(String ivyNotation) {
return stubFinder.findStubUrl(ivyNotation);
return this.stubFinder.findStubUrl(ivyNotation);
}
@Override
public RunningStubs findAllRunningStubs() {
return stubFinder.findAllRunningStubs();
return this.stubFinder.findAllRunningStubs();
}
@Override
public Map<StubConfiguration, Collection<Contract>> getContracts() {
return stubFinder.getContracts();
return this.stubFinder.getContracts();
}
@Override
public boolean trigger(String ivyNotation, String labelName) {
return stubFinder.trigger(ivyNotation, labelName);
return this.stubFinder.trigger(ivyNotation, labelName);
}
@Override
public boolean trigger(String labelName) {
return stubFinder.trigger(labelName);
return this.stubFinder.trigger(labelName);
}
@Override
public boolean trigger() {
return stubFinder.trigger();
return this.stubFinder.trigger();
}
@Override
public Map<String, Collection<String>> labels() {
return stubFinder.labels();
return this.stubFinder.labels();
}
}

View File

@@ -56,11 +56,11 @@ class StubRunnerCamelPredicate implements Predicate {
Object inputMessage = exchange.getIn().getBody();
JsonPaths jsonPaths = JsonToJsonPathsConverter
.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(
groovyDsl.getInput().getMessageBody());
this.groovyDsl.getInput().getMessageBody());
DocumentContext parsedJson;
try {
parsedJson = JsonPath
.parse(objectMapper.writeValueAsString(inputMessage));
.parse(this.objectMapper.writeValueAsString(inputMessage));
}
catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot serialize to JSON", e);
@@ -84,7 +84,7 @@ class StubRunnerCamelPredicate implements Predicate {
private boolean headersMatch(Exchange exchange) {
Map<String, Object> headers = exchange.getIn().getHeaders();
boolean matches = true;
for (Header it : groovyDsl.getInput().getMessageHeaders().getEntries()) {
for (Header it : this.groovyDsl.getInput().getMessageHeaders().getEntries()) {
String name = it.getName();
Object value = it.getClientValue();
Object valueInHeader = headers.get(name);

View File

@@ -40,18 +40,18 @@ class StubRunnerCamelProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message input = exchange.getIn();
if (groovyDsl.getInput().getMessageHeaders() != null) {
for (Header entry : groovyDsl.getInput().getMessageHeaders().getEntries()) {
if (this.groovyDsl.getInput().getMessageHeaders() != null) {
for (Header entry : this.groovyDsl.getInput().getMessageHeaders().getEntries()) {
input.removeHeader(entry.getName());
}
}
if (groovyDsl.getOutputMessage() == null) {
if (this.groovyDsl.getOutputMessage() == null) {
return;
}
input.setBody(BodyExtractor
.extractStubValueFrom(groovyDsl.getOutputMessage().getBody()));
if (groovyDsl.getOutputMessage().getHeaders() != null) {
for (Header entry : groovyDsl.getOutputMessage().getHeaders().getEntries()) {
.extractStubValueFrom(this.groovyDsl.getOutputMessage().getBody()));
if (this.groovyDsl.getOutputMessage().getHeaders() != null) {
for (Header entry : this.groovyDsl.getOutputMessage().getHeaders().getEntries()) {
input.setHeader(entry.getName(), entry.getClientValue());
}
}

View File

@@ -56,10 +56,10 @@ class StubRunnerIntegrationMessageSelector implements MessageSelector {
Object inputMessage = message.getPayload();
JsonPaths jsonPaths = JsonToJsonPathsConverter
.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(
groovyDsl.getInput().getMessageBody());
this.groovyDsl.getInput().getMessageBody());
DocumentContext parsedJson;
try {
parsedJson = JsonPath.parse(objectMapper.writeValueAsString(inputMessage));
parsedJson = JsonPath.parse(this.objectMapper.writeValueAsString(inputMessage));
}
catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot serialize to JSON", e);
@@ -86,7 +86,7 @@ class StubRunnerIntegrationMessageSelector implements MessageSelector {
private boolean headersMatch(Message<?> message) {
Map<String, Object> headers = message.getHeaders();
boolean matches = true;
for (Header it : groovyDsl.getInput().getMessageHeaders().getEntries()) {
for (Header it : this.groovyDsl.getInput().getMessageHeaders().getEntries()) {
String name = it.getName();
Object value = it.getClientValue();
Object valueInHeader = headers.get(name);

View File

@@ -40,11 +40,11 @@ class StubRunnerIntegrationTransformer implements GenericTransformer<Message<?>,
@Override
public Message<?> transform(Message<?> source) {
if (groovyDsl.getOutputMessage()==null) {
if (this.groovyDsl.getOutputMessage()==null) {
return source;
}
String payload = BodyExtractor.extractStubValueFrom(groovyDsl.getOutputMessage().getBody());
Map<String, Object> headers = groovyDsl.getOutputMessage().getHeaders().asStubSideMap();
String payload = BodyExtractor.extractStubValueFrom(this.groovyDsl.getOutputMessage().getBody());
Map<String, Object> headers = this.groovyDsl.getOutputMessage().getHeaders().asStubSideMap();
return MessageBuilder.createMessage(payload, new MessageHeaders(headers));
}
}

View File

@@ -56,10 +56,10 @@ class StubRunnerStreamMessageSelector implements MessageSelector {
Object inputMessage = message.getPayload();
JsonPaths jsonPaths = JsonToJsonPathsConverter
.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(
groovyDsl.getInput().getMessageBody());
this.groovyDsl.getInput().getMessageBody());
DocumentContext parsedJson;
try {
parsedJson = JsonPath.parse(objectMapper.writeValueAsString(inputMessage));
parsedJson = JsonPath.parse(this.objectMapper.writeValueAsString(inputMessage));
for (MethodBufferingJsonVerifiable it : jsonPaths) {
if (!matchesJsonPath(parsedJson, it)) {
return false;
@@ -83,7 +83,7 @@ class StubRunnerStreamMessageSelector implements MessageSelector {
private boolean headersMatch(Message<?> message) {
Map<String, Object> headers = message.getHeaders();
for (Header it : groovyDsl.getInput().getMessageHeaders().getEntries()) {
for (Header it : this.groovyDsl.getInput().getMessageHeaders().getEntries()) {
String name = it.getName();
Object value = it.getClientValue();
Object valueInHeader = headers.get(name);

View File

@@ -40,11 +40,11 @@ class StubRunnerStreamTransformer implements GenericTransformer<Message<?>, Mess
@Override
public Message<?> transform(Message<?> source) {
if (groovyDsl.getOutputMessage()==null) {
if (this.groovyDsl.getOutputMessage()==null) {
return source;
}
String payload = BodyExtractor.extractStubValueFrom(groovyDsl.getOutputMessage().getBody());
Map<String, Object> headers = groovyDsl.getOutputMessage().getHeaders().asStubSideMap();
String payload = BodyExtractor.extractStubValueFrom(this.groovyDsl.getOutputMessage().getBody());
Map<String, Object> headers = this.groovyDsl.getOutputMessage().getHeaders().asStubSideMap();
return MessageBuilder.createMessage(payload, new MessageHeaders(headers));
}
}

View File

@@ -43,12 +43,12 @@ public class HttpStubsController {
@RequestMapping
public Map<String, Integer> stubs() {
return stubRunning.runStubs().toIvyToPortMapping();
return this.stubRunning.runStubs().toIvyToPortMapping();
}
@RequestMapping(path = "/{ivy:.*}")
public ResponseEntity<Integer> consumer(@PathVariable String ivy) {
Integer port = stubRunning.runStubs().getPort(ivy);
Integer port = this.stubRunning.runStubs().getPort(ivy);
if (port!=null) {
return ResponseEntity.ok(port);
}

View File

@@ -52,32 +52,32 @@ public class TriggerController {
@PostMapping("/{label:.*}")
public ResponseEntity<Map<String, Collection<String>>> trigger(@PathVariable String label) {
try {
stubFinder.trigger(label);
this.stubFinder.trigger(label);
return ResponseEntity.ok().body(Collections.<String, Collection<String>>emptyMap());
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Exception occurred while trying to return " + label + " label", e);
}
return new ResponseEntity<>(stubFinder.labels(), HttpStatus.NOT_FOUND);
return new ResponseEntity<>(this.stubFinder.labels(), HttpStatus.NOT_FOUND);
}
}
@PostMapping("/{ivyNotation:.*}/{label:.*}")
public ResponseEntity<Map<String, Collection<String>>> triggerByArtifact(@PathVariable String ivyNotation, @PathVariable String label) {
try {
stubFinder.trigger(ivyNotation, label);
this.stubFinder.trigger(ivyNotation, label);
return ResponseEntity.ok().body(Collections.<String, Collection<String>>emptyMap());
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Exception occurred while trying to return " + label + " label", e);
}
return new ResponseEntity<>(stubFinder.labels(), HttpStatus.NOT_FOUND);
return new ResponseEntity<>(this.stubFinder.labels(), HttpStatus.NOT_FOUND);
}
}
@GetMapping
public Map<String, Collection<String>> labels() {
return stubFinder.labels();
return this.stubFinder.labels();
}
}

View File

@@ -25,7 +25,6 @@ import org.springframework.cloud.contract.stubrunner.AetherStubDownloader;
import org.springframework.cloud.contract.stubrunner.BatchStubRunner;
import org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory;
import org.springframework.cloud.contract.stubrunner.StubDownloader;
import org.springframework.cloud.contract.stubrunner.StubRunner;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptionsBuilder;
import org.springframework.cloud.contract.verifier.messaging.MessageVerifier;
@@ -35,8 +34,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
/**
* Configuration that initializes a {@link BatchStubRunner} that runs {@link StubRunner}
* instance for each stub
* Configuration that initializes a {@link BatchStubRunner} that runs
* {@link org.springframework.cloud.contract.stubrunner.StubRunner} instance for each stub
*/
@Configuration
@EnableConfigurationProperties(StubRunnerProperties.class)
@@ -58,17 +57,17 @@ public class StubRunnerConfiguration {
@Bean
public BatchStubRunner batchStubRunner() throws IOException {
StubRunnerOptions stubRunnerOptions = new StubRunnerOptionsBuilder()
.withMinMaxPort(props.getMinPort(), props.getMaxPort())
.withMinMaxPort(this.props.getMinPort(), this.props.getMaxPort())
.withStubRepositoryRoot(
uriStringOrEmpty(props.getRepositoryRoot()))
.withWorkOffline(props.getRepositoryRoot() == null
|| props.isWorkOffline())
.withStubsClassifier(props.getClassifier())
.withStubs(props.getIds()).build();
uriStringOrEmpty(this.props.getRepositoryRoot()))
.withWorkOffline(this.props.getRepositoryRoot() == null
|| this.props.isWorkOffline())
.withStubsClassifier(this.props.getClassifier())
.withStubs(this.props.getIds()).build();
BatchStubRunner batchStubRunner = new BatchStubRunnerFactory(stubRunnerOptions,
stubDownloader != null ? stubDownloader
this.stubDownloader != null ? this.stubDownloader
: new AetherStubDownloader(stubRunnerOptions),
contractVerifierMessaging != null ? contractVerifierMessaging
this.contractVerifierMessaging != null ? this.contractVerifierMessaging
: new NoOpStubMessages()).buildBatchStubRunner();
// TODO: Consider running it in a separate thread
batchStubRunner.runStubs();

View File

@@ -60,7 +60,7 @@ public class StubRunnerProperties {
private String classifier = "stubs";
public int getMinPort() {
return minPort;
return this.minPort;
}
public void setMinPort(int minPort) {
@@ -68,7 +68,7 @@ public class StubRunnerProperties {
}
public int getMaxPort() {
return maxPort;
return this.maxPort;
}
public void setMaxPort(int maxPort) {
@@ -76,7 +76,7 @@ public class StubRunnerProperties {
}
public boolean isWorkOffline() {
return workOffline;
return this.workOffline;
}
public void setWorkOffline(boolean workOffline) {
@@ -84,7 +84,7 @@ public class StubRunnerProperties {
}
public Resource getRepositoryRoot() {
return repositoryRoot;
return this.repositoryRoot;
}
public void setRepositoryRoot(String repositoryRoot) {
@@ -92,7 +92,7 @@ public class StubRunnerProperties {
}
public String[] getIds() {
return ids;
return this.ids;
}
public void setIds(String[] ids) {
@@ -100,7 +100,7 @@ public class StubRunnerProperties {
}
public String getClassifier() {
return classifier;
return this.classifier;
}
public void setClassifier(String classifier) {
@@ -108,9 +108,9 @@ public class StubRunnerProperties {
}
@Override public String toString() {
return "StubRunnerProperties{" + "minPort=" + minPort + ", maxPort=" + maxPort
+ ", workOffline=" + workOffline + ", repositoryRoot=" + repositoryRoot
+ ", ids=" + Arrays.toString(ids) + ", classifier='" + classifier + '\''
return "StubRunnerProperties{" + "minPort=" + this.minPort + ", maxPort=" + this.maxPort
+ ", workOffline=" + this.workOffline + ", repositoryRoot=" + this.repositoryRoot
+ ", ids=" + Arrays.toString(this.ids) + ", classifier='" + this.classifier + '\''
+ '}';
}
}

View File

@@ -61,20 +61,20 @@ public class StubMapperProperties {
public String fromIvyNotationToId(String ivyNotation) {
StubConfiguration stubConfiguration = new StubConfiguration(ivyNotation);
String id = idsToServiceIds.get(ivyNotation);
String id = this.idsToServiceIds.get(ivyNotation);
if (StringUtils.hasText(id)) {
return id;
}
String groupAndArtifact = idsToServiceIds.get(stubConfiguration.getGroupId() +
String groupAndArtifact = this.idsToServiceIds.get(stubConfiguration.getGroupId() +
":" + stubConfiguration.getArtifactId());
if (StringUtils.hasText(groupAndArtifact)) {
return groupAndArtifact;
}
return idsToServiceIds.get(stubConfiguration.getArtifactId());
return this.idsToServiceIds.get(stubConfiguration.getArtifactId());
}
public String fromServiceIdToIvyNotation(String serviceId) {
for (Map.Entry<String, String> entry : idsToServiceIds.entrySet()) {
for (Map.Entry<String, String> entry : this.idsToServiceIds.entrySet()) {
if (entry.getValue().equals(serviceId)) {
return entry.getKey();
}

View File

@@ -100,9 +100,9 @@ class StubRunnerDiscoveryClient implements DiscoveryClient {
@Override
public List<ServiceInstance> getInstances(String serviceId) {
String ivyNotation = stubMapperProperties.fromServiceIdToIvyNotation(serviceId);
String ivyNotation = this.stubMapperProperties.fromServiceIdToIvyNotation(serviceId);
String serviceToFind = StringUtils.hasText(ivyNotation) ? ivyNotation : serviceId;
URL stubUrl = stubFinder.findStubUrl(serviceToFind);
URL stubUrl = this.stubFinder.findStubUrl(serviceToFind);
log.info("Resolved from ivy [" + ivyNotation + "] service to find [" + serviceToFind + "]. "
+ "Found stub is available under URL [" + stubUrl + "]");
if (stubUrl == null) {

View File

@@ -45,17 +45,17 @@ class StubRunnerServiceInstance implements ServiceInstance {
@Override
public String getServiceId() {
return serviceId;
return this.serviceId;
}
@Override
public String getHost() {
return host;
return this.host;
}
@Override
public int getPort() {
return port;
return this.port;
}
@Override
@@ -65,7 +65,7 @@ class StubRunnerServiceInstance implements ServiceInstance {
@Override
public URI getUri() {
return uri;
return this.uri;
}
@Override

View File

@@ -16,10 +16,10 @@ public class ApplicationStatus {
}
public Application getApplication() {
return application;
return this.application;
}
public InstanceInfo.InstanceStatus getStatus() {
return status;
return this.status;
}
}

View File

@@ -85,7 +85,7 @@ public class Eureka {
}
public InstanceInfo getInstanceInfo(Application application) {
EurekaInstanceConfigBean instanceConfig = new EurekaInstanceConfigBean(inetUtils);
EurekaInstanceConfigBean instanceConfig = new EurekaInstanceConfigBean(this.inetUtils);
instanceConfig.setInstanceEnabledOnit(true);
instanceConfig.setAppname(application.getName());
instanceConfig.setVirtualHostName(application.getName());
@@ -97,11 +97,11 @@ public class Eureka {
}
public EurekaTransport createTransport() {
TransportClientFactory transportClientFactory = newTransportClientFactory(clientConfig, Collections.<ClientFilter>emptyList());
EurekaTransportConfig transportConfig = clientConfig.getTransportConfig();
TransportClientFactory transportClientFactory = newTransportClientFactory(this.clientConfig, Collections.<ClientFilter>emptyList());
EurekaTransportConfig transportConfig = this.clientConfig.getTransportConfig();
ClosableResolver<AwsEndpoint> bootstrapResolver = EurekaHttpClients.newBootstrapResolver(
clientConfig,
this.clientConfig,
transportConfig,
transportClientFactory,
null,
@@ -109,13 +109,13 @@ public class Eureka {
@Override
public Applications getApplications(int stalenessThreshold, TimeUnit timeUnit) {
long thresholdInMs = TimeUnit.MILLISECONDS.convert(stalenessThreshold, timeUnit);
long delay = eurekaClient.getLastSuccessfulRegistryFetchTimePeriod();
long delay = Eureka.this.eurekaClient.getLastSuccessfulRegistryFetchTimePeriod();
if (delay > thresholdInMs) {
log.info(String.format("Local registry is too stale for local lookup. Threshold:%s, actual:%s",
thresholdInMs, delay));
return null;
} else {
return eurekaClient.getApplications();
return Eureka.this.eurekaClient.getApplications();
}
}
}
@@ -234,26 +234,26 @@ class EurekaTransport {
}
public void shutdown() {
eurekaHttpClientFactory.shutdown();
eurekaHttpClient.shutdown();
transportClientFactory.shutdown();
closableResolver.shutdown();
this.eurekaHttpClientFactory.shutdown();
this.eurekaHttpClient.shutdown();
this.transportClientFactory.shutdown();
this.closableResolver.shutdown();
}
public EurekaHttpClientFactory getEurekaHttpClientFactory() {
return eurekaHttpClientFactory;
return this.eurekaHttpClientFactory;
}
public EurekaHttpClient getEurekaHttpClient() {
return eurekaHttpClient;
return this.eurekaHttpClient;
}
public TransportClientFactory getTransportClientFactory() {
return transportClientFactory;
return this.transportClientFactory;
}
public ClosableResolver getClosableResolver() {
return closableResolver;
return this.closableResolver;
}
}
@@ -282,7 +282,7 @@ class Application {
@JsonIgnore
public String getRegistrationKey() {
return computeRegistrationKey(this.name, instance_id);
return computeRegistrationKey(this.name, this.instance_id);
}
static String computeRegistrationKey(String name, String instanceId) {
@@ -290,19 +290,19 @@ class Application {
}
public String getName() {
return name;
return this.name;
}
public String getInstance_id() {
return instance_id;
return this.instance_id;
}
public String getHostname() {
return hostname;
return this.hostname;
}
public int getPort() {
return port;
return this.port;
}
}

View File

@@ -31,15 +31,15 @@ public class Registration {
}
public InstanceInfo getInstanceInfo() {
return instanceInfo;
return this.instanceInfo;
}
public ApplicationStatus getApplicationStatus() {
return applicationStatus;
return this.applicationStatus;
}
@Override public String toString() {
return "Registration{" + "instanceInfo=" + instanceInfo + ", applicationStatus="
+ applicationStatus + '}';
return "Registration{" + "instanceInfo=" + this.instanceInfo + ", applicationStatus="
+ this.applicationStatus + '}';
}
}

View File

@@ -16,13 +16,14 @@
package org.springframework.cloud.contract.stubrunner.spring.cloud.ribbon;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.ServerList;
import org.springframework.cloud.contract.stubrunner.StubFinder;
import org.springframework.cloud.contract.stubrunner.spring.cloud.StubMapperProperties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.cloud.contract.stubrunner.StubFinder;
import org.springframework.cloud.contract.stubrunner.spring.cloud.StubMapperProperties;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.ServerList;
/**
* Ribbon AutoConfiguration that manipulates the service id to make the service
@@ -44,24 +45,24 @@ class StubRunnerRibbonBeanPostProcessor implements BeanPostProcessor {
}
private StubFinder stubFinder() {
if (stubFinder == null) {
stubFinder = this.beanFactory.getBean(StubFinder.class);
if (this.stubFinder == null) {
this.stubFinder = this.beanFactory.getBean(StubFinder.class);
}
return stubFinder;
return this.stubFinder;
}
private StubMapperProperties stubMapperProperties() {
if (stubMapperProperties == null) {
stubMapperProperties = this.beanFactory.getBean(StubMapperProperties.class);
if (this.stubMapperProperties == null) {
this.stubMapperProperties = this.beanFactory.getBean(StubMapperProperties.class);
}
return stubMapperProperties;
return this.stubMapperProperties;
}
private IClientConfig clientConfig() {
if (clientConfig == null) {
clientConfig = this.beanFactory.getBean(IClientConfig.class);
if (this.clientConfig == null) {
this.clientConfig = this.beanFactory.getBean(IClientConfig.class);
}
return clientConfig;
return this.clientConfig;
}
@Override

View File

@@ -85,7 +85,7 @@ class StubRunnerRibbonServerList implements ServerList<Server> {
}
});
}
serverList = new ServerList<Server>() {
this.serverList = new ServerList<Server>() {
@Override
public List<Server> getInitialListOfServers() {
List<Server> combinedList = new ArrayList<>();
@@ -118,11 +118,11 @@ class StubRunnerRibbonServerList implements ServerList<Server> {
@Override
public List<Server> getInitialListOfServers() {
return serverList.getInitialListOfServers();
return this.serverList.getInitialListOfServers();
}
@Override
public List<Server> getUpdatedListOfServers() {
return serverList.getUpdatedListOfServers();
return this.serverList.getUpdatedListOfServers();
}
}

View File

@@ -91,7 +91,7 @@ public class StubsParser {
}
public boolean hasPort() {
return port != null;
return this.port != null;
}
private static StubSpecification parse(String id, String defaultClassifier) {

View File

@@ -4,7 +4,7 @@ public class Tweet {
private String text;
public String getText() {
return text;
return this.text;
}
public void setText(String text) {

View File

@@ -12,7 +12,7 @@ public class FraudCheck {
}
public String getClientPesel() {
return clientPesel;
return this.clientPesel;
}
public void setClientPesel(String clientPesel) {
@@ -20,7 +20,7 @@ public class FraudCheck {
}
public BigDecimal getLoanAmount() {
return loanAmount;
return this.loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {

View File

@@ -15,7 +15,7 @@ public class FraudCheckResult {
}
public FraudCheckStatus getFraudCheckStatus() {
return fraudCheckStatus;
return this.fraudCheckStatus;
}
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
@@ -23,7 +23,7 @@ public class FraudCheckResult {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -59,7 +59,7 @@ public class LoanApplicationService {
httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1);
ResponseEntity<FraudServiceResponse> response =
restTemplate.exchange("http://localhost:" + port + "/fraudcheck", HttpMethod.PUT,
this.restTemplate.exchange("http://localhost:" + this.port + "/fraudcheck", HttpMethod.PUT,
new HttpEntity<>(request, httpHeaders),
FraudServiceResponse.class);

View File

@@ -21,7 +21,7 @@ public class Client {
private String pesel;
public String getPesel() {
return pesel;
return this.pesel;
}
public void setPesel(String pesel) {

View File

@@ -33,7 +33,7 @@ public class FraudServiceRequest {
}
public String getClientPesel() {
return clientPesel;
return this.clientPesel;
}
public void setClientPesel(String clientPesel) {
@@ -41,7 +41,7 @@ public class FraudServiceRequest {
}
public BigDecimal getLoanAmount() {
return loanAmount;
return this.loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {

View File

@@ -26,7 +26,7 @@ public class FraudServiceResponse {
}
public FraudCheckStatus getFraudCheckStatus() {
return fraudCheckStatus;
return this.fraudCheckStatus;
}
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
@@ -34,7 +34,7 @@ public class FraudServiceResponse {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -27,7 +27,7 @@ public class LoanApplication {
private String loanApplicationId;
public Client getClient() {
return client;
return this.client;
}
public void setClient(Client client) {
@@ -35,7 +35,7 @@ public class LoanApplication {
}
public BigDecimal getAmount() {
return amount;
return this.amount;
}
public void setAmount(BigDecimal amount) {
@@ -43,7 +43,7 @@ public class LoanApplication {
}
public String getLoanApplicationId() {
return loanApplicationId;
return this.loanApplicationId;
}
public void setLoanApplicationId(String loanApplicationId) {

View File

@@ -31,7 +31,7 @@ public class LoanApplicationResult {
}
public LoanApplicationStatus getLoanApplicationStatus() {
return loanApplicationStatus;
return this.loanApplicationStatus;
}
public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) {
@@ -39,7 +39,7 @@ public class LoanApplicationResult {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -12,7 +12,7 @@ public class FraudCheck {
}
public String getClientPesel() {
return clientPesel;
return this.clientPesel;
}
public void setClientPesel(String clientPesel) {
@@ -20,7 +20,7 @@ public class FraudCheck {
}
public BigDecimal getLoanAmount() {
return loanAmount;
return this.loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {

View File

@@ -15,7 +15,7 @@ public class FraudCheckResult {
}
public FraudCheckStatus getFraudCheckStatus() {
return fraudCheckStatus;
return this.fraudCheckStatus;
}
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
@@ -23,7 +23,7 @@ public class FraudCheckResult {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -43,7 +43,7 @@ public class LoanApplicationService {
httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1);
ResponseEntity<FraudServiceResponse> response =
restTemplate.exchange("http://localhost:" + port + "/fraudcheck", HttpMethod.PUT,
this.restTemplate.exchange("http://localhost:" + this.port + "/fraudcheck", HttpMethod.PUT,
new HttpEntity<>(request, httpHeaders),
FraudServiceResponse.class);

View File

@@ -5,7 +5,7 @@ public class Client {
private String pesel;
public String getPesel() {
return pesel;
return this.pesel;
}
public void setPesel(String pesel) {

View File

@@ -17,7 +17,7 @@ public class FraudServiceRequest {
}
public String getClientPesel() {
return clientPesel;
return this.clientPesel;
}
public void setClientPesel(String clientPesel) {
@@ -25,7 +25,7 @@ public class FraudServiceRequest {
}
public BigDecimal getLoanAmount() {
return loanAmount;
return this.loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {

View File

@@ -10,7 +10,7 @@ public class FraudServiceResponse {
}
public FraudCheckStatus getFraudCheckStatus() {
return fraudCheckStatus;
return this.fraudCheckStatus;
}
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
@@ -18,7 +18,7 @@ public class FraudServiceResponse {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -11,7 +11,7 @@ public class LoanApplication {
private String loanApplicationId;
public Client getClient() {
return client;
return this.client;
}
public void setClient(Client client) {
@@ -19,7 +19,7 @@ public class LoanApplication {
}
public BigDecimal getAmount() {
return amount;
return this.amount;
}
public void setAmount(BigDecimal amount) {
@@ -27,7 +27,7 @@ public class LoanApplication {
}
public String getLoanApplicationId() {
return loanApplicationId;
return this.loanApplicationId;
}
public void setLoanApplicationId(String loanApplicationId) {

View File

@@ -15,7 +15,7 @@ public class LoanApplicationResult {
}
public LoanApplicationStatus getLoanApplicationStatus() {
return loanApplicationStatus;
return this.loanApplicationStatus;
}
public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) {
@@ -23,7 +23,7 @@ public class LoanApplicationResult {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -12,7 +12,7 @@ public class FraudCheck {
}
public String getClientPesel() {
return clientPesel;
return this.clientPesel;
}
public void setClientPesel(String clientPesel) {
@@ -20,7 +20,7 @@ public class FraudCheck {
}
public BigDecimal getLoanAmount() {
return loanAmount;
return this.loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {

View File

@@ -15,7 +15,7 @@ public class FraudCheckResult {
}
public FraudCheckStatus getFraudCheckStatus() {
return fraudCheckStatus;
return this.fraudCheckStatus;
}
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
@@ -23,7 +23,7 @@ public class FraudCheckResult {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -43,7 +43,7 @@ public class LoanApplicationService {
httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1);
ResponseEntity<FraudServiceResponse> response =
restTemplate.exchange("http://localhost:" + port + "/fraudcheck", HttpMethod.PUT,
this.restTemplate.exchange("http://localhost:" + this.port + "/fraudcheck", HttpMethod.PUT,
new HttpEntity<>(request, httpHeaders),
FraudServiceResponse.class);

View File

@@ -5,7 +5,7 @@ public class Client {
private String pesel;
public String getPesel() {
return pesel;
return this.pesel;
}
public void setPesel(String pesel) {

View File

@@ -17,7 +17,7 @@ public class FraudServiceRequest {
}
public String getClientPesel() {
return clientPesel;
return this.clientPesel;
}
public void setClientPesel(String clientPesel) {
@@ -25,7 +25,7 @@ public class FraudServiceRequest {
}
public BigDecimal getLoanAmount() {
return loanAmount;
return this.loanAmount;
}
public void setLoanAmount(BigDecimal loanAmount) {

View File

@@ -10,7 +10,7 @@ public class FraudServiceResponse {
}
public FraudCheckStatus getFraudCheckStatus() {
return fraudCheckStatus;
return this.fraudCheckStatus;
}
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
@@ -18,7 +18,7 @@ public class FraudServiceResponse {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -11,7 +11,7 @@ public class LoanApplication {
private String loanApplicationId;
public Client getClient() {
return client;
return this.client;
}
public void setClient(Client client) {
@@ -19,7 +19,7 @@ public class LoanApplication {
}
public BigDecimal getAmount() {
return amount;
return this.amount;
}
public void setAmount(BigDecimal amount) {
@@ -27,7 +27,7 @@ public class LoanApplication {
}
public String getLoanApplicationId() {
return loanApplicationId;
return this.loanApplicationId;
}
public void setLoanApplicationId(String loanApplicationId) {

View File

@@ -15,7 +15,7 @@ public class LoanApplicationResult {
}
public LoanApplicationStatus getLoanApplicationStatus() {
return loanApplicationStatus;
return this.loanApplicationStatus;
}
public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) {
@@ -23,7 +23,7 @@ public class LoanApplicationResult {
}
public String getRejectionReason() {
return rejectionReason;
return this.rejectionReason;
}
public void setRejectionReason(String rejectionReason) {

View File

@@ -197,6 +197,39 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build-tools</artifactId>
<version>${spring-cloud-build.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<sourceDirectories>
${project.basedir}/src/main/java,${project.basedir}/src/main/groovy
</sourceDirectories>
<testSourceDirectories>
${project.basedir}/src/test/java,${project.basedir}/src/test/groovy
</testSourceDirectories>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@@ -77,20 +77,20 @@ public class ConvertMojo extends AbstractMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
if (this.skip) {
getLog().info(String.format(
"Skipping Spring Cloud Contract Verifier execution: spring.cloud.contract.verifier.skip=%s",
skip));
this.skip));
return;
}
new CopyContracts(project, mavenSession, mavenResourcesFiltering)
.copy(contractsDirectory, outputDirectory);
new CopyContracts(this.project, this.mavenSession, this.mavenResourcesFiltering)
.copy(this.contractsDirectory, this.outputDirectory);
final ContractVerifierConfigProperties config = new ContractVerifierConfigProperties();
config.setContractsDslDir(isInsideProject() ? contractsDirectory : source);
config.setContractsDslDir(isInsideProject() ? this.contractsDirectory : this.source);
config.setStubsOutputDir(
isInsideProject() ? new File(outputDirectory, "mappings") : destination);
isInsideProject() ? new File(this.outputDirectory, "mappings") : this.destination);
getLog().info(
"Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings");
@@ -106,7 +106,7 @@ public class ConvertMojo extends AbstractMojo {
}
private boolean isInsideProject() {
return mavenSession.getRequest().isProjectPresent();
return this.mavenSession.getRequest().isProjectPresent();
}
}

View File

@@ -51,15 +51,15 @@ class CopyContracts {
MavenResourcesExecution execution = new MavenResourcesExecution();
execution.setResources(Collections.singletonList(resource));
execution.setOutputDirectory(new File(outputDirectory, "contracts"));
execution.setMavenProject(project);
execution.setMavenProject(this.project);
execution.setEncoding("UTF-8");
execution.setMavenSession(mavenSession);
execution.setMavenSession(this.mavenSession);
execution.setInjectProjectBuildFilters(false);
execution.setOverwrite(true);
execution.setIncludeEmptyDirs(false);
execution.setFilterFilenames(false);
try {
mavenResourcesFiltering.filterResources(execution);
this.mavenResourcesFiltering.filterResources(execution);
}
catch (MavenFilteringException e) {
throw new MojoExecutionException(e.getMessage(), e);

View File

@@ -66,14 +66,14 @@ public class GenerateStubsMojo extends AbstractMojo {
private String classifier;
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
if (this.skip) {
getLog().info(
"Skipping Spring Cloud Contract Verifier execution: spring.cloud.contract.verifier.skip="
+ skip);
+ this.skip);
return;
}
File stubsJarFile = createStubJar(outputDirectory);
projectHelper.attachArtifact(project, "jar", classifier, stubsJarFile);
File stubsJarFile = createStubJar(this.outputDirectory);
this.projectHelper.attachArtifact(this.project, "jar", this.classifier, stubsJarFile);
}
private File createStubJar(File stubsOutputDir)
@@ -84,29 +84,29 @@ public class GenerateStubsMojo extends AbstractMojo {
+ "] .\nPlease make sure that spring-cloud-contract:convert was invoked");
}
String stubArchiveName =
project.getBuild().getFinalName() + "-" + classifier + ".jar";
File stubsJarFile = new File(projectBuildDirectory, stubArchiveName);
this.project.getBuild().getFinalName() + "-" + this.classifier + ".jar";
File stubsJarFile = new File(this.projectBuildDirectory, stubArchiveName);
try {
if (attachContracts) {
archiver.addDirectory(stubsOutputDir,
if (this.attachContracts) {
this.archiver.addDirectory(stubsOutputDir,
new String[] { STUB_MAPPING_FILE_PATTERN, CONTRACT_FILE_PATTERN },
new String[0]);
}
else {
getLog().info(
"Skipping attaching Spring Cloud Contract Verifier contracts");
archiver.addDirectory(stubsOutputDir,
this.archiver.addDirectory(stubsOutputDir,
new String[] { STUB_MAPPING_FILE_PATTERN },
new String[] { CONTRACT_FILE_PATTERN });
}
archiver.setCompress(true);
archiver.setDestFile(stubsJarFile);
archiver.addConfiguredManifest(ManifestCreator.createManifest(project));
archiver.createArchive();
this.archiver.setCompress(true);
this.archiver.setDestFile(stubsJarFile);
this.archiver.addConfiguredManifest(ManifestCreator.createManifest(this.project));
this.archiver.createArchive();
}
catch (Exception e) {
throw new MojoFailureException(
"Exception while packaging " + classifier + " jar.", e);
"Exception while packaging " + this.classifier + " jar.", e);
}
return stubsJarFile;
}

View File

@@ -106,32 +106,32 @@ public class GenerateTestsMojo extends AbstractMojo {
@Parameter(property = "skipTests", defaultValue = "false") private boolean skipTests;
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip || mavenTestSkip || skipTests) {
if (skip) getLog().info("Skipping Spring Cloud Contract Verifier execution: spring.cloud.contract.verifier.skip=" + skip);
if (mavenTestSkip) getLog().info("Skipping Spring Cloud Contract Verifier execution: maven.test.skip=" + mavenTestSkip);
if (skipTests) getLog().info("Skipping Spring Cloud Contract Verifier execution: skipTests" + skipTests);
if (this.skip || this.mavenTestSkip || this.skipTests) {
if (this.skip) getLog().info("Skipping Spring Cloud Contract Verifier execution: spring.cloud.contract.verifier.skip=" + this.skip);
if (this.mavenTestSkip) getLog().info("Skipping Spring Cloud Contract Verifier execution: maven.test.skip=" + this.mavenTestSkip);
if (this.skipTests) getLog().info("Skipping Spring Cloud Contract Verifier execution: skipTests" + this.skipTests);
return;
}
getLog().info(
"Generating server tests source code for Spring Cloud Contract Verifier contract verification");
final ContractVerifierConfigProperties config = new ContractVerifierConfigProperties();
config.setContractsDslDir(contractsDirectory);
config.setGeneratedTestSourcesDir(generatedTestSourcesDir);
config.setTargetFramework(testFramework);
config.setTestMode(testMode);
config.setBasePackageForTests(basePackageForTests);
config.setBaseClassForTests(baseClassForTests);
config.setRuleClassForTests(ruleClassForTests);
config.setNameSuffixForTests(nameSuffixForTests);
config.setImports(imports);
config.setStaticImports(staticImports);
config.setIgnoredFiles(ignoredFiles);
config.setExcludedFiles(excludedFiles);
config.setAssertJsonSize(assertJsonSize);
project.addTestCompileSourceRoot(generatedTestSourcesDir.getAbsolutePath());
config.setContractsDslDir(this.contractsDirectory);
config.setGeneratedTestSourcesDir(this.generatedTestSourcesDir);
config.setTargetFramework(this.testFramework);
config.setTestMode(this.testMode);
config.setBasePackageForTests(this.basePackageForTests);
config.setBaseClassForTests(this.baseClassForTests);
config.setRuleClassForTests(this.ruleClassForTests);
config.setNameSuffixForTests(this.nameSuffixForTests);
config.setImports(this.imports);
config.setStaticImports(this.staticImports);
config.setIgnoredFiles(this.ignoredFiles);
config.setExcludedFiles(this.excludedFiles);
config.setAssertJsonSize(this.assertJsonSize);
this.project.addTestCompileSourceRoot(this.generatedTestSourcesDir.getAbsolutePath());
if (getLog().isInfoEnabled()) {
getLog().info(
"Test Source directory: " + generatedTestSourcesDir.getAbsolutePath()
"Test Source directory: " + this.generatedTestSourcesDir.getAbsolutePath()
+ " added.");
getLog().info("Using " + config.getBaseClassForTests()
+ " as base class for test classes");
@@ -149,7 +149,7 @@ public class GenerateTestsMojo extends AbstractMojo {
}
public List<String> getExcludedFiles() {
return excludedFiles;
return this.excludedFiles;
}
public void setExcludedFiles(List<String> excludedFiles) {
@@ -157,7 +157,7 @@ public class GenerateTestsMojo extends AbstractMojo {
}
public List<String> getIgnoredFiles() {
return ignoredFiles;
return this.ignoredFiles;
}
public void setIgnoredFiles(List<String> ignoredFiles) {
@@ -165,7 +165,7 @@ public class GenerateTestsMojo extends AbstractMojo {
}
public boolean isAssertJsonSize() {
return assertJsonSize;
return this.assertJsonSize;
}
public void setAssertJsonSize(boolean assertJsonSize) {

View File

@@ -97,25 +97,25 @@ public class RunMojo extends AbstractMojo {
}
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip || skipTestOnly) {
getLog().info("Skipping verifier execution: spring.cloud.contract.verifier.skip=" + skip);
if (this.skip || this.skipTestOnly) {
getLog().info("Skipping verifier execution: spring.cloud.contract.verifier.skip=" + this.skip);
return;
}
BatchStubRunner batchStubRunner = null;
StubRunnerOptionsBuilder optionsBuilder = new StubRunnerOptionsBuilder()
.withStubsClassifier(stubsClassifier);
if (isNullOrEmpty(stubs)) {
.withStubsClassifier(this.stubsClassifier);
if (isNullOrEmpty(this.stubs)) {
StubRunnerOptions options = optionsBuilder
.withPort(httpPort)
.withPort(this.httpPort)
.build();
StubRunner stubRunner = localStubRunner.run(resolveStubsDirectory().getAbsolutePath(), options);
StubRunner stubRunner = this.localStubRunner.run(resolveStubsDirectory().getAbsolutePath(), options);
batchStubRunner = new BatchStubRunner(Collections.singleton(stubRunner));
} else {
StubRunnerOptions options = optionsBuilder
.withStubs(stubs)
.withMinMaxPort(minPort, maxPort)
.withStubs(this.stubs)
.withMinMaxPort(this.minPort, this.maxPort)
.build();
batchStubRunner = remoteStubRunner.run(options, repoSession);
batchStubRunner = this.remoteStubRunner.run(options, this.repoSession);
}
pressAnyKeyToContinue();
if (batchStubRunner != null) {
@@ -129,9 +129,9 @@ public class RunMojo extends AbstractMojo {
private File resolveStubsDirectory() {
if (isInsideProject()) {
return stubsDirectory;
return this.stubsDirectory;
} else {
return destination;
return this.destination;
}
}
@@ -144,7 +144,7 @@ public class RunMojo extends AbstractMojo {
}
private boolean isInsideProject() {
return mavenSession.getRequest().isProjectPresent();
return this.mavenSession.getRequest().isProjectPresent();
}
}

View File

@@ -38,7 +38,7 @@ public class AetherStubDownloaderFactory {
}
public AetherStubDownloader build(RepositorySystemSession repoSession) {
return new AetherStubDownloader(repoSystem,
project.getRemoteProjectRepositories(), repoSession);
return new AetherStubDownloader(this.repoSystem,
this.project.getRemoteProjectRepositories(), repoSession);
}
}

View File

@@ -39,7 +39,7 @@ public class RemoteStubRunner {
}
public BatchStubRunner run(StubRunnerOptions options, RepositorySystemSession repositorySystemSession) {
AetherStubDownloader stubDownloader = aetherStubDownloaderFactory.build(repositorySystemSession);
AetherStubDownloader stubDownloader = this.aetherStubDownloaderFactory.build(repositorySystemSession);
try {
if (log.isDebugEnabled()) {
log.debug("Launching StubRunner with args: " + options);

View File

@@ -46,8 +46,8 @@ public class PluginIT {
@Test
public void should_build_project_Spring_Boot_Groovy_with_Accurest() throws Exception {
File basedir = resources.getBasedir("spring-boot-groovy");
maven.forProject(basedir)
File basedir = this.resources.getBasedir("spring-boot-groovy");
this.maven.forProject(basedir)
.execute("package")
.assertErrorFreeLog()
.assertLogText("Generating server tests source code for Spring Cloud Contract Verifier contract verification")
@@ -60,8 +60,8 @@ public class PluginIT {
@Test
public void should_build_project_Spring_Boot_Java_with_Accurest() throws Exception {
File basedir = resources.getBasedir("spring-boot-java");
maven.forProject(basedir)
File basedir = this.resources.getBasedir("spring-boot-java");
this.maven.forProject(basedir)
.execute("package")
.assertErrorFreeLog()
.assertLogText("Generating server tests source code for Spring Cloud Contract Verifier contract verification")
@@ -74,8 +74,8 @@ public class PluginIT {
@Test
public void should_build_project_with_plugin_extension() throws Exception {
File basedir = resources.getBasedir("plugin-extension");
maven.forProject(basedir)
File basedir = this.resources.getBasedir("plugin-extension");
this.maven.forProject(basedir)
.execute("package")
.assertErrorFreeLog()
.assertLogText("Generating server tests source code for Spring Cloud Contract Verifier contract verification")
@@ -89,8 +89,8 @@ public class PluginIT {
@Test
@Ignore("Ignored, because of bug accurest#245")
public void should_build_project_project_with_complex_configuration() throws Exception {
File basedir = resources.getBasedir("complex-configuration");
maven.forProject(basedir)
File basedir = this.resources.getBasedir("complex-configuration");
this.maven.forProject(basedir)
.execute("package")
.assertErrorFreeLog()
.assertLogText("Tests run: 2, Failures: 0, Errors: 0, Skipped: 1")
@@ -100,12 +100,12 @@ public class PluginIT {
@Test
public void should_convert_Accurest_Contracts_to_WireMock_Stubs_mappings() throws Exception {
File basedir = resources.getBasedir("pomless");
properties.getPluginVersion();
maven.forProject(basedir)
File basedir = this.resources.getBasedir("pomless");
this.properties.getPluginVersion();
this.maven.forProject(basedir)
.withCliOption("-X")
.execute(String.format("org.springframework.cloud:spring-cloud-contract-maven-plugin:%s:convert",
properties.getPluginVersion()))
this.properties.getPluginVersion()))
.assertLogText("Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings")
.assertLogText("Creating new json")
.assertErrorFreeLog();

View File

@@ -40,62 +40,62 @@ public class PluginUnitTest {
@Test
public void shouldGenerateWireMockStubsInDefaultLocation() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "convert");
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert");
assertFilesPresent(basedir, "target/stubs/mappings/Sample.json");
assertFilesNotPresent(basedir, "target/stubs/mappings/Messaging.json");
}
@Test
public void shouldGenerateWireMockFromStubsDirectory() throws Exception {
File basedir = resources.getBasedir("withStubs");
maven.executeMojo(basedir, "convert", newParameter("contractsDirectory", "src/test/resources/stubs"));
File basedir = this.resources.getBasedir("withStubs");
this.maven.executeMojo(basedir, "convert", newParameter("contractsDirectory", "src/test/resources/stubs"));
assertFilesPresent(basedir, "target/stubs/mappings/Sample.json");
}
@Test
public void shouldCopyContracts() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "convert");
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert");
assertFilesPresent(basedir, "target/stubs/contracts/Sample.groovy");
assertFilesPresent(basedir, "target/stubs/contracts/Messaging.groovy");
}
@Test
public void shouldGenerateWireMockStubsInSelectedLocation() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "convert", newParameter("outputDirectory", "target/foo"));
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert", newParameter("outputDirectory", "target/foo"));
assertFilesPresent(basedir, "target/foo/mappings/Sample.json");
}
@Test
public void shouldGenerateContractSpecificationInDefaultLocation() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "generateTests", newParameter("testFramework", "SPOCK"));
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", newParameter("testFramework", "SPOCK"));
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierSpec.groovy");
}
@Test
public void shouldGenerateContractTestsInDefaultLocation() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "generateTests");
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests");
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
}
@Test
public void shouldGenerateContractTestsWithCustomImports() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "generateTests", newParameter("imports", ""));
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", newParameter("imports", ""));
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
}
@Test
public void shouldGenerateContractTestsWithoutArraySize() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "generateTests");
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests");
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
File test = new File(basedir, "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
@@ -104,8 +104,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithArraySize() throws Exception {
File basedir = resources.getBasedir("basic");
maven.executeMojo(basedir, "generateTests", newParameter("assertJsonSize", "true"));
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", newParameter("assertJsonSize", "true"));
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
File test = new File(basedir, "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
@@ -114,23 +114,23 @@ public class PluginUnitTest {
@Test
public void shouldGenerateStubs() throws Exception {
File basedir = resources.getBasedir("generatedStubs");
maven.executeMojo(basedir, "generateStubs");
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs");
assertFilesPresent(basedir, "target/sample-project-0.1-stubs.jar");
}
@Test
public void shouldGenerateStubsWithMappingsOnly() throws Exception {
File basedir = resources.getBasedir("generatedStubs");
maven.executeMojo(basedir, "generateStubs", newParameter("attachContracts", "false"));
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", newParameter("attachContracts", "false"));
assertFilesPresent(basedir, "target/sample-project-0.1-stubs.jar");
// FIXME: add assertion for jar content
}
@Test
public void shouldGenerateStubsWithCustomClassifier() throws Exception {
File basedir = resources.getBasedir("generatedStubs");
maven.executeMojo(basedir, "generateStubs", newParameter("classifier", "foo"));
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", newParameter("classifier", "foo"));
assertFilesPresent(basedir, "target/sample-project-0.1-foo.jar");
}

View File

@@ -0,0 +1 @@
/.apt_generated/

View File

@@ -1,13 +1,13 @@
package org.springframework.cloud.contract.wiremock;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.springframework.http.HttpMethod;
import org.springframework.http.RequestEntity;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
public class WiremockMockServerApplicationTests {
private RestTemplate restTemplate = new RestTemplate();
@@ -17,7 +17,7 @@ public class WiremockMockServerApplicationTests {
MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings/resource.json").build();
assertThat(restTemplate.getForObject("http://example.org/resource", String.class))
assertThat(this.restTemplate.getForObject("http://example.org/resource", String.class))
.isEqualTo("Hello World");
server.verify();
}
@@ -27,7 +27,7 @@ public class WiremockMockServerApplicationTests {
MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings/poster.json").build();
assertThat(restTemplate.postForObject("http://example.org/poster", "greeting",
assertThat(this.restTemplate.postForObject("http://example.org/poster", "greeting",
String.class)).isEqualTo("Hello World");
server.verify();
}
@@ -37,7 +37,7 @@ public class WiremockMockServerApplicationTests {
WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings/*.json").ignoreExpectOrder(true).build();
assertThat(restTemplate.exchange("http://example.org/poster", HttpMethod.POST,
assertThat(this.restTemplate.exchange("http://example.org/poster", HttpMethod.POST,
RequestEntity.EMPTY, String.class).getBody()).isEqualTo("Accepted World");
}
@@ -46,7 +46,7 @@ public class WiremockMockServerApplicationTests {
WireMockRestServiceServer.with(this.restTemplate) //
.baseUrl("http://example.org") //
.stubs("classpath:/mappings").ignoreExpectOrder(true).build();
assertThat(restTemplate.getForObject("http://example.org/resource", String.class))
assertThat(this.restTemplate.getForObject("http://example.org/resource", String.class))
.isEqualTo("Hello World");
}

View File

@@ -1,7 +1,5 @@
package org.springframework.cloud.contract.wiremock;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfiguration.class)
@AutoConfigureRestDocs(outputDir = "target/snippets")
@@ -31,7 +31,7 @@ public class WiremockServerRestDocsApplicationTests {
@Test
public void contextLoads() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/resource"))
this.mockMvc.perform(MockMvcRequestBuilders.get("/resource"))
.andExpect(MockMvcResultMatchers.content().string("Hello World"))
.andDo(document("resource"));
}

View File

@@ -41,7 +41,7 @@ public class WiremockServerRestDocsMatcherApplicationTests {
@Test
public void matchesRequest() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
this.mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
.contentType(MediaType.TEXT_PLAIN))
.andExpect(MockMvcResultMatchers.content().string("Hello World"))
.andDo(WireMockRestDocs.verify()
@@ -52,9 +52,9 @@ public class WiremockServerRestDocsMatcherApplicationTests {
@Test
public void doesNotMatch() throws Exception {
expected.expect(ComparisonFailure.class);
expected.expectMessage("wiremock did not match");
mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
this.expected.expect(ComparisonFailure.class);
this.expected.expectMessage("wiremock did not match");
this.mockMvc.perform(MockMvcRequestBuilders.post("/resource").content("greeting")
.contentType(MediaType.TEXT_PLAIN))
.andExpect(MockMvcResultMatchers.content().string("Hello World"))
.andDo(WireMockRestDocs.verify()

View File

@@ -37,8 +37,8 @@ public class BookDeleter {
public void bookDeleted(Exchange exchange) {
BookDeleted bookDeleted = exchange.getIn().getBody(BookDeleted.class);
log.info("Deleting book " + bookDeleted);
bookSuccessfulyDeleted.set(true);
log.info("Book successfuly deleted [$bookSuccessfulyDeleted]");
this.bookSuccessfulyDeleted.set(true);
log.info("Book successfuly deleted [" + this.bookSuccessfulyDeleted + "]");
}
private AtomicBoolean bookSuccessfulyDeleted = new AtomicBoolean(false);

View File

@@ -49,6 +49,6 @@ public class BookListener {
*/
public void bookDeleted(BookDeleted bookDeleted) {
log.info("Deleting book [ "+ bookDeleted + "]");
bookSuccessfullyDeleted.set(true);
this.bookSuccessfullyDeleted.set(true);
}
}

View File

@@ -41,7 +41,7 @@ public class BookService {
*/
public void returnBook(BookReturned bookReturned) {
log.info("Returning book " + bookReturned);
outputChannel.send(MessageBuilder.withPayload(bookReturned)
this.outputChannel.send(MessageBuilder.withPayload(bookReturned)
.setHeader("BOOK-NAME", bookReturned.bookName).build());
}
}

View File

@@ -16,7 +16,6 @@
package com.example;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.JMSException;
@@ -31,7 +30,6 @@ import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Service
@@ -52,7 +50,7 @@ public class BookListener {
*/
@JmsListener(destination = "input")
public void returnBook(String messageAsString) throws Exception {
final BookReturned bookReturned = objectMapper.readerFor(BookReturned.class).readValue(messageAsString);
final BookReturned bookReturned = this.objectMapper.readerFor(BookReturned.class).readValue(messageAsString);
log.info("Returning book [$bookReturned]");
MessageCreator messageCreator = new MessageCreator() {
@Override
@@ -62,21 +60,21 @@ public class BookListener {
return message;
}
};
jmsTemplate.send("output", messageCreator);
this.jmsTemplate.send("output", messageCreator);
}
/**
Scenario for "should generate tests triggered by a message":
client side: if sends a message to input.messageFrom then message will be sent to output.messageFrom
server side: will send a message to input, verify the message contents and await upon receiving message on the output messageFrom
* @throws IOException
* @throws JsonProcessingException
* @throws java.io.IOException
* @throws com.fasterxml.jackson.core.JsonProcessingException
*/
@JmsListener(destination = "delete")
public void bookDeleted(String bookDeletedAsString) throws Exception {
BookDeleted bookDeleted = objectMapper.readerFor(BookDeleted.class).readValue(bookDeletedAsString);
BookDeleted bookDeleted = this.objectMapper.readerFor(BookDeleted.class).readValue(bookDeletedAsString);
log.info("Deleting book " + bookDeleted);
bookSuccessfulyDeleted.set(true);
this.bookSuccessfulyDeleted.set(true);
}
AtomicBoolean bookSuccessfulyDeleted = new AtomicBoolean(false);

View File

@@ -52,6 +52,6 @@ public class BookService {
return message;
}
};
jmsTemplate.send("output", messageCreator);
this.jmsTemplate.send("output", messageCreator);
}
}

View File

@@ -44,7 +44,7 @@ public class BookListener {
@StreamListener(Sink.INPUT)
public void returnBook(BookReturned bookReturned) {
log.info("Returning book " + bookReturned);
source.output().send(MessageBuilder.withPayload(bookReturned)
this.source.output().send(MessageBuilder.withPayload(bookReturned)
.setHeader("BOOK-NAME", bookReturned.bookName).build());
}
@@ -58,7 +58,7 @@ public class BookListener {
public void bookDeleted(BookDeleted bookDeleted) {
log.info("Deleting book " + bookDeleted);
// ... doing some work
bookSuccessfulyDeleted.set(true);
this.bookSuccessfulyDeleted.set(true);
}
public AtomicBoolean bookSuccessfulyDeleted = new AtomicBoolean(false);

View File

@@ -45,7 +45,7 @@ public class BookService {
*/
public void returnBook(BookReturned bookReturned) {
log.info("Returning book " + bookReturned);
source.output().send(MessageBuilder.withPayload(bookReturned)
this.source.output().send(MessageBuilder.withPayload(bookReturned)
.setHeader("BOOK-NAME", bookReturned.bookName).build());
}
}