Skip to content

ReleaseNotes42

Johan Haleby edited this page Jan 17, 2020 · 6 revisions

Release Notes for REST Assured 4.2.0

Contents

  1. Highlights
  2. Minor Changes

Highlights

  • Introduced the spring-mock-mvc-kotlin-extensions project which allows a nicer experience for Kotlin developers using the spring-mock-mvc module. This allows one to write tests like this:

     class RestAssuredMockMvcKotlinExtensionsTest {
    
         @Test
         fun example() {
             val mockMvc =
                 MockMvcBuilders.standaloneSetup(GreetingController())
                     .build()
    
             val id: Int =
             Given {
                 mockMvc(mockMvc)
                 param("name", "Johan")
             } When {
                 get("/greeting")
             } Then {
                 body(
                     "id", Matchers.equalTo(1),
                     "content", Matchers.equalTo("Hello, Johan!")
                 )
             } Extract {
                 path("id")
             }
    
             assertThat(id).isEqualTo(1)
     }

    To use it depend on:

    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>spring-mock-mvc-kotlin-extensions</artifactId>
        <version>4.2.0</version>
        <scope>test</scope>
    </dependency>

    and import the extension functions from the io.restassured.module.mockmvc.kotlin.extensions package. Thanks to Myeonghyeon-Lee for pull request.

  • Added a new object mapper type that supports the Jakarta EE JSON Binding (JSON-B) specification. By default it will use Eclipse Yasson as the JSON-B implementation. To use it simply include

     <dependency>
         <groupId>org.eclipse</groupId>
         <artifactId>yasson</artifactId>
          <version>${yasson.version}</version>
     </dependency>

    in your classpath and then configure REST Assured to use it as its default ObjectMapperType:

     RestAssured.config = RestAssured.config.objectMapperConfig(ObjectMapperConfig.objectMapperConfig().defaultObjectMapperType(ObjectMapperType.JSONB));

    Thanks to Andrew Guibert for pull request.

  • Added ability to blacklist headers so that they are not shown in the request or response log. Instead the header value will be replaced with [ BLACKLISTED ]. You can enable this per header basis using the LogConfig:

     given().config(config().logConfig(logConfig().blacklistHeader("Accept"))). ..

    The response log will the print:

    Request method:	GET
    Request URI:    http://localhost:8080/something
    Proxy:          <none>
    Request params: <none>
    Query params:   <none>
    Form params:    <none>
    Path params:    <none>
    Headers:        Accept=[ BLACKLISTED ]
    Cookies:        <none>
    Multiparts:     <none>
    Body:           <none>
    

    Thanks to Simone Ivan Conte for the help and initial pull request.

Minor changes

See change log for more details.