本文整理汇总了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);
}
}
示例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));
}
}
}
示例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");
}
}
}
示例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));
}
}
}