Examples of JSONComparator


Examples of org.sf.bee.commons.util.comparators.JSONComparator

     * Sort a list of objects
     * @param data List to sort
     * @param fields Array of names to order to.
     */
    public void sort(final List<JSONObject> data, final String[] fields) {
        Collections.sort(data, new JSONComparator(fields));
    }
View Full Code Here

Examples of org.sf.bee.commons.util.comparators.JSONComparator

                // get filtered data
                final List<JSONObject> data = this.find(conditions);
                // order data
                final String[] fieldNames = treeExpression.getGroupByFields();
                if (!CollectionUtils.isEmpty(fieldNames)) {
                    Collections.sort(result, new JSONComparator(fieldNames));
                }
                // loop on all data
                for (final JSONObject obj : data) {
                    try {
                        // add item to tree (list must be ordered)
View Full Code Here

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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

    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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

  }

  @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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

  /*
   * 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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

    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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

    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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

    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

Examples of org.skyscreamer.jsonassert.comparator.JSONComparator

     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
TOP
Copyright © 2018 www.massapi.com. 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.