java.lang.Object
org.springframework.cloud.contract.stubrunner.StubRunner
All Implemented Interfaces:
Closeable, AutoCloseable, StubFinder, StubRunning, StubTrigger

public class StubRunner extends Object implements StubRunning
Represents a single instance of ready-to-run stubs. Can run the stubs and then will return the name of the collaborator together with its URI. Can also be queried if the current groupid and artifactid are matching the corresponding running stub.
Author:
Marcin Grzejszczak
  • Constructor Details

  • Method Details

    • runStubs

      public RunningStubs runStubs()
      Specified by:
      runStubs in interface StubRunning
      Returns:
      runs the stubs and returns the RunningStubs. If the stubs were already started then a cached version will be returned.
    • findStubUrl

      public URL findStubUrl(String groupId, String artifactId)
      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 interface StubFinder
      Parameters:
      groupId - - might be null. In that case a search only via artifactId takes place
      artifactId - - 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: StubFinder
      For the given Ivy notation [groupId]:artifactId:[version]:[classifier] tries to find the matching URL of the running stub. You can also pass only artifactId.
      Specified by:
      findStubUrl in interface StubFinder
      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:
      findAllRunningStubs in interface StubFinder
      Returns:
      all running stubs
    • getContracts

      public Map<StubConfiguration,Collection<org.springframework.cloud.contract.spec.Contract>> getContracts()
      Specified by:
      getContracts in interface StubFinder
      Returns:
      the list of Contracts
    • trigger

      public boolean trigger(String ivyNotation, String labelName)
      Description copied from interface: StubTrigger
      Triggers an event by a given label for a given groupid:artifactid notation. You can use only artifactId too. Feature related to messaging.
      Specified by:
      trigger in interface StubTrigger
      Parameters:
      ivyNotation - ivy notation of a stub
      labelName - name of the label to trigger
      Returns:
      true - if managed to run a trigger
    • trigger

      public boolean trigger(String labelName)
      Description copied from interface: StubTrigger
      Triggers an event by a given label. Feature related to messaging.
      Specified by:
      trigger in interface StubTrigger
      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 interface StubTrigger
      Returns:
      true - if managed to run a trigger
    • labels

      public Map<String,Collection<String>> labels()
      Description copied from interface: StubTrigger
      Feature related to messaging.
      Specified by:
      labels in interface StubTrigger
      Returns:
      a mapping of ivy notation of a dependency to all the labels it has.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException