Search in sources :

Example 1 with SuperfluousPropertyDiffResult

use of nl.knaw.huygens.contractdiff.diffresults.SuperfluousPropertyDiffResult 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;
}
Also used : MissingPropertyDiffResult(nl.knaw.huygens.contractdiff.diffresults.MissingPropertyDiffResult) SuperfluousPropertyDiffResult(nl.knaw.huygens.contractdiff.diffresults.SuperfluousPropertyDiffResult)

Aggregations

MissingPropertyDiffResult (nl.knaw.huygens.contractdiff.diffresults.MissingPropertyDiffResult)1 SuperfluousPropertyDiffResult (nl.knaw.huygens.contractdiff.diffresults.SuperfluousPropertyDiffResult)1