public class StubRunnerExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, StubFinder
Modifier and Type | Class and Description |
---|---|
static class |
StubRunnerExtension.PortStubRunnerExtension
Helper class with additional port, related methods once you pick a stub to
download.
|
Constructor and Description |
---|
StubRunnerExtension() |
Modifier and Type | Method and Description |
---|---|
void |
afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
void |
afterEach(org.junit.jupiter.api.extension.ExtensionContext context) |
void |
beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
void |
beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) |
StubRunnerExtension.PortStubRunnerExtension |
downloadLatestStub(String groupId,
String artifactId,
String classifier) |
StubRunnerExtension.PortStubRunnerExtension |
downloadStub(String ivyNotation) |
StubRunnerExtension.PortStubRunnerExtension |
downloadStub(String groupId,
String artifactId) |
StubRunnerExtension.PortStubRunnerExtension |
downloadStub(String groupId,
String artifactId,
String version) |
StubRunnerExtension.PortStubRunnerExtension |
downloadStub(String groupId,
String artifactId,
String version,
String classifier) |
StubRunnerExtension |
downloadStubs(List<String> ivyNotations) |
StubRunnerExtension |
downloadStubs(String... ivyNotations) |
StubRunnerExtension |
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.
|
StubRunnerExtension |
maxPort(int maxPort) |
StubRunnerExtension |
messageVerifier(MessageVerifier messageVerifier)
Pass the
MessageVerifier that this rule should use. |
StubRunnerExtension |
minPort(int minPort) |
StubRunnerExtension |
options(StubRunnerOptions stubRunnerOptions)
Override all options.
|
StubRunnerExtension |
repoRoot(String repoRoot) |
StubRunnerExtension |
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. |
StubRunnerExtension |
withConsumerName(String consumerName) |
StubRunnerExtension |
withDeleteStubsAfterTest(boolean deleteStubsAfterTest) |
StubRunnerExtension |
withGenerateStubs(boolean generateStubs) |
StubRunnerExtension |
withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer) |
StubRunnerExtension |
withMappingsOutputFolder(String mappingsOutputFolder) |
StubRunnerExtension |
withProperties(Map<String,String> properties) |
StubRunnerExtension |
withStubPerConsumer(boolean stubPerConsumer) |
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
afterAll
in interface org.junit.jupiter.api.extension.AfterAllCallback
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
afterEach
in interface org.junit.jupiter.api.extension.AfterEachCallback
Exception
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
beforeAll
in interface org.junit.jupiter.api.extension.BeforeAllCallback
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
beforeEach
in interface org.junit.jupiter.api.extension.BeforeEachCallback
Exception
public URL findStubUrl(String groupId, String artifactId) throws StubNotFoundException
StubFinder
findStubUrl
in interface StubFinder
groupId
- - might be null. In that case a search only via artifactId takes
placeartifactId
- - artifact id of the stubStubNotFoundException
- in case of not finding a stubpublic URL findStubUrl(String ivyNotation) throws StubNotFoundException
StubFinder
[groupId]:artifactId:[version]:[classifier]
tries to find the matching URL of the running stub. You can also pass only
artifactId
.findStubUrl
in interface StubFinder
ivyNotation
- - Ivy representation of the Maven artifactStubNotFoundException
- in case of not finding a stubpublic RunningStubs findAllRunningStubs()
findAllRunningStubs
in interface StubFinder
public Map<StubConfiguration,Collection<org.springframework.cloud.contract.spec.Contract>> getContracts()
getContracts
in interface StubFinder
public boolean trigger(String ivyNotation, String labelName)
StubTrigger
groupid:artifactid
notation.
You can use only artifactId
too.
Feature related to messaging.trigger
in interface StubTrigger
ivyNotation
- ivy notation of a stublabelName
- name of the label to triggerpublic boolean trigger(String labelName)
StubTrigger
trigger
in interface StubTrigger
labelName
- name of the label to triggerpublic boolean trigger()
StubTrigger
trigger
in interface StubTrigger
public Map<String,Collection<String>> labels()
StubTrigger
labels
in interface StubTrigger
public StubRunnerExtension 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 StubRunnerExtension options(StubRunnerOptions stubRunnerOptions)
stubRunnerOptions
- options of Stub RunnerStubRunnerOptions
public StubRunnerExtension minPort(int minPort)
minPort
- min value of port for WireMock serverpublic StubRunnerExtension maxPort(int maxPort)
maxPort
- max value of port for WireMock serverpublic StubRunnerExtension repoRoot(String repoRoot)
repoRoot
- String URI of repository containing stubspublic StubRunnerExtension stubsMode(StubRunnerProperties.StubsMode stubsMode)
stubsMode
- Stubs mode that should be usedpublic StubRunnerExtension.PortStubRunnerExtension 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 StubRunnerExtension.PortStubRunnerExtension downloadLatestStub(String groupId, String artifactId, String classifier)
groupId
- group id of the stubartifactId
- artifact id of the stubclassifier
- classifier of the stubpublic StubRunnerExtension.PortStubRunnerExtension downloadStub(String groupId, String artifactId, String version)
groupId
- group id of the stubartifactId
- artifact id of the stubversion
- version of the stubpublic StubRunnerExtension.PortStubRunnerExtension downloadStub(String groupId, String artifactId)
groupId
- group id of the stubartifactId
- artifact id of the stubpublic StubRunnerExtension.PortStubRunnerExtension downloadStub(String ivyNotation)
ivyNotation
- Ivy notation of a single stub to download.public StubRunnerExtension downloadStubs(String... ivyNotations)
ivyNotations
- Stubs to download in Ivy notations.public StubRunnerExtension downloadStubs(List<String> ivyNotations)
ivyNotations
- Stubs to download in Ivy notations.public StubRunnerExtension withStubPerConsumer(boolean stubPerConsumer)
stubPerConsumer
- Allows stub per consumer.public StubRunnerExtension withConsumerName(String consumerName)
consumerName
- given consumer namepublic StubRunnerExtension withMappingsOutputFolder(String mappingsOutputFolder)
mappingsOutputFolder
- Allows setting the output folder for mappingspublic StubRunnerExtension withDeleteStubsAfterTest(boolean deleteStubsAfterTest)
deleteStubsAfterTest
- If set to false
will NOT delete stubs from a
temporary folder after running testspublic StubRunnerExtension withGenerateStubs(boolean generateStubs)
generateStubs
- If set to true
will NOT load generated stubs but will
generate stubs from contract definitions at runtime.public StubRunnerExtension failOnNoStubs(boolean failOnNoStubs)
failOnNoStubs
- when enabled, this flag will tell stub runner to throw an
exception when no stubs / contracts were found.public StubRunnerExtension withProperties(Map<String,String> properties)
properties
- Map of properties that can be passed to custom
StubDownloaderBuilder
public StubRunnerExtension withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer)
httpServerStubConfigurer
- Configuration for an HTTP server stubCopyright © 2016–2022 Spring. All rights reserved.