当前位置: 首页>>代码示例>>Java>>正文


Java JSONCompareResult.failed方法代码示例

本文整理汇总了Java中org.skyscreamer.jsonassert.JSONCompareResult.failed方法的典型用法代码示例。如果您正苦于以下问题:Java JSONCompareResult.failed方法的具体用法?Java JSONCompareResult.failed怎么用?Java JSONCompareResult.failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.skyscreamer.jsonassert.JSONCompareResult的用法示例。


在下文中一共展示了JSONCompareResult.failed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertEqualsJson

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
public static void assertEqualsJson(String expectedJson, String actualJson, JSONCompareMode compareMode) {

        try {
            JSONCompareResult result = compareJSON(expectedJson, actualJson, compareMode);

            if (result.failed()) {
                String failureMessage = result.getMessage();
                if (failureMessage != null) {
                    failureMessage = failureMessage.replaceAll(" ; ", "\n");
                }
                failureMessage = "\n================ Expected JSON ================"
                        + new JSONObject(expectedJson).toString(4)
                        + "\n================= Actual JSON ================="
                        + new JSONObject(actualJson).toString(4)
                        + "\n================= Error List ==================\n"
                        + failureMessage + "\n\n";
                fail(failureMessage);
            }
        } catch (JSONException e) {
            throw new RuntimeException("JSON completely failed to parse json", e);
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:JsonAssert.java

示例2: matchesSafely

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(JSONIterator actual, Description mismatchDescription)
{
    int line = 1;

    Iterator<String> itLeft = expected;
    Iterator<String> itRight = actual;

    while (true) {
        boolean hasLeft = itLeft.hasNext();
        boolean hasRight = itRight.hasNext();

        if (hasLeft && hasRight) {
            String left = itLeft.next();
            String right = itRight.next();

            try {
                JSONCompareResult r = JSONCompare.compareJSON(left, right, JSONCompareMode.STRICT);
                if (r.failed()) {
                    mismatchDescription.appendText("at line " + line + ": ");
                    mismatchDescription.appendText(r.getMessage());
                    return false;
                }
            }
            catch (JSONException e) {
                mismatchDescription.appendText("at line " + line + ": ");
                mismatchDescription.appendText(e.toString());
                throw new AssertionError(e);
            }
        }
        else if (!hasLeft && !hasRight) {
            return true;
        }
        else {
            // left or right has extra line
            mismatchDescription.appendText("at line " + line + ": ");
            if (hasLeft) {
                mismatchDescription.appendText("expected has extra lines");
            }
            else {
                mismatchDescription.appendText("actual has extra lines");
            }
            return false;
        }

        line += 1;
    }
}
 
开发者ID:CyberAgent,项目名称:embulk-input-parquet_hadoop,代码行数:49,代码来源:JSONIteratorMatcher.java

示例3: assertNotFailed

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
private JsonContentAssert assertNotFailed(JSONCompareResult result) {
	if (result.failed()) {
		throw new AssertionError("JSON Comparison failure: " + result.getMessage());
	}
	return this;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:JsonContentAssert.java


注:本文中的org.skyscreamer.jsonassert.JSONCompareResult.failed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。