@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 201 8 the original author or authors .
* Copyright 2012 - 201 9 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -26,7 +26,6 @@ import java.io.Reader;
import java.io.StringReader ;
import java.lang.reflect.Field ;
import com.jayway.jsonpath.Configuration ;
import org.assertj.core.api.Assertions ;
import org.springframework.beans.factory.ObjectFactory ;
@ -73,8 +72,6 @@ public abstract class AbstractJsonMarshalTester<T> {
private ResolvableType type ;
private Configuration configuration ;
/ * *
* Create a new uninitialized { @link AbstractJsonMarshalTester } instance .
* /
@ -88,22 +85,9 @@ public abstract class AbstractJsonMarshalTester<T> {
* @param type the type under test
* /
public AbstractJsonMarshalTester ( Class < ? > resourceLoadClass , ResolvableType type ) {
this ( resourceLoadClass , type , Configuration . defaultConfiguration ( ) ) ;
}
/ * *
* Create a new { @link AbstractJsonMarshalTester } instance .
* @param resourceLoadClass the source class used when loading relative classpath
* resources
* @param type the type under test
* @param configuration the json - path configuration
* /
public AbstractJsonMarshalTester ( Class < ? > resourceLoadClass , ResolvableType type ,
Configuration configuration ) {
Assert . notNull ( resourceLoadClass , "ResourceLoadClass must not be null" ) ;
Assert . notNull ( type , "Type must not be null" ) ;
Assert . notNull ( configuration , "Configuration must not be null" ) ;
initialize ( resourceLoadClass , type , configuration ) ;
initialize ( resourceLoadClass , type ) ;
}
/ * *
@ -113,23 +97,9 @@ public abstract class AbstractJsonMarshalTester<T> {
* @param type the type under test
* /
protected final void initialize ( Class < ? > resourceLoadClass , ResolvableType type ) {
initialize ( resourceLoadClass , type , Configuration . defaultConfiguration ( ) ) ;
}
/ * *
* Initialize the marshal tester for use .
* @param resourceLoadClass the source class used when loading relative classpath
* resources
* @param type the type under test
* @param configuration the json - path configuration
* /
protected final void initialize ( Class < ? > resourceLoadClass , ResolvableType type ,
Configuration configuration ) {
if ( this . resourceLoadClass = = null & & this . type = = null
& & this . configuration = = null ) {
if ( this . resourceLoadClass = = null & & this . type = = null ) {
this . resourceLoadClass = resourceLoadClass ;
this . type = type ;
this . configuration = configuration ;
}
}
@ -159,8 +129,18 @@ public abstract class AbstractJsonMarshalTester<T> {
verify ( ) ;
Assert . notNull ( value , "Value must not be null" ) ;
String json = writeObject ( value , this . type ) ;
return new JsonContent < > ( this . resourceLoadClass , this . type , json ,
this . configuration ) ;
return getJsonContent ( json ) ;
}
/ * *
* Factory method used to get a { @link JsonContent } instance from a source JSON
* string .
* @param json the source JSON
* @return a new { @link JsonContent } instance
* @since 2.1 .5
* /
protected JsonContent < T > getJsonContent ( String json ) {
return new JsonContent < > ( getResourceLoadClass ( ) , getType ( ) , json ) ;
}
/ * *