title: Testing Micronaut POST Request without hitting the URL - Mocking - Kotlin
body: <p>I would like to Unit Test my Kotlin class, which makes a POST request using micronaut's RxHttpClient.</p>
  
  <p>The code I want to test (simplified):</p>
  
  <pre><code>fun makePost() {
      val httpRequest = HttpRequest.POST&lt;Any&gt;(uri, json).contentType(MediaType.APPLICATION_JSON)
      return httpClient.exchange(httpRequest, String::class.java)
          .singleOrError()
          .map { response -&gt;
              println("Success")
          }.doOnError { error -&gt;
              println("Error"))
          }
  }
  </code></pre>
  
  <p>I don't want it to hit the actual url of the post, I'm looking for a way to "mock" the response.</p>
  
  <p>I already tried to use mock-server and mocking the HttpClient using mockito, without success.</p>
  
  <p>Can someone help me, or give me any advice about what should I do?
  Thanks</p>