Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ee3525aa
Commit
ee3525aa
authored
Jul 21, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
536c3bbd
a57a7415
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
JsonContentAssert.java
...org/springframework/boot/test/json/JsonContentAssert.java
+10
-8
JsonContentAssertTests.java
...pringframework/boot/test/json/JsonContentAssertTests.java
+2
-1
No files found.
spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java
View file @
ee3525aa
...
@@ -26,12 +26,11 @@ import com.jayway.jsonpath.JsonPath;
...
@@ -26,12 +26,11 @@ import com.jayway.jsonpath.JsonPath;
import
org.assertj.core.api.AbstractAssert
;
import
org.assertj.core.api.AbstractAssert
;
import
org.assertj.core.api.AbstractBooleanAssert
;
import
org.assertj.core.api.AbstractBooleanAssert
;
import
org.assertj.core.api.AbstractCharSequenceAssert
;
import
org.assertj.core.api.AbstractCharSequenceAssert
;
import
org.assertj.core.api.AbstractListAssert
;
import
org.assertj.core.api.AbstractMapAssert
;
import
org.assertj.core.api.AbstractObjectAssert
;
import
org.assertj.core.api.AbstractObjectAssert
;
import
org.assertj.core.api.Assert
;
import
org.assertj.core.api.Assert
;
import
org.assertj.core.api.Assertions
;
import
org.assertj.core.api.Assertions
;
import
org.assertj.core.api.ObjectAssert
;
import
org.assertj.core.api.ListAssert
;
import
org.assertj.core.api.MapAssert
;
import
org.skyscreamer.jsonassert.JSONCompare
;
import
org.skyscreamer.jsonassert.JSONCompare
;
import
org.skyscreamer.jsonassert.JSONCompareMode
;
import
org.skyscreamer.jsonassert.JSONCompareMode
;
import
org.skyscreamer.jsonassert.JSONCompareResult
;
import
org.skyscreamer.jsonassert.JSONCompareResult
;
...
@@ -947,12 +946,13 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
...
@@ -947,12 +946,13 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
* @param expression the {@link JsonPath} expression
* @param expression the {@link JsonPath} expression
* @param args arguments to parameterize the {@code JsonPath} expression with, using
* @param args arguments to parameterize the {@code JsonPath} expression with, using
* formatting specifiers defined in {@link String#format(String, Object...)}
* formatting specifiers defined in {@link String#format(String, Object...)}
* @param <E> element type
* @return a new assertion object whose object under test is the extracted item
* @return a new assertion object whose object under test is the extracted item
* @throws AssertionError if the path is not valid or does not result in an array
* @throws AssertionError if the path is not valid or does not result in an array
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
AbstractListAssert
<?,
?,
Object
,
ObjectAssert
<
Object
>>
extractingJsonPathArrayValue
(
public
<
E
>
ListAssert
<
E
>
extractingJsonPathArrayValue
(
CharSequence
expression
,
CharSequence
expression
,
Object
...
args
)
{
Object
...
args
)
{
return
Assertions
.
assertThat
(
return
Assertions
.
assertThat
(
extractingJsonPathValue
(
expression
,
args
,
List
.
class
,
"an array"
));
extractingJsonPathValue
(
expression
,
args
,
List
.
class
,
"an array"
));
}
}
...
@@ -961,13 +961,15 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
...
@@ -961,13 +961,15 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
* Extract the map value at the given JSON path for further object assertions.
* Extract the map value at the given JSON path for further object assertions.
* @param expression the {@link JsonPath} expression
* @param expression the {@link JsonPath} expression
* @param args arguments to parameterize the {@code JsonPath} expression with, using
* @param args arguments to parameterize the {@code JsonPath} expression with, using
* formatting specifiers defined in {@link String#format(String, Object...)}
* @param <K> key type
* @param <V> value type formatting specifiers defined in
* {@link String#format(String, Object...)}
* @return a new assertion object whose object under test is the extracted item
* @return a new assertion object whose object under test is the extracted item
* @throws AssertionError if the path is not valid or does not result in a map
* @throws AssertionError if the path is not valid or does not result in a map
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
AbstractMapAssert
<?,
?,
Object
,
Object
>
extractingJsonPathMapValue
(
public
<
K
,
V
>
MapAssert
<
K
,
V
>
extractingJsonPathMapValue
(
CharSequence
expression
,
CharSequence
expression
,
Object
...
args
)
{
Object
...
args
)
{
return
Assertions
.
assertThat
(
return
Assertions
.
assertThat
(
extractingJsonPathValue
(
expression
,
args
,
Map
.
class
,
"a map"
));
extractingJsonPathValue
(
expression
,
args
,
Map
.
class
,
"a map"
));
}
}
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/json/JsonContentAssertTests.java
View file @
ee3525aa
...
@@ -37,6 +37,7 @@ import org.springframework.test.util.JsonPathExpectationsHelper;
...
@@ -37,6 +37,7 @@ import org.springframework.test.util.JsonPathExpectationsHelper;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.FileCopyUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
entry
;
/**
/**
* Tests for {@link JsonContentAssert}. Some tests here are based on Spring Framework
* Tests for {@link JsonContentAssert}. Some tests here are based on Spring Framework
...
@@ -1252,7 +1253,7 @@ public class JsonContentAssertTests {
...
@@ -1252,7 +1253,7 @@ public class JsonContentAssertTests {
@Test
@Test
public
void
extractingJsonPathMapValue
()
throws
Exception
{
public
void
extractingJsonPathMapValue
()
throws
Exception
{
assertThat
(
forJson
(
TYPES
)).
extractingJsonPathMapValue
(
"@.colorMap"
)
assertThat
(
forJson
(
TYPES
)).
extractingJsonPathMapValue
(
"@.colorMap"
)
.
contains
Entry
(
"red"
,
"rojo"
);
.
contains
(
entry
(
"red"
,
"rojo"
)
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment