hamcrest-jackson

Hamcrest add-on to elegantly perform assertions on Json nodes

License

License

Categories

Categories

Jackson Data JSON
GroupId

GroupId

nl.fd
ArtifactId

ArtifactId

hamcrest-jackson
Last Version

Last Version

1.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

hamcrest-jackson
Hamcrest add-on to elegantly perform assertions on Json nodes
Project URL

Project URL

http://www.fdmediagroep.nl
Project Organization

Project Organization

FD Mediagroep
Source Code Management

Source Code Management

https://github.com/FDMediagroep/hamcrest-jackson

Download hamcrest-jackson

How to add to project

<!-- https://jarcasting.com/artifacts/nl.fd/hamcrest-jackson/ -->
<dependency>
    <groupId>nl.fd</groupId>
    <artifactId>hamcrest-jackson</artifactId>
    <version>1.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/nl.fd/hamcrest-jackson/
implementation 'nl.fd:hamcrest-jackson:1.0.5'
// https://jarcasting.com/artifacts/nl.fd/hamcrest-jackson/
implementation ("nl.fd:hamcrest-jackson:1.0.5")
'nl.fd:hamcrest-jackson:jar:1.0.5'
<dependency org="nl.fd" name="hamcrest-jackson" rev="1.0.5">
  <artifact name="hamcrest-jackson" type="jar" />
</dependency>
@Grapes(
@Grab(group='nl.fd', module='hamcrest-jackson', version='1.0.5')
)
libraryDependencies += "nl.fd" % "hamcrest-jackson" % "1.0.5"
[nl.fd/hamcrest-jackson "1.0.5"]

Dependencies

compile (2)

Group / Artifact Type Version
org.hamcrest : hamcrest-library jar 1.2
com.fasterxml.jackson.core : jackson-databind jar 2.0.5

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

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!

nl.fd

FDMediagroep

FD Mediagroep is de meest vooraanstaande nieuws- en informatiedienstverlener voor ondernemend Nederland.

Versions

Version
1.0.5