Class JsonSourceManagerFactory

java.lang.Object
de.ppi.deepsampler.junit.json.JsonSourceManagerFactory
All Implemented Interfaces:
de.ppi.deepsampler.junit.SourceManagerFactory<de.ppi.deepsampler.persistence.json.JsonSourceManager>

public class JsonSourceManagerFactory
extends java.lang.Object
implements de.ppi.deepsampler.junit.SourceManagerFactory<de.ppi.deepsampler.persistence.json.JsonSourceManager>
JsonSourceManagerFactory creates and configures a JsonSourceManager. It is used by the annotations LoadSamples and SaveSamples, to configure the usage of JSON for recording and loading of samples. Tests, that want to use json-files to load and record samples, may use the following annotations to configure the JsonSourceManager:
  • LoadSamples loads a json-file before a test method is started
  • SaveSamples records all calls to stubbed methods during a test and saves the recorded samples as a json-file after the test has finished
  • UseJsonDeserializer registers a custom JsonDeserializer that is used by Jackson (the underlying json-api) to load objects, that cannot be loaded by default
  • UseJsonSerializer registers a custom JsonSerializer that is used by Jackson (the underlying json-api) to save objects, that cannot be saved by default
  • SampleRootPath defines the root path under which Json-files are saved.
  • UseCharset defines the Charset that is used to write and read the Json-files
  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.lang.String DEFAULT_ROOT_PATH  
  • Constructor Summary

    Constructors
    Constructor Description
    JsonSourceManagerFactory()  
  • Method Summary

    Modifier and Type Method Description
    de.ppi.deepsampler.persistence.json.JsonSourceManager createSourceManagerToLoadSamples​(java.lang.reflect.Method testMethod)  
    de.ppi.deepsampler.persistence.json.JsonSourceManager createSourceManagerToSaveSamples​(java.lang.reflect.Method testMethod)  
    java.lang.String getDefaultJsonFileName​(java.lang.reflect.Method testMethod)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_ROOT_PATH

      public static final java.lang.String DEFAULT_ROOT_PATH
      See Also:
      Constant Field Values
  • Constructor Details

    • JsonSourceManagerFactory

      public JsonSourceManagerFactory()
  • Method Details

    • createSourceManagerToLoadSamples

      public de.ppi.deepsampler.persistence.json.JsonSourceManager createSourceManagerToLoadSamples​(java.lang.reflect.Method testMethod)
      Specified by:
      createSourceManagerToLoadSamples in interface de.ppi.deepsampler.junit.SourceManagerFactory<de.ppi.deepsampler.persistence.json.JsonSourceManager>
    • createSourceManagerToSaveSamples

      public de.ppi.deepsampler.persistence.json.JsonSourceManager createSourceManagerToSaveSamples​(java.lang.reflect.Method testMethod)
      Specified by:
      createSourceManagerToSaveSamples in interface de.ppi.deepsampler.junit.SourceManagerFactory<de.ppi.deepsampler.persistence.json.JsonSourceManager>
    • getDefaultJsonFileName

      public java.lang.String getDefaultJsonFileName​(java.lang.reflect.Method testMethod)