public class JsonUnitResultMatchers extends Object
this.mockMvc.perform(get("/sample").accept(MediaType.APPLICATION_JSON)).andExpect(json().isEqualTo(CORRECT_JSON));
| Modifier and Type | Method and Description |
|---|---|
JsonUnitResultMatchers |
ignoring(String ignorePlaceholder)
Sets the placeholder that can be used to ignore values.
|
org.springframework.test.web.servlet.ResultMatcher |
isAbsent()
Fails if the node exists.
|
org.springframework.test.web.servlet.ResultMatcher |
isArray()
Fails if the selected JSON is not an Array or is not present.
|
org.springframework.test.web.servlet.ResultMatcher |
isEqualTo(Object expected)
Compares JSON for equality.
|
org.springframework.test.web.servlet.ResultMatcher |
isNotEqualTo(String expected)
Fails if compared documents are equal.
|
org.springframework.test.web.servlet.ResultMatcher |
isObject()
Fails if the selected JSON is not an Object or is not present.
|
org.springframework.test.web.servlet.ResultMatcher |
isPresent()
Fails if the node is missing.
|
org.springframework.test.web.servlet.ResultMatcher |
isString()
Fails if the selected JSON is not a String or is not present.
|
org.springframework.test.web.servlet.ResultMatcher |
isStringEqualTo(String expected)
Fails if the selected JSON is not a String or is not present or the value
is not equal to expected value.
|
static JsonUnitResultMatchers |
json()
Creates JsonUnitResultMatchers to be used for JSON assertions.
|
org.springframework.test.web.servlet.ResultMatcher |
matches(org.hamcrest.Matcher<?> matcher)
Matches the node using Hamcrest matcher.
|
JsonUnitResultMatchers |
node(String path)
Creates a matcher object that only compares given node.
|
JsonUnitResultMatchers |
when(Option firstOption,
Option... otherOptions)
Sets options changing comparison behavior.
|
JsonUnitResultMatchers |
withTolerance(BigDecimal tolerance)
Sets the tolerance for floating number comparison.
|
JsonUnitResultMatchers |
withTolerance(double tolerance)
Sets the tolerance for floating number comparison.
|
public static JsonUnitResultMatchers json()
public JsonUnitResultMatchers node(String path)
this.mockMvc.perform(get("/sample").accept(MediaType.APPLICATION_JSON)).andExpect(json().node("root.test[0]").isEqualTo("1"));
path - public org.springframework.test.web.servlet.ResultMatcher isEqualTo(Object expected)
isStringEqualTo(String).
If the string parameter is not a valid JSON, it is quoted automatically.expected - this object.isStringEqualTo(String)public org.springframework.test.web.servlet.ResultMatcher isStringEqualTo(String expected)
public org.springframework.test.web.servlet.ResultMatcher isNotEqualTo(String expected)
public org.springframework.test.web.servlet.ResultMatcher isAbsent()
public org.springframework.test.web.servlet.ResultMatcher isPresent()
public org.springframework.test.web.servlet.ResultMatcher isArray()
public org.springframework.test.web.servlet.ResultMatcher isObject()
public org.springframework.test.web.servlet.ResultMatcher isString()
public JsonUnitResultMatchers ignoring(String ignorePlaceholder)
public JsonUnitResultMatchers withTolerance(double tolerance)
public JsonUnitResultMatchers withTolerance(BigDecimal tolerance)
public JsonUnitResultMatchers when(Option firstOption, Option... otherOptions)
OptionOptionpublic org.springframework.test.web.servlet.ResultMatcher matches(org.hamcrest.Matcher<?> matcher)
matcher - Copyright © 2015. All Rights Reserved.