Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

FDMediagroep/hamcrest-jackson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hamcrest-jackson All Contributors

The Hamcrest Jackson library provides a set of matchers for Json node elements.

How to use hamcrest-jackson in your project:

  • Clone this project
  • Build it using maven clean install
  • Add it to your dependencies using
<dependency>
    <groupId>nl.fd</groupId>
      <artifactId>hamcrest-jackson</artifactId>
      <version>1.0.6-SNAPSHOT</version>
</dependency>

Example Usage

Here we provide a code sample to give you a rough idea how easy to use this library is.

JsonNode queryNode = mapper.readTree(someQueryBuilder.toString());
assertThat(queryNode,
    hasJsonField("function_score",
        hasJsonField("query", isJsonText("apple annual figures")),
        hasJsonField("fields",isJsonArray("title", "content"))
    )
);

Matchers

The following matchers are provided:

  • HasJsonField Matcher for checking if an object has a JSON field.
    • hasJsonField
  • IsJsonArray Matcher for checking if an object is a JSON array.
    • isJsonArray
  • IsJsonBoolean Matcher for checking if an object is a JSON boolean.
    • isJsonBoolean
  • IsJsonInt Matcher for checking if an object is a JSON integer.
    • isJsonInt
  • IsJsonText Matcher for checking if an object is a JSON integer.
    • isJsonText

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Joram Hannema
Joram Hannema

💻 📖 🚧
Jeroen M Snoeij
Jeroen M Snoeij

💻 📖 🚧
Quinten Krijger
Quinten Krijger

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!