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


Java JSONCompareResult.fail方法代码示例

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


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

示例1: compareValues

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Override
public void compareValues(String prefix, Object expectedValue, Object actualValue, JSONCompareResult result) throws JSONException {
	if (JsonCompareKeywords.SKIP.getKey().equals(expectedValue.toString())) {
		// do nothing
	} else if (expectedValue != null && expectedValue.toString().startsWith(JsonCompareKeywords.TYPE.getKey())) {
		String expType = expectedValue.toString().replace(JsonCompareKeywords.TYPE.getKey(), "");
		if (!expType.equals(actualValue.getClass().getSimpleName())) {
			result.fail(String.format("%s\nValue type '%s' doesn't match to expected type '%s'\n", prefix, actualValue.getClass()
					.getSimpleName(), expType));
		}
	} else if (expectedValue != null && expectedValue.toString().startsWith(JsonCompareKeywords.REGEX.getKey())) {
		if (actualValue instanceof Number || actualValue instanceof String) {
			String actualStr = actualValue.toString();
			String regex = expectedValue.toString().replace(JsonCompareKeywords.REGEX.getKey(), "");
			Matcher m = Pattern.compile(regex).matcher(actualStr);
			if (!m.find()) {
				result.fail(String.format("%s\nActual value '%s' doesn't match to expected regex '%s'\n", prefix, actualStr, regex));
			}
		} else {
			super.compareValues(prefix, expectedValue, actualValue, result);
		}
	} else {
		super.compareValues(prefix, expectedValue, actualValue, result);
	}
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:26,代码来源:JsonKeywordsComparator.java

示例2: compareJSONArrayForSimpleTypeWContains

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
private void compareJSONArrayForSimpleTypeWContains(String prefix, JSONArray expected, JSONArray actual, JSONCompareResult result) throws JSONException {
	if(expected.length() == 1 && JsonCompareKeywords.SKIP.getKey().equals(expected.get(0).toString())){
		return;
	}
	for (int i = 0; i < expected.length(); ++i) {
		boolean isEquals = false;
		
		for (int j = 0; j < actual.length(); ++j) {
			if(expected.get(i).equals(actual.get(j))){
				isEquals = true;
				break;
			}
		}
		
		if (!isEquals) {
			result.fail(String.format("%s\nExpected array item '"+expected.get(i)+"' is missed in actual array\n", prefix));
		}
	}
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:20,代码来源:JsonKeywordsComparator.java

示例3: compareForNull

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
private JSONCompareResult compareForNull(CharSequence expectedJson) {
	JSONCompareResult result = new JSONCompareResult();
	result.passed();
	if (expectedJson != null) {
		result.fail("Expected null JSON");
	}
	return result;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:JsonContentAssert.java

示例4: checkJsonObjectKeysExpectedInActual

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Override
protected void checkJsonObjectKeysExpectedInActual(String prefix, JSONObject expected, JSONObject actual, JSONCompareResult result) throws JSONException {
    final Set<String> expectedKeys = getKeys(expected);
    for (String key : expectedKeys) {
        final Object expectedValue = expected.get(key);
        if (actual.has(key)) {
            final Object actualValue = actual.get(key);
            compareValues(qualify(prefix, key), expectedValue, actualValue, result);
        } else {
            result.missing(prefix, key);
            result.fail(key, expectedValue, "we did not received the value");
        }
    }
}
 
开发者ID:uaihebert,项目名称:uaiMockServer,代码行数:15,代码来源:UaiJSONComparator.java

示例5: checkJsonObjectKeysActualInExpected

import org.skyscreamer.jsonassert.JSONCompareResult; //导入方法依赖的package包/类
@Override
protected void checkJsonObjectKeysActualInExpected(String prefix, JSONObject expected, JSONObject actual, JSONCompareResult result) {
    final Set<String> actualKeys = getKeys(actual);

    for (String key : actualKeys) {
        if (!expected.has(key)) {
            result.unexpected(prefix, key);
            final Object actualValue = actual.opt(key);
            result.fail(key, actualValue, String.format("The [%s] is not mapped", key));
        }
    }
}
 
开发者ID:uaihebert,项目名称:uaiMockServer,代码行数:13,代码来源:UaiJSONComparator.java


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