Content-Type

The following assertions can be performed on both request and response variables offered by the Touchstone Rules-Engine.

They would validate the Content-Type header in the request or response.

  • assertContentTypeContains(expectedValue)

    • Asserts that the header ‘Content-Type’ contains the provided value

    • Example:

      response.assertContentTypeContains("xml")
      
    • Equivalent to these:

      assertContentTypeContains("xml", response)
      
      // expectedValue and operator can be passed as parameters from test script.
      assertContentType("xml", "contains", request)
      
      assert response.header("Content-Type").contains("json"): "The actual
         value \""+response.header('Content-Type')?.value +"\" did not contain
            the expected value \"json\" for 'Content-Type' header in response."
      

      Notice that the raw value of the ‘Content-Type’ header can be grabbed using:

      response.header('Content-Type')?.value
      
  • assertContentTypeNotContains(expectedValue)

    • Asserts that the header ‘Content-Type’ does not contain the provided value

    • Example:

      response.assertContentTypeNotContains("xml")
      
    • Equivalent to these:

      assertContentTypeNotContains("xml", response)
      
      // expectedValue and operator can be passed as parameters from test script.
      assertContentType("xml", "notContains", request)
      
      assert response.header("Content-Type").notContains("xml"): "The actual
         value \""+response.header('Content-Type')?.value +"\" contained the
            expected value \"xml\" for 'Content-Type' header with operator
               'notContains' in response."
      
  • assertContentTypeEquals(expectedValue)

    • Asserts that the value of header ‘Content-Type’ matches the provided value

    • Example:

      response.assertContentTypeEquals("application/fhir+json;charset=UTF-8")
      
    • Equivalent to these:

      assertContentTypeEquals("application/fhir+json;charset=UTF-8", response)
      
      // expectedValue and operator can be passed as parameters from test script.
      assertContentType("application/fhir+json;charset=UTF-8", "equals", request)
      
      assert response.header("Content-Type").equals("application/fhir+json;charset=UTF-8"): "The
         actual value \""+response.header('Content-Type')?.value +"\" did not match the
         expected value \"application/fhir+json;charset=UTF-8\" for 'Content-Type' header in response"
      
  • assertContentTypeNotEquals(expectedValue)

    • Asserts that the value of header ‘Content-Type’ does not match the provided value

    • Example:

      response.assertContentTypeNotEquals("application/fhir+xml")
      
    • Equivalent to these:

      assertContentTypeNotEquals("application/fhir+xml", response)
      
      // expectedValue and operator can be passed as parameters from test script.
      assertContentType("application/fhir+xml", "notEquals", request)
      
      assert response.header("Content-Type").notEquals("application/fhir+xml"): "The actual
         value \""+response.header('Content-Type')?.value +"\" matched the expected value
          \"application/fhir+xml\" for 'Content-Type' header with operator 'notEquals'
            in response."