本文整理匯總了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;
}