Class Mock


  • public final class Mock
    extends Object
    Provides static methods for constructing MockResponse objects.
    Since:
    1.0.0
    • Method Detail

      • ofAll

        public static List<okhttp3.mockwebserver.MockResponse> ofAll​(String... responseBodies)
        Parameters:
        responseBodies - All response bodies to create MockResponses for.
        Returns:
        Multiple MockResponses that can be provided to the MockWebServer.
      • of

        public static okhttp3.mockwebserver.MockResponse of​(String body)
        Parameters:
        body - The literal content to add to the response.
        Returns:
        The MockResponse that can be provided to the MockWebServer.
      • of

        public static okhttp3.mockwebserver.MockResponse of​(String value,
                                                            ContentLoader loader)
                                                     throws IOException
        Parameters:
        value - The string to load via the provided ContentLoader.
        loader - An implementation to load the body from the given value.
        Returns:
        The MockResponse that can be provided to the MockWebServer.
        Throws:
        IOException - If an exception occurs while loading the content.
      • of

        public static okhttp3.mockwebserver.MockResponse of​(String value,
                                                            int responseCode,
                                                            ContentLoader loader)
                                                     throws IOException
        Parameters:
        value - The string to load via the provided ContentLoader.
        responseCode - The response code of the response.
        loader - An implementation to load the body from the given value.
        Returns:
        The MockResponse that can be provided to the MockWebServer.
        Throws:
        IOException - If an exception occurs while loading the content.
      • of

        public static okhttp3.mockwebserver.MockResponse of​(String body,
                                                            int responseCode)
        Parameters:
        body - The literal content to add to the response.
        responseCode - The response code of the response.
        Returns:
        The MockResponse that can be provided to the MockWebServer.