Codota Logo
JSONCompareResult.getMessage
Code IndexAdd Codota to your IDE (free)

How to use
getMessage
method
in
org.skyscreamer.jsonassert.JSONCompareResult

Best Java code snippets using org.skyscreamer.jsonassert.JSONCompareResult.getMessage (Showing top 20 results out of 315)

  • Common ways to obtain JSONCompareResult
private void myMethod () {
JSONCompareResult j =
  • Codota Iconnew JSONCompareResult()
  • Codota IconString expectedStr;String actualStr;JSONCompareMode mode;JSONCompare.compareJSON(expectedStr, actualStr, mode)
  • Smart code suggestions by Codota
}
origin: apache/geode

@Override
public boolean matches(Object item) {
 if (!(item instanceof String)) {
  ObjectMapper om = new ObjectMapper();
  try {
   item = om.writeValueAsString(item);
  } catch (JsonProcessingException e) {
   failureMessage = e.getMessage();
   return false;
  }
 }
 JSONCompareResult result;
 try {
  result = JSONCompare.compareJSON(expectedJson, item.toString(), JSONCompareMode.LENIENT);
 } catch (JSONException jex) {
  failureMessage = jex.getMessage();
  return false;
 }
 if (result != null && result.failed()) {
  failureMessage = result.getMessage();
 }
 return result != null && result.passed();
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the JSONArray provided matches the expected string.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
  throws JSONException {
  if (expectedStr==actualStr) return;
  if (expectedStr==null){
    throw new AssertionError("Expected string is null.");
  }else if (actualStr==null){
    throw new AssertionError("Actual string is null.");
  }
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, compareMode);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the JSONArray provided does not match the expected JSONArray.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONArray
 * @param actual JSONArray to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}

origin: org.skyscreamer/jsonassert

/**
 * Asserts that the json string provided does not match the expected string.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param comparator Comparator
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, comparator);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the JSONArray provided does not match the expected string.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, compareMode);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the JSONArray provided matches the expected JSONArray.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONArray
 * @param actual JSONArray to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the JSONObject provided matches the expected JSONObject.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONObject
 * @param actual JSONObject to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the json string provided matches the expected string.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param comparator Comparator
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, comparator);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.skyscreamer/jsonassert

/**
 * Asserts that the JSONObject provided does not match the expected JSONObject.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONObject
 * @param actual JSONObject to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: jamesdbloom/mockserver

public boolean matches(final HttpRequest context, String matched) {
  boolean result = false;
  JSONCompareResult jsonCompareResult;
  try {
    if (Strings.isNullOrEmpty(matcher)) {
      result = true;
    } else {
      JSONCompareMode jsonCompareMode = JSONCompareMode.LENIENT;
      if (matchType == MatchType.STRICT) {
        jsonCompareMode = JSONCompareMode.STRICT;
      }
      jsonCompareResult = compareJSON(matcher, matched, jsonCompareMode);
      if (jsonCompareResult.passed()) {
        result = true;
      }
      if (!result) {
        mockServerLogger.trace(context, "Failed to perform JSON match \"{}\" with \"{}\" because {}", matched, this.matcher, jsonCompareResult.getMessage());
      }
    }
  } catch (Exception e) {
    mockServerLogger.trace(context, "Failed to perform JSON match \"{}\" with \"{}\" because {}", matched, this.matcher, e.getMessage());
  }
  return not != result;
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the JSONArray provided matches the expected string.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
  throws JSONException {
  if (expectedStr==actualStr) return;
  if (expectedStr==null){
    throw new AssertionError("Expected string is null.");
  }else if (actualStr==null){
    throw new AssertionError("Actual string is null.");
  }
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, compareMode);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the json string provided matches the expected string.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param comparator Comparator
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, comparator);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the JSONObject provided does not match the expected JSONObject.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONObject
 * @param actual JSONObject to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the JSONArray provided matches the expected JSONArray.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONArray
 * @param actual JSONArray to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the JSONObject provided matches the expected JSONObject.  If it isn't it throws an
 * {@link AssertionError}.
 *
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONObject
 * @param actual JSONObject to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertEquals(String message, JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.failed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the json string provided does not match the expected string.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param comparator Comparator
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, comparator);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: skyscreamer/JSONassert

/**
 * Asserts that the JSONArray provided does not match the expected JSONArray.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expected Expected JSONArray
 * @param actual JSONArray to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}

origin: skyscreamer/JSONassert

/**
 * Asserts that the JSONArray provided does not match the expected string.  If it is it throws an
 * {@link AssertionError}.
 * 
 * @param message Error message to be displayed in case of assertion failure
 * @param expectedStr Expected JSON string
 * @param actualStr String to compare
 * @param compareMode Specifies which comparison mode to use
 * @throws JSONException JSON parsing error
 */
public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
  throws JSONException {
  JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, compareMode);
  if (result.passed()) {
    throw new AssertionError(getCombinedMessage(message, result.getMessage()));
  }
}
origin: org.springframework.boot/spring-boot-test

private JsonContentAssert assertNotPassed(JSONCompareResult result) {
  if (result.passed()) {
    throw new AssertionError("JSON Comparison failure: " + result.getMessage());
  }
  return this;
}
origin: org.springframework.boot/spring-boot-test

private JsonContentAssert assertNotFailed(JSONCompareResult result) {
  if (result.failed()) {
    throw new AssertionError("JSON Comparison failure: " + result.getMessage());
  }
  return this;
}
org.skyscreamer.jsonassertJSONCompareResultgetMessage

Javadoc

Result message

Popular methods of JSONCompareResult

  • failed
    Did the comparison fail?
  • passed
    Did the comparison pass?
  • fail
    Identify that the comparison failed
  • <init>
  • 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

  • Creating JSON documents from java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • runOnUiThread (Activity)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • String (java.lang)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now