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.AfterAllCallbackpublic void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
throws Exception
afterEach in interface org.junit.jupiter.api.extension.AfterEachCallbackExceptionpublic void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallbackpublic void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
throws Exception
beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallbackExceptionpublic URL findStubUrl(String groupId, String artifactId) throws StubNotFoundException
StubFinderfindStubUrl in interface StubFindergroupId - - 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 StubFinderivyNotation - - Ivy representation of the Maven artifactStubNotFoundException - in case of not finding a stubpublic 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 StubTriggerpublic 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 RunnerStubRunnerOptionspublic 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
StubDownloaderBuilderpublic StubRunnerExtension withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer)
httpServerStubConfigurer - Configuration for an HTTP server stubCopyright © 2016–2021 Spring. All rights reserved.