Package org.skyscreamer.jsonassert.comparator

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator


    doTest("a", new ArrayValueMatcher<Object>(comparator, 0), "{a:[[6,7,8]]}", ARRAY_OF_JSONARRAYS);
  }

  @Test
  public void matchesSizeOfFirstThreeInnerArrays() throws JSONException {
    JSONComparator innerArraySizeComparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);
    doTest("a", new ArrayValueMatcher<Object>(innerArraySizeComparator, 0, 2), "{a:[[3]]}", ARRAY_OF_JSONARRAYS);
  }
View Full Code Here


    doTest("a", new ArrayValueMatcher<Object>(innerArraySizeComparator, 0, 2), "{a:[[3]]}", ARRAY_OF_JSONARRAYS);
  }

  @Test
  public void failsWhenInnerArraySizeDoesNotMatch() throws JSONException {
    JSONComparator innerArraySizeComparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);
    doFailingMatchTest("a",
        new ArrayValueMatcher<Object>(innerArraySizeComparator),
        "{a:[[3]]}",
        ARRAY_OF_JSONARRAYS,
        "a\\[3\\]\\[\\]\\s*Expected:\\s*array size of 3 elements\\s*got:\\s*4 elements\\s*");
 
View Full Code Here

  }

  @Test
  public void failsWhenInnerJSONObjectArrayElementDoesNotMatch() throws JSONException {
    ArrayValueMatcher<Object> innerArrayValueMatcher = new ArrayValueMatcher<Object>(comparator, 1);
    JSONComparator innerArrayComparator = new CustomComparator(
        JSONCompareMode.LENIENT, new Customization("a[2]", innerArrayValueMatcher));
    doFailingMatchTest("a",
        new ArrayValueMatcher<Object>(innerArrayComparator, 2)// tests inner array i.e. [12,13,14]
        "{a:[[99]]}",
        ARRAY_OF_JSONARRAYS,
View Full Code Here

  /*
   * Following tests contain copies of code quoted in ArrayValueMatcher JavaDoc and are included to verify that the exact code documented works as expected.
   */
  @Test
  public void verifyIdAttributeOfFirstArrayElementMatches() throws JSONException {
    JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
    Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 0));
    JSONAssert.assertEquals("{a:[{id:1}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
View Full Code Here

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

    JSONAssert.assertEquals("{a:{id:1}}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
 
  @Test
  public void verifyTypeAttributeOfSecondAndThirdElementMatchesRow() throws JSONException {
    JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
    Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 1, 2));
    JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
View Full Code Here

    JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
 
  @Test
  public void verifyTypeAttributeOfEveryArrayElementMatchesRow() throws JSONException {
     JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
     Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator));
     JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
View Full Code Here

     JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
 
  @Test
  public void verifyBackgroundAttributesOfEveryArrayElementAlternateBetweenWhiteAndGrey() throws JSONException {
     JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
     Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator));
     JSONAssert.assertEquals("{a:[{background:white},{background:grey}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
View Full Code Here

     JSONAssert.assertEquals("{a:[{background:white},{background:grey}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
 
  @Test
  public void verifyEveryElementOfArrayIsJSONArrayOfLength3() throws JSONException {
     JSONComparator comparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);
     Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 0, 2));
     JSONAssert.assertEquals("{a:[[3]]}", ARRAY_OF_JSONARRAYS, new CustomComparator(JSONCompareMode.LENIENT, customization));
  }
View Full Code Here

  }
 
  @Test
  public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9() 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

TOP

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

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.