title: Kotlin how to create custom assertion with assertj
body: <p>I'd like to create custom assertion in the same file of my test code.</p>
  
  <p>What I did is</p>
  
  <pre><code>fun String?.isValidJson(): Boolean {
      try {
          JSONObject(this)
      } catch (ex: JSONException) {
          // e.g. in case JSONArray is valid as well...
          try {
              JSONArray(this)
          } catch (ex1: JSONException) {
              return false
          }
      }
      return true
  }
  
  @Test
  fun `Check body is valid json`() {
      // ...
      assertThat(entity.body.isValidJson()).isTrue()
  }
  </code></pre>
  
  <p>However, it look not professional and I want to customize my own assertion:</p>
  
  <pre><code>assertThat(entity.body).isValidJson()
  </code></pre>
  
  <p>I tried in many ways with helps of IntelliJ, but it all failed.
  Could anyone can create this?</p>
  
  <p>This is automatically generated function by IntelliJ which not works:</p>
  
  <pre><code>private fun &lt;SELF, ACTUAL&gt; AbstractCharSequenceAssert&lt;SELF, ACTUAL&gt;.isValidJson() {
      TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
  }
  </code></pre>