本文整理汇总了Java中org.skyscreamer.jsonassert.JSONCompareResult.getFieldFailures方法的典型用法代码示例。如果您正苦于以下问题:Java JSONCompareResult.getFieldFailures方法的具体用法?Java JSONCompareResult.getFieldFailures怎么用?Java JSONCompareResult.getFieldFailures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.skyscreamer.jsonassert.JSONCompareResult
的用法示例。
在下文中一共展示了JSONCompareResult.getFieldFailures方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logFailure
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
public static void logFailure(final String errorText, final JSONCompareResult jsonResult) {
final List<FieldComparisonFailure> failureList = jsonResult.getFieldFailures();
for (FieldComparisonFailure failure : failureList) {
Log.warnFormatted(errorText, failure.getField(), failure.getExpected(), failure.getActual());
}
}
示例2: isListingMoreThanOneNotPresentAttribute
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void isListingMoreThanOneNotPresentAttribute() {
final JSONCompareResult jsonCompareResult = UaiJSONCompareWrapper.compareJSON("{id:1, age:1, aNumber:1}", "{name:\"JC\"}", STRICT_COMPARATOR);
final List<FieldComparisonFailure> failureList = jsonCompareResult.getFieldFailures();
assertTrue("all the missing fields should be present", failureList.size() > 1);
}
示例3: isListingErrorWithWrongValueInAttribute
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void isListingErrorWithWrongValueInAttribute() {
final JSONCompareResult jsonCompareResult = UaiJSONCompareWrapper.compareJSON("{id:1}", "{id:2}", STRICT_COMPARATOR);
final List<FieldComparisonFailure> failureList = jsonCompareResult.getFieldFailures();
assertTrue("all the missing fields should be present", failureList.size() == 1);
}
示例4: isComparingWithLine
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void isComparingWithLine() {
final String jsonWithoutLines = "{id:1,age:33}";
final String jsonWithLines = "" +
"{" +
" id:1," +
" age:33" +
"}";
final JSONCompareResult jsonCompareResult = UaiJSONCompareWrapper.compareJSON(jsonWithoutLines, jsonWithLines, STRICT_COMPARATOR);
final List<FieldComparisonFailure> failureList = jsonCompareResult.getFieldFailures();
assertTrue("Should not have any error", failureList.isEmpty());
}
示例5: isComparingWithSuccess
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void isComparingWithSuccess() {
final JSONCompareResult jsonCompareResult = UaiJSONCompareWrapper.compareJSON("{id:1}", "{id:1}", STRICT_COMPARATOR);
final List<FieldComparisonFailure> failureList = jsonCompareResult.getFieldFailures();
assertTrue("Should not have any error", failureList.isEmpty());
}
示例6: isIgnoringWhenNotRequired
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void isIgnoringWhenNotRequired() {
final JSONCompareResult jsonCompareResult = UaiJSONCompareWrapper.compareJSON("{id:1}", "{id:1, age:33}", LENIENT_COMPARATOR);
final List<FieldComparisonFailure> failureList = jsonCompareResult.getFieldFailures();
assertTrue("Should not have any error", failureList.isEmpty());
}
示例7: test
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
String s1 = "{ \"f1\":1, \"obj\":{ \"f2\":2}, \"arr\":[ {\"f4\":3 } ] }";
String s2 = "{ \"f1\":2, \"obj\":{ \"f2\":3 }, \"arr\":[ {\"f4\":4 } ] }";
JSONCompareResult result = JSONCompare.compareJSON(s1, s2,
JSONCompareMode.STRICT);
for (FieldComparisonFailure x : result.getFieldFailures()) {
System.out.println(x.getField() + " " + x.getExpected() + " " + x.getActual());
}
}
示例8: isListingWhenAttributeIsNotPresent
import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Test
public void isListingWhenAttributeIsNotPresent() {
final JSONCompareResult jsonCompareResult = UaiJSONCompareWrapper.compareJSON("{id:1}", "{}", STRICT_COMPARATOR);
final List<FieldComparisonFailure> failureList = jsonCompareResult.getFieldFailures();
assertFalse("should list a missing field as field failure", failureList.isEmpty());
final FieldComparisonFailure failure = failureList.get(0);
assertEquals("the id field should be listed", "id", failure.getField());
}