All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.approvaltests.JsonXstreamApprovals Maven / Gradle / Ivy

There is a newer version: 24.9.0
Show newest version
package org.approvaltests;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import org.approvaltests.core.Options;

/**
 * Requires (XStream)[https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream]
 * Requires (Jettison)[https://mvnrepository.com/artifact/org.codehaus.jettison/jettison]
 * Requires (Camel-XStream)[https://mvnrepository.com/artifact/org.apache.camel/camel-xstream]
 */
public class JsonXstreamApprovals
{
  public static void verifyAsJson(Object o)
  {
    verifyAsJson(o, new Options());
  }
  public static void verifyAsJson(Object o, Options options)
  {
    Approvals.verify(asJson(o), options.forFile().withExtension(".json"));
  }
  public static String asJson(Object o)
  {
    XStream xstream = new XStream(new JsonHierarchicalStreamDriver());
    return xstream.toXML(o);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy