Package org.skyscreamer.jsonassert.comparator

Examples of org.skyscreamer.jsonassert.comparator.CustomComparator


  }
 
  @Test
  public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9WithEvenMoreSimpliedExpectedString() throws JSONException {
     Customization innerCustomization = new Customization("a[1]", new ArrayValueMatcher<Object>(comparator, 0));
     JSONComparator comparator = new CustomComparator(JSONCompareMode.LENIENT, innerCustomization);
     Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 1));
     JSONAssert.assertEquals("{a:9}", ARRAY_OF_JSONARRAYS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
View Full Code Here


        }
    };

    @Test
    public void whenPathMatchesInCustomizationThenCallCustomMatcher() throws JSONException {
        JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("first", comparator));
        JSONCompareResult result = compareJSON(expected, actual, jsonCmp);
        assertTrue(result.getMessage(),  result.passed());
        assertEquals(1, comparatorCallCount);
    }
View Full Code Here

        assertEquals(1, comparatorCallCount);
    }

    @Test
    public void whenDeepPathMatchesCallCustomMatcher() throws JSONException {
        JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("outer.inner.value", comparator));
        JSONCompareResult result = compareJSON(deepExpected, deepActual, jsonCmp);
        assertTrue(result.getMessage(), result.passed());
        assertEquals(1, comparatorCallCount);
    }
View Full Code Here

  private static final String JSON_STRING_WITH_ARRAY = "{d:{results:[{__metadata:{uri:\"http://localhost:80/Person('1')\",type:Person},id:1}]}}";
  private static final String CONSTANT_URI_REGEX_EXPECTED_JSON = "{d:{results:[{__metadata:{uri:X}}]}}";

  private void doTest(String jsonPath, String regex, String expectedJSON,
      String actualJSON) throws JSONException {
    JSONAssert.assertEquals(expectedJSON, actualJSON, new CustomComparator(
        JSONCompareMode.STRICT_ORDER, new Customization(jsonPath,
            new RegularExpressionValueMatcher<Object>(regex))));
  }
View Full Code Here

        doTest(ARRAY_ELEMENT_PREFIX, null, "{d:{results:[{__metadata:{uri:\"http://localhost:80/Person\\\\('\\\\d+'\\\\)\"}}]}}", JSON_STRING_WITH_ARRAY);
    }

    @Test
    public void dynamicRegexMatchesStringAttributeInsideArrayWithNoArgConstructor() throws JSONException {
    JSONAssert.assertEquals("{d:{results:[{__metadata:{uri:\"http://localhost:80/Person\\\\('\\\\d+'\\\\)\"}}]}}", JSON_STRING_WITH_ARRAY, new CustomComparator(
        JSONCompareMode.STRICT_ORDER, new Customization(ARRAY_ELEMENT_PREFIX,
            new RegularExpressionValueMatcher<Object>())));
    }
View Full Code Here

TOP

Related Classes of org.skyscreamer.jsonassert.comparator.CustomComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.