Class Invocation

java.lang.Object
kong.unirest.core.Invocation
All Implemented Interfaces:
Expectation

class Invocation extends Object implements Expectation
  • Field Details

  • Constructor Details

    • Invocation

      public Invocation(Routes routes)
    • Invocation

      public Invocation(Routes routes, HttpRequest request)
    • Invocation

      Invocation(Routes routes, Invocation other)
    • Invocation

      Invocation()
  • Method Details

    • thenReturn

      public ExpectedResponse thenReturn(String body)
      Description copied from interface: Expectation
      expect a string response
      Specified by:
      thenReturn in interface Expectation
      Parameters:
      body - the expected response body
      Returns:
      The ExpectedResponse
    • thenReturn

      public ExpectedResponse thenReturn(JSONElement jsonObject)
      Description copied from interface: Expectation
      expect a json response
      Specified by:
      thenReturn in interface Expectation
      Parameters:
      jsonObject - the expected response body
      Returns:
      The ExpectedResponse
    • thenReturn

      public ExpectedResponse thenReturn(Object pojo)
      Description copied from interface: Expectation
      expect a object response as defined by a pojo using the requests / configuration object mapper
      Specified by:
      thenReturn in interface Expectation
      Parameters:
      pojo - the expected response body
      Returns:
      The ExpectedResponse
    • thenReturn

      public ExpectedResponse thenReturn(Supplier<String> supplier)
      Description copied from interface: Expectation
      A supplier for the expected body which will get invoked at the time of build the response.
      Specified by:
      thenReturn in interface Expectation
      Parameters:
      supplier - the expected response body supplier
      Returns:
      The ExpectedResponse
    • thenReturn

      public void thenReturn(Function<HttpRequest<?>,ExpectedResponse> fun)
      Description copied from interface: Expectation
      Allows for a full override of the way a expected response is built. useful in building more complicated test-doubles of services that implement logic
      Specified by:
      thenReturn in interface Expectation
      Parameters:
      fun - the function to convert a request to a response
    • getResponse

      RawResponse getResponse(Config config, HttpRequest request)
    • allHeaders

      private Headers allHeaders()
    • log

      public void log(HttpRequest request)
    • header

      public Expectation header(String key, String value)
      Description copied from interface: Expectation
      A expected header for a request
      Specified by:
      header in interface Expectation
      Parameters:
      key - the header key
      value - the header value
      Returns:
      this Expectation
    • queryString

      public Expectation queryString(String key, String value)
      Description copied from interface: Expectation
      A expected header for a request
      Specified by:
      queryString in interface Expectation
      Parameters:
      key - the query key
      value - the query value
      Returns:
      this Expectation
    • body

      public Expectation body(String body)
      Description copied from interface: Expectation
      A expected body for a request
      Specified by:
      body in interface Expectation
      Parameters:
      body - the expected body
      Returns:
      this Expectation
    • body

      public Expectation body(BodyMatcher matcher)
      Description copied from interface: Expectation
      A matcher for the body for a request
      Specified by:
      body in interface Expectation
      Parameters:
      matcher - the matcher
      Returns:
      this Expectation
    • thenReturn

      public ExpectedResponse thenReturn()
      Description copied from interface: Expectation
      expect a null response
      Specified by:
      thenReturn in interface Expectation
      Returns:
      The ExpectedResponse
    • verify

      public void verify()
      Description copied from interface: Expectation
      verify that all Expectations was fulfilled at least once.
      Specified by:
      verify in interface Expectation
    • verify

      public void verify(Times times)
      Specified by:
      verify in interface Expectation
    • times

      public Expectation times(Times times)
      Specified by:
      times in interface Expectation
    • details

      private String details()
    • hasExpectedHeader

      public boolean hasExpectedHeader(String key, String value)
    • getBodyStream

      private Stream<Body> getBodyStream()
    • hasBody

      public boolean hasBody(String body)
    • uniBodyMatches

      private boolean uniBodyMatches(String body, Body o)
    • hasField

      public boolean hasField(String name, String value)
    • hasField

      private boolean hasField(String name, String value, Body b)
    • requestSize

      public Integer requestSize()
    • getRequests

      public List<HttpRequest> getRequests()
    • isExpected

      public Boolean isExpected()
    • scoreMatch

      public Integer scoreMatch(HttpRequest request)
    • scoreBody

      private int scoreBody(HttpRequest request)
    • matchBody

      private Integer matchBody(Body b)
    • scoreHeaders

      private int scoreHeaders(HttpRequest request)
    • scoreQuery

      private int scoreQuery(HttpRequest request)
    • tryCast

      private static <T, M extends T> Optional<M> tryCast(T original, Class<M> too)