Java Code Examples for org.skyscreamer.jsonassert.JSONAssert#assertNotEquals()
The following examples show how to use
org.skyscreamer.jsonassert.JSONAssert#assertNotEquals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonAssertUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void whenUsingCompareModeOrBoolean_thenBothAreSame() throws JSONException { String actual = "{id:123,name:\"John\",zip:\"33025\"}"; JSONAssert.assertEquals("{id:123,name:\"John\"}", actual, JSONCompareMode.LENIENT); JSONAssert.assertEquals("{id:123,name:\"John\"}", actual, false); actual = "{id:123,name:\"John\"}"; JSONAssert.assertNotEquals("{name:\"John\"}", actual, JSONCompareMode.STRICT); JSONAssert.assertNotEquals("{name:\"John\"}", actual, true); }
Example 2
Source File: JsonAssertUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenArray_whenComparing_thenOrderMustMatchForStrict() throws JSONException { String result = "[Alex, Barbera, Charlie, Wolf]"; JSONAssert.assertEquals("[Charlie, Alex, Wolf, Barbera]", result, JSONCompareMode.LENIENT); JSONAssert.assertEquals("[Alex, Barbera, Charlie, Wolf]", result, JSONCompareMode.STRICT); JSONAssert.assertNotEquals("[Charlie, Alex, Wolf, Barbera]", result, JSONCompareMode.STRICT); }
Example 3
Source File: JsonAssertUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenArray_whenComparingExtended_thenNotEqual() throws JSONException { String result = "[1,2,3,4,5]"; JSONAssert.assertEquals("[1,2,3,4,5]", result, JSONCompareMode.LENIENT); JSONAssert.assertNotEquals("[1,2,3]", result, JSONCompareMode.LENIENT); JSONAssert.assertNotEquals("[1,2,3,4,5,6]", result, JSONCompareMode.LENIENT); }
Example 4
Source File: JsonAssertUnitTest.java From tutorials with MIT License | 4 votes |
@Test public void givenStrictMode_whenAssertNotEqualsExtendedJsonString_thenPass() throws JSONException { String actual = "{id:123,name:\"John\"}"; JSONAssert.assertNotEquals("{name:\"John\"}", actual, JSONCompareMode.STRICT); }
Example 5
Source File: JsonAssertUnitTest.java From tutorials with MIT License | 4 votes |
@Test public void givenValueMatcher_whenComparingUsingRegex_thenPass() throws IllegalArgumentException, JSONException { JSONAssert.assertEquals("{entry:{id:x}}", "{entry:{id:1, id:2}}", new CustomComparator(JSONCompareMode.STRICT, new Customization("entry.id", new RegularExpressionValueMatcher<Object>("\\d")))); JSONAssert.assertNotEquals("{entry:{id:x}}", "{entry:{id:1, id:as}}", new CustomComparator(JSONCompareMode.STRICT, new Customization("entry.id", new RegularExpressionValueMatcher<Object>("\\d")))); }
Example 6
Source File: JsonExpectationsHelper.java From spring-analysis-note with MIT License | 2 votes |
/** * Parse the expected and actual strings as JSON and assert the two * are "not similar" - i.e. they contain different attribute-value pairs * regardless of formatting. * <p>Can compare in two modes, depending on {@code strict} parameter value: * <ul> * <li>{@code true}: strict checking. Not extensible, and strict array ordering.</li> * <li>{@code false}: lenient checking. Extensible, and non-strict array ordering.</li> * </ul> * @param expected the expected JSON content * @param actual the actual JSON content * @param strict enables strict checking * @since 4.2 */ public void assertJsonNotEqual(String expected, String actual, boolean strict) throws Exception { JSONAssert.assertNotEquals(expected, actual, strict); }
Example 7
Source File: JsonExpectationsHelper.java From java-technology-stack with MIT License | 2 votes |
/** * Parse the expected and actual strings as JSON and assert the two * are "not similar" - i.e. they contain different attribute-value pairs * regardless of formatting. * <p>Can compare in two modes, depending on {@code strict} parameter value: * <ul> * <li>{@code true}: strict checking. Not extensible, and strict array ordering.</li> * <li>{@code false}: lenient checking. Extensible, and non-strict array ordering.</li> * </ul> * @param expected the expected JSON content * @param actual the actual JSON content * @param strict enables strict checking * @since 4.2 */ public void assertJsonNotEqual(String expected, String actual, boolean strict) throws Exception { JSONAssert.assertNotEquals(expected, actual, strict); }
Example 8
Source File: JsonExpectationsHelper.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Parse the expected and actual strings as JSON and assert the two * are "not similar" - i.e. they contain different attribute-value pairs * regardless of formatting. * * <p>Can compare in two modes, depending on {@code strict} parameter value: * <ul> * <li>{@code true}: strict checking. Not extensible, and strict array ordering.</li> * <li>{@code false}: lenient checking. Extensible, and non-strict array ordering.</li> * </ul> * * @param expected the expected JSON content * @param actual the actual JSON content * @param strict enables strict checking * @since 4.2 */ public void assertJsonNotEqual(String expected, String actual, boolean strict) throws Exception { JSONAssert.assertNotEquals(expected, actual, strict); }
Example 9
Source File: MobileMessagingBaseTestCase.java From mobile-messaging-sdk-android with Apache License 2.0 | 2 votes |
/** * Asserts that two objects are not strictly the same using JSONAssert and JSON serialization * * @param expected expected object * @param actual actual object * @throws Exception if serialization or assertion fails */ protected <T> void assertJNotEquals(T expected, T actual) throws Exception { JSONAssert.assertNotEquals(gson.toJson(expected), gson.toJson(actual), true); }