本文整理汇总了Java中org.hamcrest.Description.appendValueList方法的典型用法代码示例。如果您正苦于以下问题:Java Description.appendValueList方法的具体用法?Java Description.appendValueList怎么用?Java Description.appendValueList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hamcrest.Description
的用法示例。
在下文中一共展示了Description.appendValueList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchesQueryParameter
import org.hamcrest.Description; //导入方法依赖的package包/类
private boolean matchesQueryParameter(RecordedRequest item, Description mismatchDescription) {
String path = item.getPath();
boolean hasQuery = path.indexOf("?") > 0;
if (!hasQuery) {
mismatchDescription.appendText(" query was empty");
return false;
}
String query = path.substring(path.indexOf("?") + 1, path.length());
String[] parameters = query.split("&");
for (String p : parameters) {
if (p.equals(String.format("%s=%s", first, second))) {
return true;
}
}
mismatchDescription.appendValueList("Query parameters were {", ", ", "}.", parameters);
return false;
}
示例2: describeTo
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(Description description) {
if (!expected.isEmpty()) {
description.appendValueList("Expected Bucket content [{", "},{", "}].", expected.entrySet());
}
if (!without.isEmpty()) {
description.appendValueList("Expected Bucket to not include [", ",", "].", without);
}
}
示例3: matchesSafely
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(String item, Description mismatchDescription) {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = getJsonNode(item, objectMapper);
List<String> validationMessages = schema.validate(jsonNode)
.stream()
.map(ValidationMessage::getMessage)
.collect(toList());
mismatchDescription.appendValueList("schema validation failed with the following errors: \n - ", "\n - ", "", validationMessages);
return validationMessages.isEmpty();
}
示例4: matchesSafely
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(RastDiff diff, Description mismatchDescription) {
List<RelationshipQuery> falseNegatives = new ArrayList<>();
Set<Relationship> truePositives = new HashSet<>();
Set<Relationship> falsePositives = new HashSet<>(diff.getRelationships());
for (RelationshipQuery query : queries) {
Optional<Relationship> optional = query.find(diff);
if (optional.isPresent()) {
truePositives.add(optional.get());
falsePositives.remove(optional.get());
} else {
falseNegatives.add(query);
}
}
int tp = truePositives.size();
int fp = computeFp ? falsePositives.size() : 0;
int fn = falseNegatives.size();
if (fn != 0 || fp != 0) {
if (computeFp) {
mismatchDescription.appendText(String.format("%d true positives, %d false positives, %d false negatives", tp, fp, fn));
} else {
mismatchDescription.appendText(String.format("%d true positives, %d false negatives", tp, fn));
}
if (!falseNegatives.isEmpty()) {
mismatchDescription.appendValueList("\nFalse negatives:\n", "\n", "", falseNegatives);
}
if (!falsePositives.isEmpty()) {
mismatchDescription.appendValueList("\nFalse positives:\n", "\n", "", falsePositives);
}
return false;
}
return true;
}