Commit f6727e78 authored by Andy Wilkinson's avatar Andy Wilkinson

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
parent ae91c846
...@@ -951,8 +951,8 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -951,8 +951,8 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
* @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 <E> ListAssert<E> 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"));
} }
...@@ -962,14 +962,14 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -962,14 +962,14 @@ 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
* @param <K> key type * @param <K> key type
* @param <V> value type * @param <V> value type formatting specifiers defined in
* formatting specifiers defined in {@link String#format(String, Object...)} * {@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 <K, V> MapAssert<K, V> 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"));
} }
......
...@@ -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")
.containsEntry("red", "rojo"); .contains(entry("red", "rojo"));
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment