Skip to content

Commit f6727e7

Browse files
committed
Polish "Fix JsonContentAssert type safety warnings"
- Format code - Update an existing test to use the contains method that would previously have triggered a type safety warning Closes gh-9675
1 parent ae91c84 commit f6727e7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,8 @@ public AbstractBooleanAssert<?> extractingJsonPathBooleanValue(
951951
* @throws AssertionError if the path is not valid or does not result in an array
952952
*/
953953
@SuppressWarnings("unchecked")
954-
public <E> ListAssert<E> 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
}
@@ -962,14 +962,14 @@ public <E> ListAssert<E> extractingJsonPathArrayValue(
962962
* @param expression the {@link JsonPath} expression
963963
* @param args arguments to parameterize the {@code JsonPath} expression with, using
964964
* @param <K> key type
965-
* @param <V> value type
966-
* formatting specifiers defined in {@link String#format(String, Object...)}
965+
* @param <V> value type formatting specifiers defined in
966+
* {@link String#format(String, Object...)}
967967
* @return a new assertion object whose object under test is the extracted item
968968
* @throws AssertionError if the path is not valid or does not result in a map
969969
*/
970970
@SuppressWarnings("unchecked")
971-
public <K, V> MapAssert<K, V> extractingJsonPathMapValue(
972-
CharSequence expression, Object... args) {
971+
public <K, V> MapAssert<K, V> extractingJsonPathMapValue(CharSequence expression,
972+
Object... args) {
973973
return Assertions.assertThat(
974974
extractingJsonPathValue(expression, args, Map.class, "a map"));
975975
}

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)