DiffoExample.Util (DiffoExample v0.2.2)

Copy Markdown View Source

Cross-domain projection helpers for the diffo_example app.

Mirrors Diffo.Util in shape: each function is a projection — it collapses values in a JSON payload to a coarser semantic form so comparisons stay meaningful at the projected level. Apply the same projection to both sides of a comparison.

Summary

Functions

Project the *Characteristic arrays in a JSON payload to a coarser form derived from instance's declarations.

Functions

summarise_characteristics(payload, instance)

Project the *Characteristic arrays in a JSON payload to a coarser form derived from instance's declarations.

While diffo#169 is open, typed characteristic records and pool records do not collapse into the TMF serviceCharacteristic / resourceCharacteristic / featureCharacteristic arrays. Without this projection the actual JSON has no entries at all and the expected has rich entries.

This projection reads the declared characteristic, pool and feature characteristic names from the instance's module and replaces each named characteristic array with a sorted list of %{"name" => name, "value" => "absent_diffo_169"} entries. Applied to both sides, names align; the rich value collapses to the same placeholder. When #169 lands and the collapse arrives, remove the |> summarise_characteristics(instance) wraps from each call site (or delete this function) — every previously masked test surfaces.

Modelled after Diffo.Util.summarise_dates/1.