congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JSONCompareResult.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.skyscreamer.jsonassert.JSONCompareResult
constructor

Best Java code snippets using org.skyscreamer.jsonassert.JSONCompareResult.<init> (Showing top 10 results out of 315)

origin: org.skyscreamer/jsonassert

/**
 * Compares JSONObject provided to the expected JSONObject, and returns the results of the comparison.
 *
 * @param expected Expected JSONObject
 * @param actual   JSONObject to compare
 * @throws JSONException JSON parsing error
 */
@Override
public final JSONCompareResult compareJSON(JSONObject expected, JSONObject actual) throws JSONException {
  JSONCompareResult result = new JSONCompareResult();
  compareJSON("", expected, actual, result);
  return result;
}
origin: org.skyscreamer/jsonassert

/**
 * Compares JSONArray provided to the expected JSONArray, and returns the results of the comparison.
 *
 * @param expected Expected JSONArray
 * @param actual   JSONArray to compare
 * @throws JSONException JSON parsing error
 */
@Override
public final JSONCompareResult compareJSON(JSONArray expected, JSONArray actual) throws JSONException {
  JSONCompareResult result = new JSONCompareResult();
  compareJSONArray("", expected, actual, result);
  return result;
}
origin: org.skyscreamer/jsonassert

/**
 * Compares {@link JSONString} provided to the expected {@code JSONString}, checking that the
 * {@link org.json.JSONString#toJSONString()} are equal.
 *
 * @param expected Expected {@code JSONstring}
 * @param actual   {@code JSONstring} to compare
 * @return result of the comparison
 */
public static JSONCompareResult compareJson(final JSONString expected, final JSONString actual) {
  final JSONCompareResult result = new JSONCompareResult();
  final String expectedJson = expected.toJSONString();
  final String actualJson = actual.toJSONString();
  if (!expectedJson.equals(actualJson)) {
   result.fail("");
  }
  return result;
}
origin: org.skyscreamer/jsonassert

/**
 * Compares JSON string provided to the expected JSON string using provided comparator, and returns the results of
 * the comparison.
 * @param expectedStr Expected JSON string
 * @param actualStr JSON string to compare
 * @param comparator Comparator to use
 * @return result of the comparison
 * @throws JSONException JSON parsing error
 * @throws IllegalArgumentException when type of expectedStr doesn't match the type of actualStr
 */
public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONComparator comparator)
    throws JSONException {
  Object expected = JSONParser.parseJSON(expectedStr);
  Object actual = JSONParser.parseJSON(actualStr);
  if ((expected instanceof JSONObject) && (actual instanceof JSONObject)) {
    return compareJSON((JSONObject) expected, (JSONObject) actual, comparator);
  }
  else if ((expected instanceof JSONArray) && (actual instanceof JSONArray)) {
    return compareJSON((JSONArray)expected, (JSONArray)actual, comparator);
  }
  else if (expected instanceof JSONString && actual instanceof JSONString) {
    return compareJson((JSONString) expected, (JSONString) actual);
  }
  else if (expected instanceof JSONObject) {
    return new JSONCompareResult().fail("", expected, actual);
  }
  else {
    return new JSONCompareResult().fail("", expected, actual);
  }
}
origin: skyscreamer/JSONassert

/**
 * Compares JSONObject provided to the expected JSONObject, and returns the results of the comparison.
 *
 * @param expected Expected JSONObject
 * @param actual   JSONObject to compare
 * @throws JSONException JSON parsing error
 */
@Override
public final JSONCompareResult compareJSON(JSONObject expected, JSONObject actual) throws JSONException {
  JSONCompareResult result = new JSONCompareResult();
  compareJSON("", expected, actual, result);
  return result;
}
origin: skyscreamer/JSONassert

/**
 * Compares JSONArray provided to the expected JSONArray, and returns the results of the comparison.
 *
 * @param expected Expected JSONArray
 * @param actual   JSONArray to compare
 * @throws JSONException JSON parsing error
 */
@Override
public final JSONCompareResult compareJSON(JSONArray expected, JSONArray actual) throws JSONException {
  JSONCompareResult result = new JSONCompareResult();
  compareJSONArray("", expected, actual, result);
  return result;
}
origin: skyscreamer/JSONassert

/**
 * Compares {@link JSONString} provided to the expected {@code JSONString}, checking that the
 * {@link org.json.JSONString#toJSONString()} are equal.
 *
 * @param expected Expected {@code JSONstring}
 * @param actual   {@code JSONstring} to compare
 * @return result of the comparison
 */
public static JSONCompareResult compareJson(final JSONString expected, final JSONString actual) {
  final JSONCompareResult result = new JSONCompareResult();
  final String expectedJson = expected.toJSONString();
  final String actualJson = actual.toJSONString();
  if (!expectedJson.equals(actualJson)) {
   result.fail("");
  }
  return result;
}
origin: skyscreamer/JSONassert

/**
 * Compares JSON string provided to the expected JSON string using provided comparator, and returns the results of
 * the comparison.
 * @param expectedStr Expected JSON string
 * @param actualStr JSON string to compare
 * @param comparator Comparator to use
 * @return result of the comparison
 * @throws JSONException JSON parsing error
 * @throws IllegalArgumentException when type of expectedStr doesn't match the type of actualStr
 */
public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONComparator comparator)
    throws JSONException {
  Object expected = JSONParser.parseJSON(expectedStr);
  Object actual = JSONParser.parseJSON(actualStr);
  if ((expected instanceof JSONObject) && (actual instanceof JSONObject)) {
    return compareJSON((JSONObject) expected, (JSONObject) actual, comparator);
  }
  else if ((expected instanceof JSONArray) && (actual instanceof JSONArray)) {
    return compareJSON((JSONArray)expected, (JSONArray)actual, comparator);
  }
  else if (expected instanceof JSONString && actual instanceof JSONString) {
    return compareJson((JSONString) expected, (JSONString) actual);
  }
  else if (expected instanceof JSONObject) {
    return new JSONCompareResult().fail("", expected, actual);
  }
  else {
    return new JSONCompareResult().fail("", expected, actual);
  }
}
origin: org.springframework.boot/spring-boot-test

private JSONCompareResult compareForNull(CharSequence expectedJson) {
  JSONCompareResult result = new JSONCompareResult();
  result.passed();
  if (expectedJson != null) {
    result.fail("Expected null JSON");
  }
  return result;
}
origin: qaprosoft/carina

JSONCompareResult tmpResult = new JSONCompareResult();
compareValues(prefix + "[" + i + "]", expectedValue, actualValue, tmpResult);
if (tmpResult.passed()) {
JSONCompareResult tmpResult = new JSONCompareResult();
super.compareJSON(prefix + "[" + i + "]", expectedValue, actValueMostlySimilar, tmpResult);
result.fail(tmpResult.getMessage());
org.skyscreamer.jsonassertJSONCompareResult<init>

Javadoc

Default constructor.

Popular methods of JSONCompareResult

  • getMessage
    Result message
  • failed
    Did the comparison fail?
  • passed
    Did the comparison pass?
  • fail
    Identify that the comparison failed
  • getFieldFailures
    Get the list of failures on field comparisons
  • missing
    Identify the missing field
  • unexpected
    Identify unexpected field
  • describe
  • formatFailureMessage
  • formatMissing
  • formatUnexpected
  • getFieldMissing
    Get the list of missed on field comparisons
  • formatUnexpected,
  • getFieldMissing,
  • getFieldUnexpected

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Collectors (java.util.stream)
  • Option (scala)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now