use of nl.knaw.huygens.contractdiff.diffresults.MissingPropertyDiffResult in project timbuctoo by HuygensING.
the class JsonDiffer method checkObject.
// FIXME: handle arrays as expected and arrays as actual
public DiffResult checkObject(ObjectNode actual, ObjectNode expected) {
Set<String> expectedFields = Sets.newHashSet();
expected.fieldNames().forEachRemaining(expectedFields::add);
ObjectDiffResult result = new ObjectDiffResult();
actual.fields().forEachRemaining(field -> {
// we've seen this one
expectedFields.remove(field.getKey());
if (expected.get(field.getKey()) == null) {
result.add(field.getKey(), new SuperfluousPropertyDiffResult(field.getValue().toString()));
} else {
result.add(field.getKey(), checkNodes(field.getValue(), expected.get(field.getKey())));
}
});
expectedFields.forEach(field -> result.add(field, new MissingPropertyDiffResult(expected.get(field).toString())));
return result;
}
use of nl.knaw.huygens.contractdiff.diffresults.MissingPropertyDiffResult in project timbuctoo by HuygensING.
the class ExpectedHeadersAreEqualValidator method validate.
public static HttpHeadersDiffResult validate(LinkedListMultimap<String, String> expectation, LinkedListMultimap<String, String> reality) {
final HttpHeadersDiffResult result = new HttpHeadersDiffResult();
// We don't supporting multiple expectations for headers of the same name
for (String fieldName : expectation.keySet()) {
if (expectation.get(fieldName).size() > 1) {
result.addMultiHeaderExpectation(fieldName);
}
}
// Preparations
Map<String, DoDiff> diffResults = new HashMap<>();
for (String key : reality.keySet()) {
diffResults.put(key, new DoDiff(expectation.get(key), reality.get(key)));
}
// output results
for (Map.Entry<String, String> actual : reality.entries()) {
result.add(actual.getKey(), diffResults.get(actual.getKey()).getNextResult());
}
for (String key : expectation.keySet()) {
if (!reality.containsKey(key)) {
result.add(key, new MissingPropertyDiffResult(expectation.get(key).get(0)));
}
}
return result;
}
Aggregations