Class StubRunnerRule
java.lang.Object
org.springframework.cloud.contract.stubrunner.junit.StubRunnerRule
- All Implemented Interfaces:
org.junit.rules.TestRule
,StubFinder
,StubTrigger
- Direct Known Subclasses:
StubRunnerRule.PortStubRunnerRule
JUnit class rule that allows you to download the provided stubs.
- Author:
- Marcin Grzejszczak
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Helper class with additional port, related methods once you pick a stub to download. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) downloadLatestStub
(String groupId, String artifactId, String classifier) downloadStub
(String ivyNotation) downloadStub
(String groupId, String artifactId) downloadStub
(String groupId, String artifactId, String version) downloadStub
(String groupId, String artifactId, String version, String classifier) downloadStubs
(String... ivyNotations) downloadStubs
(List<String> ivyNotations) failOnNoStubs
(boolean failOnNoStubs) findStubUrl
(String ivyNotation) For the given Ivy notation[groupId]:artifactId:[version]:[classifier]
tries to find the matching URL of the running stub.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>> labels()
Feature related to messaging.maxPort
(int maxPort) messageVerifierReceiver
(org.springframework.cloud.contract.verifier.messaging.MessageVerifierReceiver messageVerifier) messageVerifierSender
(org.springframework.cloud.contract.verifier.messaging.MessageVerifierSender messageVerifier) minPort
(int minPort) options
(StubRunnerOptions stubRunnerOptions) stubsMode
(StubRunnerProperties.StubsMode stubsMode) boolean
trigger()
Triggers all possible events.boolean
Triggers an event by a given label.boolean
Triggers an event by a given label for a givengroupid:artifactid
notation.withConsumerName
(String consumerName) withDeleteStubsAfterTest
(boolean deleteStubsAfterTest) withGenerateStubs
(boolean generateStubs) withHttpServerStubConfigurer
(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer) withMappingsOutputFolder
(String mappingsOutputFolder) withProperties
(Map<String, String> properties) withStubPerConsumer
(boolean stubPerConsumer)
-
Constructor Details
-
StubRunnerRule
public StubRunnerRule()
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
messageVerifierSender
public StubRunnerRule messageVerifierSender(org.springframework.cloud.contract.verifier.messaging.MessageVerifierSender messageVerifier) -
messageVerifierReceiver
public StubRunnerRule messageVerifierReceiver(org.springframework.cloud.contract.verifier.messaging.MessageVerifierReceiver messageVerifier) -
options
-
minPort
-
maxPort
-
repoRoot
-
stubsMode
-
downloadStub
public StubRunnerRule.PortStubRunnerRule downloadStub(String groupId, String artifactId, String version, String classifier) -
downloadLatestStub
public StubRunnerRule.PortStubRunnerRule downloadLatestStub(String groupId, String artifactId, String classifier) -
downloadStub
public StubRunnerRule.PortStubRunnerRule downloadStub(String groupId, String artifactId, String version) -
downloadStub
-
downloadStub
-
downloadStubs
-
downloadStubs
-
withStubPerConsumer
-
withConsumerName
-
withMappingsOutputFolder
-
withDeleteStubsAfterTest
-
withGenerateStubs
-
failOnNoStubs
-
withProperties
-
withHttpServerStubConfigurer
public StubRunnerRule withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer) -
findStubUrl
Description copied from interface:StubFinder
For the given groupId and artifactId tries to find the matching URL of the running stub.- Specified by:
findStubUrl
in interfaceStubFinder
- Parameters:
groupId
- - might be null. In that case a search only via artifactId takes placeartifactId
- - artifact id of the stub- Returns:
- URL of a running stub or throws exception if not found
-
findStubUrl
Description copied from interface:StubFinder
For the given Ivy notation[groupId]:artifactId:[version]:[classifier]
tries to find the matching URL of the running stub. You can also pass onlyartifactId
.- Specified by:
findStubUrl
in interfaceStubFinder
- Parameters:
ivyNotation
- - Ivy representation of the Maven artifact- Returns:
- URL of a running stub or throws exception if not found
-
findAllRunningStubs
- Specified by:
findAllRunningStubs
in interfaceStubFinder
- Returns:
- all running stubs
-
getContracts
public Map<StubConfiguration,Collection<org.springframework.cloud.contract.spec.Contract>> getContracts()- Specified by:
getContracts
in interfaceStubFinder
- Returns:
- the list of Contracts
-
trigger
Description copied from interface:StubTrigger
Triggers an event by a given label for a givengroupid:artifactid
notation. You can use onlyartifactId
too. Feature related to messaging.- Specified by:
trigger
in interfaceStubTrigger
- Parameters:
ivyNotation
- ivy notation of a stublabelName
- name of the label to trigger- Returns:
- true - if managed to run a trigger
-
trigger
Description copied from interface:StubTrigger
Triggers an event by a given label. Feature related to messaging.- Specified by:
trigger
in interfaceStubTrigger
- Parameters:
labelName
- name of the label to trigger- Returns:
- true - if managed to run a trigger
-
trigger
public boolean trigger()Description copied from interface:StubTrigger
Triggers all possible events. Feature related to messaging.- Specified by:
trigger
in interfaceStubTrigger
- Returns:
- true - if managed to run a trigger
-
labels
Description copied from interface:StubTrigger
Feature related to messaging.- Specified by:
labels
in interfaceStubTrigger
- Returns:
- a mapping of ivy notation of a dependency to all the labels it has.
-