Class AbstractTest

    • Constructor Detail

      • AbstractTest

        public AbstractTest()
    • Method Detail

      • respondWith

        protected void respondWith​(String resource)
                            throws IOException
        Responds with success status code and body from json resource file
        Parameters:
        resource - the json resource file
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • respondWith

        protected void respondWith​(int statusCode)
        Responds with specified status code and no body
        Parameters:
        statusCode - the status code to respond with
      • respondWith

        protected void respondWith​(Map<String,​String> headers,
                                   int statusCode)
        Responds with specified status code, no body and optional headers
        Parameters:
        headers - optional headers
        statusCode - the status code to respond with
      • respondWith

        protected void respondWith​(int statusCode,
                                   String jsonBody)
        Responds with specified status code and json body
        Parameters:
        statusCode - the status code to respond with
        jsonBody - the json body
      • respondWith

        protected void respondWith​(Map<String,​String> headers,
                                   int statusCode,
                                   String body)
        Responds with specified status code, body and optional headers
        Parameters:
        headers - optional headers
        statusCode - the status code to respond with
        body - the response body
      • respondWithHeaderAndResource

        protected void respondWithHeaderAndResource​(Map<String,​String> headers,
                                                    int statusCode,
                                                    String resource)
                                             throws IOException
        Responds with given header, status code, body from json resource file.
        Parameters:
        headers - the specified header
        statusCode - the status code to respond with
        resource - the json resource file
        Throws:
        IOException - Signals that an I/O exception has occurred
      • respondWithCodeAndResource

        protected void respondWithCodeAndResource​(int statusCode,
                                                  String resource)
                                           throws IOException
        Throws:
        IOException
      • takeRequest

        protected okhttp3.mockwebserver.RecordedRequest takeRequest()
                                                             throws InterruptedException
        Awaits, removes and returns the next request made to the mock server. Callers should use this to verify the request was sent as intended. This method will block until the request is available, possibly forever.
        Be aware that this method will catch all the previous requests made to the mock server, also from other previous tests! Make sure to take all the requests made by methods in the same test class.
        Returns:
        the head of the request queue
        Throws:
        InterruptedException
      • afterTest

        @AfterClass(alwaysRun=true)
        protected void afterTest()