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
public class StubRunnerRule extends Object implements org.junit.rules.TestRule, StubFinder
JUnit class rule that allows you to download the provided stubs.- Author:
- Marcin Grzejszczak
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStubRunnerRule.PortStubRunnerRuleHelper class with additional port, related methods once you pick a stub to download.
-
Constructor Summary
Constructors Constructor Description StubRunnerRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)StubRunnerRule.PortStubRunnerRuledownloadLatestStub(String groupId, String artifactId, String classifier)StubRunnerRule.PortStubRunnerRuledownloadStub(String ivyNotation)StubRunnerRule.PortStubRunnerRuledownloadStub(String groupId, String artifactId)StubRunnerRule.PortStubRunnerRuledownloadStub(String groupId, String artifactId, String version)StubRunnerRule.PortStubRunnerRuledownloadStub(String groupId, String artifactId, String version, String classifier)StubRunnerRuledownloadStubs(String... ivyNotations)StubRunnerRuledownloadStubs(List<String> ivyNotations)StubRunnerRulefailOnNoStubs(boolean failOnNoStubs)RunningStubsfindAllRunningStubs()URLfindStubUrl(String ivyNotation)For the given Ivy notation[groupId]:artifactId:[version]:[classifier]tries to find the matching URL of the running stub.URLfindStubUrl(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.StubRunnerRulemaxPort(int maxPort)StubRunnerRulemessageVerifier(org.springframework.cloud.contract.verifier.messaging.MessageVerifier messageVerifier)StubRunnerRuleminPort(int minPort)StubRunnerRuleoptions(StubRunnerOptions stubRunnerOptions)StubRunnerRulerepoRoot(String repoRoot)StubRunnerRulestubsMode(StubRunnerProperties.StubsMode stubsMode)booleantrigger()Triggers all possible events.booleantrigger(String labelName)Triggers an event by a given label.booleantrigger(String ivyNotation, String labelName)Triggers an event by a given label for a givengroupid:artifactidnotation.StubRunnerRulewithConsumerName(String consumerName)StubRunnerRulewithDeleteStubsAfterTest(boolean deleteStubsAfterTest)StubRunnerRulewithGenerateStubs(boolean generateStubs)StubRunnerRulewithHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer)StubRunnerRulewithMappingsOutputFolder(String mappingsOutputFolder)StubRunnerRulewithProperties(Map<String,String> properties)StubRunnerRulewithStubPerConsumer(boolean stubPerConsumer)
-
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)- Specified by:
applyin interfaceorg.junit.rules.TestRule
-
messageVerifier
public StubRunnerRule messageVerifier(org.springframework.cloud.contract.verifier.messaging.MessageVerifier messageVerifier)
-
options
public StubRunnerRule options(StubRunnerOptions stubRunnerOptions)
-
minPort
public StubRunnerRule minPort(int minPort)
-
maxPort
public StubRunnerRule maxPort(int maxPort)
-
repoRoot
public StubRunnerRule repoRoot(String repoRoot)
-
stubsMode
public StubRunnerRule stubsMode(StubRunnerProperties.StubsMode 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
public StubRunnerRule.PortStubRunnerRule downloadStub(String groupId, String artifactId)
-
downloadStub
public StubRunnerRule.PortStubRunnerRule downloadStub(String ivyNotation)
-
downloadStubs
public StubRunnerRule downloadStubs(String... ivyNotations)
-
downloadStubs
public StubRunnerRule downloadStubs(List<String> ivyNotations)
-
withStubPerConsumer
public StubRunnerRule withStubPerConsumer(boolean stubPerConsumer)
-
withConsumerName
public StubRunnerRule withConsumerName(String consumerName)
-
withMappingsOutputFolder
public StubRunnerRule withMappingsOutputFolder(String mappingsOutputFolder)
-
withDeleteStubsAfterTest
public StubRunnerRule withDeleteStubsAfterTest(boolean deleteStubsAfterTest)
-
withGenerateStubs
public StubRunnerRule withGenerateStubs(boolean generateStubs)
-
failOnNoStubs
public StubRunnerRule failOnNoStubs(boolean failOnNoStubs)
-
withProperties
public StubRunnerRule withProperties(Map<String,String> properties)
-
withHttpServerStubConfigurer
public StubRunnerRule withHttpServerStubConfigurer(Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer)
-
findStubUrl
public URL findStubUrl(String groupId, String artifactId)
Description copied from interface:StubFinderFor the given groupId and artifactId tries to find the matching URL of the running stub.- Specified by:
findStubUrlin 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
public URL findStubUrl(String ivyNotation)
Description copied from interface:StubFinderFor 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:
findStubUrlin interfaceStubFinder- Parameters:
ivyNotation- - Ivy representation of the Maven artifact- Returns:
- URL of a running stub or throws exception if not found
-
findAllRunningStubs
public RunningStubs findAllRunningStubs()
- Specified by:
findAllRunningStubsin interfaceStubFinder- Returns:
- all running stubs
-
getContracts
public Map<StubConfiguration,Collection<org.springframework.cloud.contract.spec.Contract>> getContracts()
- Specified by:
getContractsin interfaceStubFinder- Returns:
- the list of Contracts
-
trigger
public boolean trigger(String ivyNotation, String labelName)
Description copied from interface:StubTriggerTriggers an event by a given label for a givengroupid:artifactidnotation. You can use onlyartifactIdtoo. Feature related to messaging.- Specified by:
triggerin interfaceStubTrigger- Parameters:
ivyNotation- ivy notation of a stublabelName- name of the label to trigger- Returns:
- true - if managed to run a trigger
-
trigger
public boolean trigger(String labelName)
Description copied from interface:StubTriggerTriggers an event by a given label. Feature related to messaging.- Specified by:
triggerin 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:StubTriggerTriggers all possible events. Feature related to messaging.- Specified by:
triggerin interfaceStubTrigger- Returns:
- true - if managed to run a trigger
-
labels
public Map<String,Collection<String>> labels()
Description copied from interface:StubTriggerFeature related to messaging.- Specified by:
labelsin interfaceStubTrigger- Returns:
- a mapping of ivy notation of a dependency to all the labels it has.
-
-