public class StubRunnerRule extends Object implements org.junit.rules.TestRule, StubFinder
| Modifier and Type | Class and Description |
|---|---|
static class |
StubRunnerRule.PortStubRunnerRule
Helper class with additional port, related methods once you pick a stub to
download.
|
| Constructor and Description |
|---|
StubRunnerRule() |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
StubRunnerRule.PortStubRunnerRule |
downloadLatestStub(String groupId,
String artifactId,
String classifier) |
StubRunnerRule.PortStubRunnerRule |
downloadStub(String ivyNotation) |
StubRunnerRule.PortStubRunnerRule |
downloadStub(String groupId,
String artifactId) |
StubRunnerRule.PortStubRunnerRule |
downloadStub(String groupId,
String artifactId,
String version) |
StubRunnerRule.PortStubRunnerRule |
downloadStub(String groupId,
String artifactId,
String version,
String classifier) |
StubRunnerRule |
downloadStubs(List<String> ivyNotations) |
StubRunnerRule |
downloadStubs(String... ivyNotations) |
StubRunnerRule |
failOnNoStubs(boolean failOnNoStubs) |
RunningStubs |
findAllRunningStubs() |
URL |
findStubUrl(String ivyNotation)
For the given Ivy notation
[groupId]:artifactId:[version]:[classifier]
tries to find the matching URL of the running stub. |
URL |
findStubUrl(String groupId,
String artifactId)
For the given groupId and artifactId tries to find the matching URL of the running
stub.
|
Map<StubConfiguration,Collection<org.springframework.cloud.contract.spec.Contract>> |
getContracts() |
Map<String,Collection<String>> |
labels()
Feature related to messaging.
|
StubRunnerRule |
maxPort(int maxPort) |
StubRunnerRule |
messageVerifier(MessageVerifier messageVerifier)
Pass the
MessageVerifier that this rule should use. |
StubRunnerRule |
minPort(int minPort) |
StubRunnerRule |
options(StubRunnerOptions stubRunnerOptions)
Override all options.
|
StubRunnerRule |
repoRoot(String repoRoot) |
StubRunnerRule |
stubsMode(StubRunnerProperties.StubsMode stubsMode) |
boolean |
trigger()
Triggers all possible events.
|
boolean |
trigger(String labelName)
Triggers an event by a given label.
|
boolean |
trigger(String ivyNotation,
String labelName)
Triggers an event by a given label for a given
groupid:artifactid notation. |
StubRunnerRule |
withConsumerName(String consumerName) |
StubRunnerRule |
withDeleteStubsAfterTest(boolean deleteStubsAfterTest) |
StubRunnerRule |
withGenerateStubs(boolean generateStubs) |
StubRunnerRule |
withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer) |
StubRunnerRule |
withMappingsOutputFolder(String mappingsOutputFolder) |
StubRunnerRule |
withProperties(Map<String,String> properties) |
StubRunnerRule |
withStubPerConsumer(boolean stubPerConsumer) |
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRulepublic StubRunnerRule messageVerifier(MessageVerifier messageVerifier)
MessageVerifier that this rule should use. If you don't pass
anything a ExceptionThrowingMessageVerifier will be used. That means that
an exception will be thrown whenever you try to do sth messaging related.messageVerifier - message verifier implementationpublic StubRunnerRule options(StubRunnerOptions stubRunnerOptions)
stubRunnerOptions - options of Stub RunnerStubRunnerOptionspublic StubRunnerRule minPort(int minPort)
minPort - min value of port for WireMock serverpublic StubRunnerRule maxPort(int maxPort)
maxPort - max value of port for WireMock serverpublic StubRunnerRule repoRoot(String repoRoot)
repoRoot - String URI of repository containing stubspublic StubRunnerRule stubsMode(StubRunnerProperties.StubsMode stubsMode)
stubsMode - Stubs mode that should be usedpublic StubRunnerRule.PortStubRunnerRule downloadStub(String groupId, String artifactId, String version, String classifier)
groupId - group id of the stubartifactId - artifact id of the stubversion - version of the stubclassifier - classifier of the stubpublic StubRunnerRule.PortStubRunnerRule downloadLatestStub(String groupId, String artifactId, String classifier)
groupId - group id of the stubartifactId - artifact id of the stubclassifier - classifier of the stubpublic StubRunnerRule.PortStubRunnerRule downloadStub(String groupId, String artifactId, String version)
groupId - group id of the stubartifactId - artifact id of the stubversion - version of the stubpublic StubRunnerRule.PortStubRunnerRule downloadStub(String groupId, String artifactId)
groupId - group id of the stubartifactId - artifact id of the stubpublic StubRunnerRule.PortStubRunnerRule downloadStub(String ivyNotation)
ivyNotation - Ivy notation of a single stub to download.public StubRunnerRule downloadStubs(String... ivyNotations)
ivyNotations - Stubs to download in Ivy notations.public StubRunnerRule downloadStubs(List<String> ivyNotations)
ivyNotations - Stubs to download in Ivy notations.public StubRunnerRule withStubPerConsumer(boolean stubPerConsumer)
stubPerConsumer - Allows stub per consumer.public StubRunnerRule withConsumerName(String consumerName)
consumerName - given consumer namepublic StubRunnerRule withMappingsOutputFolder(String mappingsOutputFolder)
mappingsOutputFolder - Allows setting the output folder for mappingspublic StubRunnerRule withDeleteStubsAfterTest(boolean deleteStubsAfterTest)
deleteStubsAfterTest - If set to false will NOT delete stubs from a
temporary folder after running testspublic StubRunnerRule withGenerateStubs(boolean generateStubs)
generateStubs - If set to true will NOT load generated stubs but will
generate stubs from contract definitions at runtime.public StubRunnerRule failOnNoStubs(boolean failOnNoStubs)
failOnNoStubs - when enabled, this flag will tell stub runner to throw an
exception when no stubs / contracts were found.public StubRunnerRule withProperties(Map<String,String> properties)
properties - Map of properties that can be passed to custom
StubDownloaderBuilderpublic StubRunnerRule withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer)
httpServerStubConfigurer - Configuration for an HTTP server stubpublic URL findStubUrl(String groupId, String artifactId)
StubFinderfindStubUrl in interface StubFindergroupId - - might be null. In that case a search only via artifactId takes
placeartifactId - - artifact id of the stubpublic URL findStubUrl(String ivyNotation)
StubFinder[groupId]:artifactId:[version]:[classifier]
tries to find the matching URL of the running stub. You can also pass only
artifactId.findStubUrl in interface StubFinderivyNotation - - Ivy representation of the Maven artifactpublic RunningStubs findAllRunningStubs()
findAllRunningStubs in interface StubFinderpublic Map<StubConfiguration,Collection<org.springframework.cloud.contract.spec.Contract>> getContracts()
getContracts in interface StubFinderpublic boolean trigger(String ivyNotation, String labelName)
StubTriggergroupid:artifactid notation.
You can use only artifactId too.
Feature related to messaging.trigger in interface StubTriggerivyNotation - ivy notation of a stublabelName - name of the label to triggerpublic boolean trigger(String labelName)
StubTriggertrigger in interface StubTriggerlabelName - name of the label to triggerpublic boolean trigger()
StubTriggertrigger in interface StubTriggerpublic Map<String,Collection<String>> labels()
StubTriggerlabels in interface StubTriggerCopyright © 2016–2021 Spring. All rights reserved.