Skip to content

Commit ee3525a

Browse files
committed
Merge branch '1.5.x'
2 parents 536c3bb + a57a741 commit ee3525a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
import org.assertj.core.api.AbstractAssert;
2727
import org.assertj.core.api.AbstractBooleanAssert;
2828
import org.assertj.core.api.AbstractCharSequenceAssert;
29-
import org.assertj.core.api.AbstractListAssert;
30-
import org.assertj.core.api.AbstractMapAssert;
3129
import org.assertj.core.api.AbstractObjectAssert;
3230
import org.assertj.core.api.Assert;
3331
import org.assertj.core.api.Assertions;
34-
import org.assertj.core.api.ObjectAssert;
32+
import org.assertj.core.api.ListAssert;
33+
import org.assertj.core.api.MapAssert;
3534
import org.skyscreamer.jsonassert.JSONCompare;
3635
import org.skyscreamer.jsonassert.JSONCompareMode;
3736
import org.skyscreamer.jsonassert.JSONCompareResult;
@@ -947,12 +946,13 @@ public AbstractBooleanAssert<?> extractingJsonPathBooleanValue(
947946
* @param expression the {@link JsonPath} expression
948947
* @param args arguments to parameterize the {@code JsonPath} expression with, using
949948
* formatting specifiers defined in {@link String#format(String, Object...)}
949+
* @param <E> element type
950950
* @return a new assertion object whose object under test is the extracted item
951951
* @throws AssertionError if the path is not valid or does not result in an array
952952
*/
953953
@SuppressWarnings("unchecked")
954-
public AbstractListAssert<?, ?, Object, ObjectAssert<Object>> extractingJsonPathArrayValue(
955-
CharSequence expression, Object... args) {
954+
public <E> ListAssert<E> extractingJsonPathArrayValue(CharSequence expression,
955+
Object... args) {
956956
return Assertions.assertThat(
957957
extractingJsonPathValue(expression, args, List.class, "an array"));
958958
}
@@ -961,13 +961,15 @@ public AbstractBooleanAssert<?> extractingJsonPathBooleanValue(
961961
* Extract the map value at the given JSON path for further object assertions.
962962
* @param expression the {@link JsonPath} expression
963963
* @param args arguments to parameterize the {@code JsonPath} expression with, using
964-
* formatting specifiers defined in {@link String#format(String, Object...)}
964+
* @param <K> key type
965+
* @param <V> value type formatting specifiers defined in
966+
* {@link String#format(String, Object...)}
965967
* @return a new assertion object whose object under test is the extracted item
966968
* @throws AssertionError if the path is not valid or does not result in a map
967969
*/
968970
@SuppressWarnings("unchecked")
969-
public AbstractMapAssert<?, ?, Object, Object> extractingJsonPathMapValue(
970-
CharSequence expression, Object... args) {
971+
public <K, V> MapAssert<K, V> extractingJsonPathMapValue(CharSequence expression,
972+
Object... args) {
971973
return Assertions.assertThat(
972974
extractingJsonPathValue(expression, args, Map.class, "a map"));
973975
}

spring-boot-test/src/test/java/org/springframework/boot/test/json/JsonContentAssertTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.util.FileCopyUtils;
3838

3939
import static org.assertj.core.api.Assertions.assertThat;
40+
import static org.assertj.core.api.Assertions.entry;
4041

4142
/**
4243
* Tests for {@link JsonContentAssert}. Some tests here are based on Spring Framework
@@ -1252,7 +1253,7 @@ public void extractingJsonPathArrayValueForWrongType() throws Exception {
12521253
@Test
12531254
public void extractingJsonPathMapValue() throws Exception {
12541255
assertThat(forJson(TYPES)).extractingJsonPathMapValue("@.colorMap")
1255-
.containsEntry("red", "rojo");
1256+
.contains(entry("red", "rojo"));
12561257
}
12571258

12581259
@Test

0 commit comments

Comments
 (0)