Merge pull request #9675 from Mihhail Lapushkin
* gh-9675: Polish "Fix JsonContentAssert type safety warnings" Fix JsonContentAssert type safety warnings
This commit is contained in:
		
						commit
						a57a74157d
					
				| 
						 | 
				
			
			@ -26,12 +26,11 @@ import com.jayway.jsonpath.JsonPath;
 | 
			
		|||
import org.assertj.core.api.AbstractAssert;
 | 
			
		||||
import org.assertj.core.api.AbstractBooleanAssert;
 | 
			
		||||
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.Assert;
 | 
			
		||||
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.JSONCompareMode;
 | 
			
		||||
import org.skyscreamer.jsonassert.JSONCompareResult;
 | 
			
		||||
| 
						 | 
				
			
			@ -947,12 +946,13 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
 | 
			
		|||
	 * @param expression the {@link JsonPath} expression
 | 
			
		||||
	 * @param args arguments to parameterize the {@code JsonPath} expression with, using
 | 
			
		||||
	 * 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
 | 
			
		||||
	 * @throws AssertionError if the path is not valid or does not result in an array
 | 
			
		||||
	 */
 | 
			
		||||
	@SuppressWarnings("unchecked")
 | 
			
		||||
	public AbstractListAssert<?, ?, Object, ObjectAssert<Object>> extractingJsonPathArrayValue(
 | 
			
		||||
			CharSequence expression, Object... args) {
 | 
			
		||||
	public <E> ListAssert<E> extractingJsonPathArrayValue(CharSequence expression,
 | 
			
		||||
			Object... args) {
 | 
			
		||||
		return Assertions.assertThat(
 | 
			
		||||
				extractingJsonPathValue(expression, args, List.class, "an array"));
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -961,13 +961,15 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
 | 
			
		|||
	 * Extract the map value at the given JSON path for further object assertions.
 | 
			
		||||
	 * @param expression the {@link JsonPath} expression
 | 
			
		||||
	 * @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
 | 
			
		||||
	 * @throws AssertionError if the path is not valid or does not result in a map
 | 
			
		||||
	 */
 | 
			
		||||
	@SuppressWarnings("unchecked")
 | 
			
		||||
	public AbstractMapAssert<?, ?, Object, Object> extractingJsonPathMapValue(
 | 
			
		||||
			CharSequence expression, Object... args) {
 | 
			
		||||
	public <K, V> MapAssert<K, V> extractingJsonPathMapValue(CharSequence expression,
 | 
			
		||||
			Object... args) {
 | 
			
		||||
		return Assertions.assertThat(
 | 
			
		||||
				extractingJsonPathValue(expression, args, Map.class, "a map"));
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,6 +37,7 @@ import org.springframework.test.util.JsonPathExpectationsHelper;
 | 
			
		|||
import org.springframework.util.FileCopyUtils;
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -1252,7 +1253,7 @@ public class JsonContentAssertTests {
 | 
			
		|||
	@Test
 | 
			
		||||
	public void extractingJsonPathMapValue() throws Exception {
 | 
			
		||||
		assertThat(forJson(TYPES)).extractingJsonPathMapValue("@.colorMap")
 | 
			
		||||
				.containsEntry("red", "rojo");
 | 
			
		||||
				.contains(entry("red", "rojo"));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue