Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrization for JSON Comparator #15

Open
saksmt opened this issue Jan 24, 2018 · 0 comments
Open

Parametrization for JSON Comparator #15

saksmt opened this issue Jan 24, 2018 · 0 comments

Comments

@saksmt
Copy link
Owner

saksmt commented Jan 24, 2018

Main idea is for comparator to traverse through JSON applying function with signature (T, T) -> List<Mismatch> to every method.

Conceptual code:

typealias ValueComparator = (expected: JsonNode, actual: JsonNode) -> List<ComparisonMismatch>
val valueComparatorRegistry = mutableMapOf<JsonNodeType, ValueComparator>()

fun compareSameTypedValueNodes(expected: JsonNode, actual: JsonNode, conflicts: MutableList<ComparisonMismatch>) {
  valueComparatorRegistry[expected.nodeType](expected, actual).forEach(conflicts::add)
}

Comparator may also have some interface to accept configuration?

@saksmt saksmt self-assigned this Jan 24, 2018
@saksmt saksmt added this to the 1.1.0 milestone Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant