diff --git a/CHANGELOG.md b/CHANGELOG.md index 75fa993..3592cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,21 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline +## [v0.2.3](https://github.com/diffo-dev/diffo/compare/v0.2.2..v0.2.3) (2026-05-22) + +### Maintenance: +* updated to diffo 0.4.1 (issue #48) +* refreshed agent guidance via `mix usage_rules.sync` + +### Refactors: +* adopted upstream `Diffo.Provider.Changes.{Define,Relate,Assign}` across 11 instance resources; deleted the local `DiffoExample.Changes.*` trio now that the same modules ship in diffo proper ([diffo#170](https://github.com/diffo-dev/diffo/pull/170)) +* slimmed 16 `BaseCharacteristic`-derived resources by relying on the auto-generated `:create`/`:update` actions ([diffo#171](https://github.com/diffo-dev/diffo/pull/171)) — ~360 lines removed; custom `:update` retained on `cable`, `path`, `circuit`, `constraints` where unit/bandwidth-profile composition is needed +* `Cable.relate` inline `after_action` (which referenced an unaliased `Relationship` module) folded into `change Diffo.Provider.Changes.Relate` + +### Resolved workarounds: +* `DslAccess.qualify_result` now transitions to `:feasibilityChecked` — restores correct TMF form following [diffo#168](https://github.com/diffo-dev/diffo/pull/168) broadening the Assigner lifecycle gate to include `:feasibilityChecked` +* `Util.summarise_characteristics/2` no longer called from tests — typed characteristic + pool records now surface in TMF JSON by default ([diffo#169](https://github.com/diffo-dev/diffo/pull/169)). The projection function is retained in [lib/diffo_example/util.ex](lib/diffo_example/util.ex) for future projection demonstrations. Expected JSON strings updated across `cable`, `card`, `cable`, `path`, `shelf`, `dsl_access`, `nbn_ethernet` tests to reflect the real typed/pool surfacing + ## [v0.2.2](https://github.com/diffo-dev/diffo/compare/v0.2.1..v0.2.2) (2026-05-21) ### Maintenance: diff --git a/lib/access/resources/cable.ex b/lib/access/resources/cable.ex index 73ca03c..c481d9f 100644 --- a/lib/access/resources/cable.ex +++ b/lib/access/resources/cable.ex @@ -70,25 +70,21 @@ defmodule DiffoExample.Access.Cable do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the cable with other instances" argument :relationships, {:array, :struct} - change after_action(fn changeset, result, _context -> - with {:ok, result} <- Relationship.relate_instance(result, changeset), - {:ok, result} <- Access.get_cable_by_id(result.id), - do: {:ok, result} - end) + change Diffo.Provider.Changes.Relate end update :assign_pair do description "relates the cable with an instance by assigning a pair" argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :pairs} + change {Diffo.Provider.Changes.Assign, pool: :pairs} end end end diff --git a/lib/access/resources/card.ex b/lib/access/resources/card.ex index cc160ad..396014b 100644 --- a/lib/access/resources/card.ex +++ b/lib/access/resources/card.ex @@ -70,21 +70,21 @@ defmodule DiffoExample.Access.Card do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the card with other instances" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end update :assign_port do description "relates the card with an instance by assigning a port" argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :ports} + change {Diffo.Provider.Changes.Assign, pool: :ports} end end diff --git a/lib/access/resources/characteristic_values/cable_characteristic.ex b/lib/access/resources/characteristic_values/cable_characteristic.ex index 856447a..ff3b040 100644 --- a/lib/access/resources/characteristic_values/cable_characteristic.ex +++ b/lib/access/resources/characteristic_values/cable_characteristic.ex @@ -16,14 +16,6 @@ defmodule DiffoExample.Access.CableCharacteristic do end actions do - create :create do - accept [:name, :pairs, :length_amount, :length_unit, :loss_amount, :loss_unit, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - update :update do accept [:pairs, :technology, :length_amount, :length_unit, :loss_amount, :loss_unit] argument :length, :term, allow_nil?: true diff --git a/lib/access/resources/characteristic_values/card_characteristic.ex b/lib/access/resources/characteristic_values/card_characteristic.ex index f3fb0be..f308463 100644 --- a/lib/access/resources/characteristic_values/card_characteristic.ex +++ b/lib/access/resources/characteristic_values/card_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Access.CardCharacteristic do plural_name :card_characteristics end - actions do - create :create do - accept [:name, :family, :model, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:family, :model, :technology] - end - end - attributes do attribute :family, :atom, public?: true attribute :model, :string, public?: true diff --git a/lib/access/resources/characteristic_values/path_characteristic.ex b/lib/access/resources/characteristic_values/path_characteristic.ex index 731e24d..76e08c7 100644 --- a/lib/access/resources/characteristic_values/path_characteristic.ex +++ b/lib/access/resources/characteristic_values/path_characteristic.ex @@ -16,24 +16,6 @@ defmodule DiffoExample.Access.PathCharacteristic do end actions do - create :create do - accept [ - :name, - :device_name, - :sections, - :length_amount, - :length_unit, - :loss_amount, - :loss_unit, - :technology - ] - - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - update :update do accept [ :device_name, diff --git a/lib/access/resources/characteristic_values/shelf_characteristic.ex b/lib/access/resources/characteristic_values/shelf_characteristic.ex index 6a915cd..fdafc29 100644 --- a/lib/access/resources/characteristic_values/shelf_characteristic.ex +++ b/lib/access/resources/characteristic_values/shelf_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Access.ShelfCharacteristic do plural_name :shelf_characteristics end - actions do - create :create do - accept [:name, :device_name, :family, :model, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:device_name, :family, :model, :technology] - end - end - attributes do attribute :device_name, :string, public?: true attribute :family, :atom, public?: true diff --git a/lib/access/resources/path.ex b/lib/access/resources/path.ex index 816e511..c56e2f2 100644 --- a/lib/access/resources/path.ex +++ b/lib/access/resources/path.ex @@ -64,14 +64,14 @@ defmodule DiffoExample.Access.Path do description "defines the path" argument :characteristic_value_updates, {:array, :term} - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the path with other instances" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end diff --git a/lib/access/resources/shelf.ex b/lib/access/resources/shelf.ex index 243de66..43b8a50 100644 --- a/lib/access/resources/shelf.ex +++ b/lib/access/resources/shelf.ex @@ -70,21 +70,21 @@ defmodule DiffoExample.Access.Shelf do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the shelf with cards" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end update :assign_slot do description "relates the shelf with an instance by assigning a slot" argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :slots} + change {Diffo.Provider.Changes.Assign, pool: :slots} end end diff --git a/lib/access/services/characteristic_values/aggregate_characteristic.ex b/lib/access/services/characteristic_values/aggregate_characteristic.ex index 0c5c7cf..986a753 100644 --- a/lib/access/services/characteristic_values/aggregate_characteristic.ex +++ b/lib/access/services/characteristic_values/aggregate_characteristic.ex @@ -13,29 +13,6 @@ defmodule DiffoExample.Access.AggregateCharacteristic do plural_name :aggregate_characteristics end - actions do - create :create do - accept [ - :name, - :interface_name, - :physical_interface, - :physical_layer, - :link_layer, - :svlan_id, - :vpi - ] - - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:interface_name, :physical_interface, :physical_layer, :link_layer, :svlan_id, :vpi] - end - end - attributes do attribute :interface_name, :string, public?: true attribute :physical_interface, :string, public?: true diff --git a/lib/access/services/characteristic_values/circuit_characteristic.ex b/lib/access/services/characteristic_values/circuit_characteristic.ex index 87dcea5..1829997 100644 --- a/lib/access/services/characteristic_values/circuit_characteristic.ex +++ b/lib/access/services/characteristic_values/circuit_characteristic.ex @@ -16,24 +16,6 @@ defmodule DiffoExample.Access.CircuitCharacteristic do end actions do - create :create do - accept [ - :name, - :circuit_id, - :cvlan_id, - :vci, - :encapsulation, - :bp_downstream, - :bp_upstream, - :bp_units - ] - - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - update :update do accept [:circuit_id, :cvlan_id, :vci, :encapsulation] argument :bandwidth_profile, :term, allow_nil?: true diff --git a/lib/access/services/characteristic_values/constraints_characteristic.ex b/lib/access/services/characteristic_values/constraints_characteristic.ex index 4cfcade..d3f3177 100644 --- a/lib/access/services/characteristic_values/constraints_characteristic.ex +++ b/lib/access/services/characteristic_values/constraints_characteristic.ex @@ -16,14 +16,6 @@ defmodule DiffoExample.Access.ConstraintsCharacteristic do end actions do - create :create do - accept [:name, :max_latency, :mp_downstream, :mp_upstream, :mp_units] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - update :update do accept [:max_latency] argument :min_profile, :term, allow_nil?: true diff --git a/lib/access/services/characteristic_values/dslam_characteristic.ex b/lib/access/services/characteristic_values/dslam_characteristic.ex index 06d61ef..fbbc010 100644 --- a/lib/access/services/characteristic_values/dslam_characteristic.ex +++ b/lib/access/services/characteristic_values/dslam_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Access.DslamCharacteristic do plural_name :dslam_characteristics end - actions do - create :create do - accept [:name, :device_name, :family, :model, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:device_name, :family, :model, :technology] - end - end - attributes do attribute :device_name, :string, public?: true attribute :family, :atom, public?: true diff --git a/lib/access/services/characteristic_values/line_characteristic.ex b/lib/access/services/characteristic_values/line_characteristic.ex index 33506b5..e0b5fe7 100644 --- a/lib/access/services/characteristic_values/line_characteristic.ex +++ b/lib/access/services/characteristic_values/line_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Access.LineCharacteristic do plural_name :line_characteristics end - actions do - create :create do - accept [:name, :port, :slot, :standard, :profile] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:port, :slot, :standard, :profile] - end - end - attributes do attribute :port, :integer, public?: true attribute :slot, :integer, public?: true diff --git a/lib/access/services/dsl_access.ex b/lib/access/services/dsl_access.ex index 7983f8f..a059900 100644 --- a/lib/access/services/dsl_access.ex +++ b/lib/access/services/dsl_access.ex @@ -54,8 +54,8 @@ defmodule DiffoExample.Access.DslAccess do state_machine do transitions do - transition action: :qualify_result, from: :initial, to: :inactive - transition action: :design_result, from: [:initial, :inactive], to: :reserved + transition action: :qualify_result, from: :initial, to: :feasibilityChecked + transition action: :design_result, from: [:initial, :feasibilityChecked], to: :reserved end end @@ -76,7 +76,7 @@ defmodule DiffoExample.Access.DslAccess do argument :places, {:array, :struct} require_atomic? false - change transition_state(:inactive) + change transition_state(:feasibilityChecked) validate argument_in(:service_operating_status, [ nil, @@ -99,7 +99,7 @@ defmodule DiffoExample.Access.DslAccess do argument :characteristic_value_updates, {:array, :term} change transition_state(:reserved) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end end end diff --git a/lib/diffo_example/changes/assign.ex b/lib/diffo_example/changes/assign.ex deleted file mode 100644 index 0887940..0000000 --- a/lib/diffo_example/changes/assign.ex +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-FileCopyrightText: 2025 diffo_example contributors -# -# SPDX-License-Identifier: MIT - -defmodule DiffoExample.Changes.Assign do - @moduledoc """ - After-action for `:assign_*`-style update actions on Diffo Instance resources - that declare pools. - - Applies the `:assignment` argument via `Assigner.assign/3` against the named - pool, then reloads the instance through its primary read so preparations - re-run. - - Pass the pool name as an option: - - update :assign_pair do - argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :pairs} - end - """ - use Ash.Resource.Change - require Ash.Query - - alias Diffo.Provider.Assigner - - @impl true - def change(changeset, opts, _context) do - pool = Keyword.fetch!(opts, :pool) - - Ash.Changeset.after_action(changeset, fn changeset, result -> - mod = result.__struct__ - - with {:ok, result} <- Assigner.assign(result, changeset, pool), - {:ok, result} <- - mod - |> Ash.Query.for_read(:read) - |> Ash.Query.filter(id == ^result.id) - |> Ash.read_one() do - {:ok, result} - end - end) - end -end diff --git a/lib/diffo_example/changes/define.ex b/lib/diffo_example/changes/define.ex deleted file mode 100644 index 5af026c..0000000 --- a/lib/diffo_example/changes/define.ex +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-FileCopyrightText: 2025 diffo_example contributors -# -# SPDX-License-Identifier: MIT - -defmodule DiffoExample.Changes.Define do - @moduledoc """ - After-action for `:define`-style update actions on Diffo Instance resources. - - Applies the `:characteristic_value_updates` argument against the resource's - compile-time `characteristics/0` and `pools/0` declarations, then reloads - the instance through its primary read so preparations re-run. - - Use it on any instance update action that carries - `argument :characteristic_value_updates, {:array, :term}`: - - update :define do - argument :characteristic_value_updates, {:array, :term} - - change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define - end - - Lifecycle transitions (resource_state for resources, transition_state for - services) remain on the action — they are intent-specific. - """ - use Ash.Resource.Change - require Ash.Query - - alias Diffo.Provider.Extension.Characteristic - alias Diffo.Provider.Extension.Pool - - @impl true - def change(changeset, _opts, _context) do - Ash.Changeset.after_action(changeset, fn changeset, result -> - mod = result.__struct__ - - with {:ok, result} <- Ash.load(result, [:characteristics]), - {:ok, result} <- Characteristic.update_all(result, changeset, mod.characteristics()), - {:ok, result} <- Pool.update_pools(result, changeset, mod.pools()), - {:ok, result} <- - mod - |> Ash.Query.for_read(:read) - |> Ash.Query.filter(id == ^result.id) - |> Ash.read_one() do - {:ok, result} - end - end) - end -end diff --git a/lib/diffo_example/changes/relate.ex b/lib/diffo_example/changes/relate.ex deleted file mode 100644 index 5ddd24c..0000000 --- a/lib/diffo_example/changes/relate.ex +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-FileCopyrightText: 2025 diffo_example contributors -# -# SPDX-License-Identifier: MIT - -defmodule DiffoExample.Changes.Relate do - @moduledoc """ - After-action for `:relate`-style update actions on Diffo Instance resources. - - Applies the `:relationships` argument via `Relationship.relate_instance`, - then reloads the instance through its primary read so preparations re-run. - - Use it on any instance update action that carries - `argument :relationships, {:array, :struct}`: - - update :relate do - argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate - end - """ - use Ash.Resource.Change - require Ash.Query - - alias Diffo.Provider.Instance.Relationship - - @impl true - def change(changeset, _opts, _context) do - Ash.Changeset.after_action(changeset, fn changeset, result -> - mod = result.__struct__ - - with {:ok, result} <- Relationship.relate_instance(result, changeset), - {:ok, result} <- - mod - |> Ash.Query.for_read(:read) - |> Ash.Query.filter(id == ^result.id) - |> Ash.read_one() do - {:ok, result} - end - end) - end -end diff --git a/lib/diffo_example/util.ex b/lib/diffo_example/util.ex index e0047ad..6aedea5 100644 --- a/lib/diffo_example/util.ex +++ b/lib/diffo_example/util.ex @@ -12,26 +12,25 @@ defmodule DiffoExample.Util do projection to both sides of a comparison. """ - @absent_characteristic "absent_diffo_169" + @absent_characteristic "absent_characteristic" @doc """ Project the `*Characteristic` arrays in a JSON payload to a coarser form derived from `instance`'s declarations. - While [diffo#169](https://github.com/diffo-dev/diffo/issues/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. + General-purpose projection helper for comparing TMF payloads at the + *names-only* level, ignoring the specific values carried by typed + characteristic records and pool records. 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_characteristic"}` + entries. Applied to both sides of a comparison, names align and rich + values collapse to the same placeholder. + + Useful for demonstrating projections — coarsening test assertions to + the structural shape (which characteristics are declared and surface) + without coupling them to the values those characteristics happen to + carry on a given run. Modelled after `Diffo.Util.summarise_dates/1`. """ diff --git a/lib/nbn/resources/avc.ex b/lib/nbn/resources/avc.ex index 609cfeb..8be922d 100644 --- a/lib/nbn/resources/avc.ex +++ b/lib/nbn/resources/avc.ex @@ -77,14 +77,14 @@ defmodule DiffoExample.Nbn.Avc do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the AVC with other instances" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end diff --git a/lib/nbn/resources/characteristic_values/avc_characteristic.ex b/lib/nbn/resources/characteristic_values/avc_characteristic.ex index 94df0fa..eed80e1 100644 --- a/lib/nbn/resources/characteristic_values/avc_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/avc_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Nbn.AvcCharacteristic do plural_name :avc_characteristics end - actions do - create :create do - accept [:name, :cvlan, :bandwidth_profile] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:cvlan, :bandwidth_profile] - end - end - attributes do attribute :cvlan, :integer, public?: true attribute :bandwidth_profile, DiffoExample.Nbn.BandwidthProfile, public?: true diff --git a/lib/nbn/resources/characteristic_values/cvc_characteristic.ex b/lib/nbn/resources/characteristic_values/cvc_characteristic.ex index 0a5fb96..3587794 100644 --- a/lib/nbn/resources/characteristic_values/cvc_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/cvc_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Nbn.CvcCharacteristic do plural_name :cvc_characteristics end - actions do - create :create do - accept [:name, :svlan, :bandwidth] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:svlan, :bandwidth] - end - end - attributes do attribute :svlan, :integer, public?: true attribute :bandwidth, :integer, public?: true diff --git a/lib/nbn/resources/characteristic_values/nni_characteristic.ex b/lib/nbn/resources/characteristic_values/nni_characteristic.ex index 8ca3a7a..14df69f 100644 --- a/lib/nbn/resources/characteristic_values/nni_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/nni_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Nbn.NniCharacteristic do plural_name :nni_characteristics end - actions do - create :create do - accept [:name, :port_id, :capacity, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:port_id, :capacity, :technology] - end - end - attributes do attribute :port_id, :string, public?: true attribute :capacity, :integer, public?: true diff --git a/lib/nbn/resources/characteristic_values/nni_group_characteristic.ex b/lib/nbn/resources/characteristic_values/nni_group_characteristic.ex index 18a09a6..2974594 100644 --- a/lib/nbn/resources/characteristic_values/nni_group_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/nni_group_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Nbn.NniGroupCharacteristic do plural_name :nni_group_characteristics end - actions do - create :create do - accept [:name, :group_name, :location] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:group_name, :location] - end - end - attributes do attribute :group_name, :string, public?: true attribute :location, :string, public?: true diff --git a/lib/nbn/resources/characteristic_values/ntd_characteristic.ex b/lib/nbn/resources/characteristic_values/ntd_characteristic.ex index 0ddf67e..4c7ab5c 100644 --- a/lib/nbn/resources/characteristic_values/ntd_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/ntd_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Nbn.NtdCharacteristic do plural_name :ntd_characteristics end - actions do - create :create do - accept [:name, :model, :serial_number, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:model, :serial_number, :technology] - end - end - attributes do attribute :model, :string, public?: true attribute :serial_number, :string, public?: true diff --git a/lib/nbn/resources/characteristic_values/pri_characteristic.ex b/lib/nbn/resources/characteristic_values/pri_characteristic.ex index 283ddc6..ba9b785 100644 --- a/lib/nbn/resources/characteristic_values/pri_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/pri_characteristic.ex @@ -13,36 +13,6 @@ defmodule DiffoExample.Nbn.PriCharacteristic do plural_name :pri_characteristics end - actions do - create :create do - accept [ - :name, - :avcid, - :uniid, - :technology, - :bandwidth_profile, - :speeds_downstream, - :speeds_upstream - ] - - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [ - :avcid, - :uniid, - :technology, - :bandwidth_profile, - :speeds_downstream, - :speeds_upstream - ] - end - end - attributes do attribute :avcid, :string, public?: true attribute :uniid, :string, public?: true diff --git a/lib/nbn/resources/characteristic_values/uni_characteristic.ex b/lib/nbn/resources/characteristic_values/uni_characteristic.ex index 3a805f3..28dc640 100644 --- a/lib/nbn/resources/characteristic_values/uni_characteristic.ex +++ b/lib/nbn/resources/characteristic_values/uni_characteristic.ex @@ -13,20 +13,6 @@ defmodule DiffoExample.Nbn.UniCharacteristic do plural_name :uni_characteristics end - actions do - create :create do - accept [:name, :port, :encapsulation, :technology] - argument :instance_id, :uuid - argument :feature_id, :uuid - change manage_relationship(:instance_id, :instance, type: :append) - change manage_relationship(:feature_id, :feature, type: :append) - end - - update :update do - accept [:port, :encapsulation, :technology] - end - end - attributes do attribute :port, :integer, public?: true attribute :encapsulation, :string, public?: true diff --git a/lib/nbn/resources/cvc.ex b/lib/nbn/resources/cvc.ex index b2011ca..90d38b6 100644 --- a/lib/nbn/resources/cvc.ex +++ b/lib/nbn/resources/cvc.ex @@ -83,21 +83,21 @@ defmodule DiffoExample.Nbn.Cvc do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :assign_cvlan do description "assigns a C-VLAN ID from the CVC pool to an AVC" argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :cvlans} + change {Diffo.Provider.Changes.Assign, pool: :cvlans} end update :relate do description "relates the CVC with other instances (e.g. AVC aggregation, NNI Group termination)" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end diff --git a/lib/nbn/resources/nbn_ethernet.ex b/lib/nbn/resources/nbn_ethernet.ex index 5ddc50c..7dae763 100644 --- a/lib/nbn/resources/nbn_ethernet.ex +++ b/lib/nbn/resources/nbn_ethernet.ex @@ -75,14 +75,14 @@ defmodule DiffoExample.Nbn.NbnEthernet do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the NBN Ethernet access with other instances (e.g. UNI)" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end diff --git a/lib/nbn/resources/nni.ex b/lib/nbn/resources/nni.ex index db4886c..7714971 100644 --- a/lib/nbn/resources/nni.ex +++ b/lib/nbn/resources/nni.ex @@ -77,14 +77,14 @@ defmodule DiffoExample.Nbn.Nni do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the NNI with other instances (e.g. its parent NNI Group)" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end diff --git a/lib/nbn/resources/nni_group.ex b/lib/nbn/resources/nni_group.ex index 5ae78e6..baf8897 100644 --- a/lib/nbn/resources/nni_group.ex +++ b/lib/nbn/resources/nni_group.ex @@ -81,21 +81,21 @@ defmodule DiffoExample.Nbn.NniGroup do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :assign_svlan do description "assigns an S-VLAN ID from the NNI Group pool to a CVC" argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :svlans} + change {Diffo.Provider.Changes.Assign, pool: :svlans} end update :relate do description "relates the NNI Group with other instances (e.g. NNI resources it comprises)" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end diff --git a/lib/nbn/resources/ntd.ex b/lib/nbn/resources/ntd.ex index 3e728af..424a386 100644 --- a/lib/nbn/resources/ntd.ex +++ b/lib/nbn/resources/ntd.ex @@ -98,21 +98,21 @@ defmodule DiffoExample.Nbn.Ntd do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :assign_port do description "assigns a port from the NTD pool to a UNI" argument :assignment, :struct, constraints: [instance_of: Assignment] - change {DiffoExample.Changes.Assign, pool: :ports} + change {Diffo.Provider.Changes.Assign, pool: :ports} end update :relate do description "relates the NTD with other instances (e.g. UNI)" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end end diff --git a/lib/nbn/resources/uni.ex b/lib/nbn/resources/uni.ex index 86a6f40..dd8bf2e 100644 --- a/lib/nbn/resources/uni.ex +++ b/lib/nbn/resources/uni.ex @@ -94,14 +94,14 @@ defmodule DiffoExample.Nbn.Uni do argument :characteristic_value_updates, {:array, :term} change set_attribute(:resource_state, :operating) - change DiffoExample.Changes.Define + change Diffo.Provider.Changes.Define end update :relate do description "relates the UNI with other instances (e.g. NTD, NBN Ethernet access)" argument :relationships, {:array, :struct} - change DiffoExample.Changes.Relate + change Diffo.Provider.Changes.Relate end end end diff --git a/mix.exs b/mix.exs index a9f4bd7..298d0f7 100644 --- a/mix.exs +++ b/mix.exs @@ -6,7 +6,7 @@ defmodule DiffoExample.MixProject do @moduledoc false use Mix.Project - @version "0.2.2" + @version "0.2.3" @name "DiffoExample" @description "Examples for Diffo TMF Service and Resource Manager" @github_url "https://github.com/diffo-dev/diffo-example" @@ -89,7 +89,7 @@ defmodule DiffoExample.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:diffo, diffo_version("~> 0.4.0")}, + {:diffo, diffo_version("~> 0.4.1")}, {:ash_ai, "~> 0.6"}, {:ash_json_api, "~> 1.6"}, {:plug_cowboy, "~> 2.7"}, diff --git a/mix.lock b/mix.lock index 2643834..210948c 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ %{ "abnf_parsec": {:hex, :abnf_parsec, "2.1.0", "c4e88d5d089f1698297c0daced12be1fb404e6e577ecf261313ebba5477941f9", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e0ed6290c7cc7e5020c006d1003520390c9bdd20f7c3f776bd49bfe3c5cd362a"}, - "ash": {:hex, :ash, "3.25.2", "d23c52a9f823e98895d0cf1dc8bbf5d22943ffa45ba087e583d94bb05d205b2e", [:mix], [{:crux, ">= 0.1.2 and < 1.0.0-0", [hex: :crux, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 1.0", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.6.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.3", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c4e3fb9252719dd3fec84610a5a19e309f298265076da23c0bef21de237e98bb"}, + "ash": {:hex, :ash, "3.26.0", "29cc66579ac8b8efc30f6d3c2c408c5b7d27fc4b878a6a2a9971f2dd36c09d56", [:mix], [{:crux, ">= 0.1.2 and < 1.0.0-0", [hex: :crux, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 1.0", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.6.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.3", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cec7b582dcbf89810cefa641d28fa996ae2c48e5c0d6b40183f3e526e0a85d20"}, "ash_ai": {:hex, :ash_ai, "0.6.1", "d30bda859f17bed34302cd3d0c16acf56841c43c2fa3b9271c681122b8297d01", [:mix], [{:ash, ">= 3.7.1 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_authentication, "~> 4.8", [hex: :ash_authentication, repo: "hexpm", optional: true]}, {:ash_json_api, ">= 1.4.27 and < 2.0.0-0", [hex: :ash_json_api, repo: "hexpm", optional: false]}, {:ash_oban, "~> 0.5", [hex: :ash_oban, repo: "hexpm", optional: true]}, {:ash_phoenix, "~> 2.0", [hex: :ash_phoenix, repo: "hexpm", optional: true]}, {:ash_postgres, "~> 2.5", [hex: :ash_postgres, repo: "hexpm", optional: true]}, {:igniter, "~> 0.5", [hex: :igniter, repo: "hexpm", optional: true]}, {:open_api_spex, "~> 3.0", [hex: :open_api_spex, repo: "hexpm", optional: false]}, {:phx_new, "~> 1.7", [hex: :phx_new, repo: "hexpm", optional: true]}, {:plug, "~> 1.17", [hex: :plug, repo: "hexpm", optional: true]}, {:req_llm, "~> 1.7", [hex: :req_llm, repo: "hexpm", optional: false]}], "hexpm", "e950e5743ef093fdd2561cf608a1719d46dcc4125bee6f50d43fd6f8a9526c05"}, "ash_jason": {:hex, :ash_jason, "3.1.0", "84a88dfe5e25a20d55cf2d2664885cd086fa45871e8777aedc3ad96a282e2a6f", [:mix], [{:ash, ">= 3.6.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:spark, ">= 2.1.21 and < 3.0.0", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "71e6bbc421fb2cf7079f8804814145cca458116c839fc798f9606b806e07eb2b"}, "ash_json_api": {:hex, :ash_json_api, "1.6.5", "ff925107ebdced10407a6045dc3ff9e8335fe3485ce042f899817a2b47f49b5f", [:mix], [{:ash, ">= 3.19.1 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:igniter, ">= 0.3.58 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:json_xema, "~> 0.4", [hex: :json_xema, repo: "hexpm", optional: false]}, {:open_api_spex, "~> 3.16", [hex: :open_api_spex, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}, {:plug, "~> 1.11", [hex: :plug, repo: "hexpm", optional: false]}, {:spark, ">= 2.2.10", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "ab2f413d977a560843bbf7a7f6bc486b74e944ef51d9adf93c355a4bf984b0df"}, @@ -16,7 +16,7 @@ "db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"}, "decimal": {:hex, :decimal, "2.4.1", "6c0fbede12fb122ba685e9ab41c6a40c129e322b3aa192f9e072e61f3a6ffaf2", [:mix], [], "hexpm", "7e618897933a8455f19a727d7c5e50a2c071a544b700e5e724298ecb4340187f"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, - "diffo": {:hex, :diffo, "0.4.0", "919101d104f3c3c8fbe61ee38f94da84a9a0f107dac94875b00b6cca30b5c04e", [:mix], [{:ash, ">= 3.24.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_jason, "~> 3.0", [hex: :ash_jason, repo: "hexpm", optional: false]}, {:ash_neo4j, "~> 0.6", [hex: :ash_neo4j, repo: "hexpm", optional: false]}, {:ash_outstanding, "~> 0.2.3", [hex: :ash_outstanding, repo: "hexpm", optional: false]}, {:ash_state_machine, "~> 0.2.12", [hex: :ash_state_machine, repo: "hexpm", optional: false]}, {:bolty, ">= 0.0.12", [hex: :bolty, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:uuid, "~> 1.1", [hex: :uuid, repo: "hexpm", optional: false]}], "hexpm", "6e3b37d523ee1e19c92f21956b9c3f710dc3ed87d5be813d0ed120f331bc630d"}, + "diffo": {:hex, :diffo, "0.4.1", "34d7030428b34463fb0b248a720979656ef523904ddc7382d0d7a3f85d067928", [:mix], [{:ash, ">= 3.24.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_jason, "~> 3.0", [hex: :ash_jason, repo: "hexpm", optional: false]}, {:ash_neo4j, "~> 0.6", [hex: :ash_neo4j, repo: "hexpm", optional: false]}, {:ash_outstanding, "~> 0.2.3", [hex: :ash_outstanding, repo: "hexpm", optional: false]}, {:ash_state_machine, "~> 0.2.12", [hex: :ash_state_machine, repo: "hexpm", optional: false]}, {:bolty, ">= 0.0.12", [hex: :bolty, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:uuid, "~> 1.1", [hex: :uuid, repo: "hexpm", optional: false]}], "hexpm", "bab49f959a2123cc31a4434ea7ba367f632edac30ad1808bf22a5d353a1460a3"}, "dotenvy": {:hex, :dotenvy, "1.1.1", "00e318f3c51de9fafc4b48598447e386f19204dc18ca69886905bb8f8b08b667", [:mix], [], "hexpm", "c8269471b5701e9e56dc86509c1199ded2b33dce088c3471afcfef7839766d8e"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, "ecto": {:hex, :ecto, "3.13.6", "352135b474f91d1ab99a1b502171d207e9db60421c9e3d0ecab4c7ab96b24d14", [:mix], [{:decimal, "~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "8afa059bc16cd2c94739ec0a11e3e5df69d828125119109bef35f20a21a76af2"}, diff --git a/test/access/cable_test.exs b/test/access/cable_test.exs index 2365ba0..61a7560 100644 --- a/test/access/cable_test.exs +++ b/test/access/cable_test.exs @@ -12,7 +12,6 @@ defmodule DiffoExample.Access.CableTest do alias DiffoExample.Access.Cable alias DiffoExample.Access.IntegerUnit alias DiffoExample.Test.Characteristics - alias DiffoExample.Util describe "build cable" do test "create a cable" do @@ -39,11 +38,9 @@ defmodule DiffoExample.Access.CableTest do encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(cable) assert encoding == - ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"}}) - |> Util.summarise_characteristics(cable) + ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"cable\",\"value\":{}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":1,\"algorithm\":\"lowest\"}}]}) end test "define cable" do @@ -67,11 +64,9 @@ defmodule DiffoExample.Access.CableTest do encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(cable) assert encoding == - ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\"}) - |> Util.summarise_characteristics(cable) + ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceCharacteristic\":[{\"name\":\"cable\",\"value\":{\"pairs\":60,\"length\":{\"amount\":600,\"unit\":\"m\"},\"technology\":\"PIUT\"}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":60,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]}) end test "auto assign pair to service" do @@ -96,11 +91,9 @@ defmodule DiffoExample.Access.CableTest do encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(cable) assert encoding == - ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":1}]}]}) - |> Util.summarise_characteristics(cable) + ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":1}]}],\"resourceCharacteristic\":[{\"name\":\"cable\",\"value\":{\"pairs\":60,\"length\":{\"amount\":600,\"unit\":\"m\"},\"technology\":\"PIUT\"}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":60,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]}) end test "auto assign two pairs to same service" do @@ -130,11 +123,9 @@ defmodule DiffoExample.Access.CableTest do encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(cable) assert encoding == - ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":1}]},{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":2}]}]}) - |> Util.summarise_characteristics(cable) + ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":1}]},{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":2}]}],\"resourceCharacteristic\":[{\"name\":\"cable\",\"value\":{\"pairs\":60,\"length\":{\"amount\":600,\"unit\":\"m\"},\"technology\":\"PIUT\"}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":60,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]}) end test "specific assignment rejects duplicate request" do @@ -164,11 +155,9 @@ defmodule DiffoExample.Access.CableTest do encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(cable) assert encoding == - ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":5}]}]}) - |> Util.summarise_characteristics(cable) + ~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"description\":\"A Cable Resource Instance\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":5}]}],\"resourceCharacteristic\":[{\"name\":\"cable\",\"value\":{\"pairs\":60,\"length\":{\"amount\":600,\"unit\":\"m\"},\"technology\":\"PIUT\"}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":60,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]}) end end end diff --git a/test/access/card_test.exs b/test/access/card_test.exs index cca2682..d27afdd 100644 --- a/test/access/card_test.exs +++ b/test/access/card_test.exs @@ -11,7 +11,6 @@ defmodule DiffoExample.Access.CardTest do alias DiffoExample.Access alias DiffoExample.Access.Card alias DiffoExample.Test.Characteristics - alias DiffoExample.Util describe "build card" do test "create a card" do @@ -38,11 +37,9 @@ defmodule DiffoExample.Access.CardTest do encoding = Jason.encode!(card) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(card) assert encoding == - ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"}}) - |> Util.summarise_characteristics(card) + ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"card\",\"value\":{}},{\"name\":\"ports\",\"value\":{\"first\":1,\"last\":1,\"algorithm\":\"lowest\"}}]}) end test "define card" do @@ -66,11 +63,9 @@ defmodule DiffoExample.Access.CardTest do encoding = Jason.encode!(card) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(card) assert encoding == - ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\"}) - |> Util.summarise_characteristics(card) + ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceCharacteristic\":[{\"name\":\"card\",\"value\":{\"family\":\"ISAM\",\"model\":\"EBLT48\",\"technology\":\"adsl2Plus\"}},{\"name\":\"ports\",\"value\":{\"first\":1,\"last\":48,\"type\":\"ADSL2+\",\"algorithm\":\"lowest\"}}]}) end test "auto assign port to service" do @@ -95,11 +90,9 @@ defmodule DiffoExample.Access.CardTest do encoding = Jason.encode!(card) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(card) assert encoding == - ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":1}]}]}) - |> Util.summarise_characteristics(card) + ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":1}]}],\"resourceCharacteristic\":[{\"name\":\"card\",\"value\":{\"family\":\"ISAM\",\"model\":\"EBLT48\",\"technology\":\"adsl2Plus\"}},{\"name\":\"ports\",\"value\":{\"first\":1,\"last\":48,\"type\":\"ADSL2+\",\"algorithm\":\"lowest\"}}]}) end test "auto assign two ports to same service" do @@ -129,11 +122,9 @@ defmodule DiffoExample.Access.CardTest do encoding = Jason.encode!(card) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(card) assert encoding == - ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":1}]},{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":2}]}]}) - |> Util.summarise_characteristics(card) + ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":1}]},{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":2}]}],\"resourceCharacteristic\":[{\"name\":\"card\",\"value\":{\"family\":\"ISAM\",\"model\":\"EBLT48\",\"technology\":\"adsl2Plus\"}},{\"name\":\"ports\",\"value\":{\"first\":1,\"last\":48,\"type\":\"ADSL2+\",\"algorithm\":\"lowest\"}}]}) end test "specific assignment rejects duplicate request" do @@ -163,11 +154,9 @@ defmodule DiffoExample.Access.CardTest do encoding = Jason.encode!(card) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(card) assert encoding == - ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":5}]}]}) - |> Util.summarise_characteristics(card) + ~s({\"id\":\"#{card.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{card.id}",\"category\":\"Network Resource\",\"description\":\"A Card Resource Instance\",\"resourceSpecification\":{\"id\":\"cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/cd29956f-6c68-44cc-bf54-705eb8d2f754\",\"name\":\"card\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"port\",\"value\":5}]}],\"resourceCharacteristic\":[{\"name\":\"card\",\"value\":{\"family\":\"ISAM\",\"model\":\"EBLT48\",\"technology\":\"adsl2Plus\"}},{\"name\":\"ports\",\"value\":{\"first\":1,\"last\":48,\"type\":\"ADSL2+\",\"algorithm\":\"lowest\"}}]}) end end end diff --git a/test/access/dsl_access_test.exs b/test/access/dsl_access_test.exs index 8478e74..9815384 100644 --- a/test/access/dsl_access_test.exs +++ b/test/access/dsl_access_test.exs @@ -15,7 +15,6 @@ defmodule DiffoExample.Access.DslAccessTest do alias DiffoExample.Access.DslAccess alias DiffoExample.Test.Parties alias DiffoExample.Test.Places - alias DiffoExample.Util describe "service qualification" do test "create an initial service for service qualification" do @@ -71,14 +70,12 @@ defmodule DiffoExample.Access.DslAccessTest do encoding = Jason.encode!(dsl_access) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(dsl_access) assert encoding == - ~s({\"id\":\"#{dsl_access.id}",\"href\":\"serviceInventoryManagement/v4/service/#{dsl_access.id}\",\"category\":\"Network Service\",\"description\":\"A DSL Access Network Service connecting a subscriber premises to an NNI\",\"serviceSpecification\":{\"id\":\"da9b207a-26c3-451d-8abd-0640c6349979\",\"href\":\"serviceCatalogManagement/v4/serviceSpecification/da9b207a-26c3-451d-8abd-0640c6349979\",\"name\":\"dslAccess\",\"version\":\"v1.0.0\"},\"serviceDate\":\"now\",\"state\":\"initial\",\"feature\":[{\"name\":\"dynamic_line_management\",\"isEnabled\":true,\"featureCharacteristic\":[{\"name\":\"constraints\",\"value\":{}}]}],\"serviceCharacteristic\":[{\"name\":\"aggregate_interface\",\"value\":{\"physicalLayer\":\"GbE\",\"linkLayer\":\"QinQ\",\"svlanId\":0,\"VPI\":0}},{\"name\":\"circuit\",\"value\":{\"cvlan_id\":0,\"VCI\":0,\"encapsulation\":\"IPoE\"}},{\"name\":\"dslam\",\"value\":{\"family\":\"ISAM\",\"technology\":\"eth\"}},{\"name\":\"line\",\"value\":{\"standard\":\"ADSL2plus\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"IND000000897354\",\"name\":\"individualId\",\"role\":\"Customer\",\"@referredType\":\"Individual\",\"@type\":\"PartyRef\"},{\"id\":\"ORG000000123456\",\"name\":\"organizationId\",\"role\":\"Reseller\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(dsl_access) + ~s({\"id\":\"#{dsl_access.id}",\"href\":\"serviceInventoryManagement/v4/service/#{dsl_access.id}\",\"category\":\"Network Service\",\"description\":\"A DSL Access Network Service connecting a subscriber premises to an NNI\",\"serviceSpecification\":{\"id\":\"da9b207a-26c3-451d-8abd-0640c6349979\",\"href\":\"serviceCatalogManagement/v4/serviceSpecification/da9b207a-26c3-451d-8abd-0640c6349979\",\"name\":\"dslAccess\",\"version\":\"v1.0.0\"},\"serviceDate\":\"now\",\"state\":\"initial\",\"feature\":[{\"name\":\"dynamic_line_management\",\"isEnabled\":true}],\"serviceCharacteristic\":[{\"name\":\"dslam\",\"value\":{}},{\"name\":\"aggregate_interface\",\"value\":{}},{\"name\":\"circuit\",\"value\":{}},{\"name\":\"line\",\"value\":{}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"IND000000897354\",\"name\":\"individualId\",\"role\":\"Customer\",\"@referredType\":\"Individual\",\"@type\":\"PartyRef\"},{\"id\":\"ORG000000123456\",\"name\":\"organizationId\",\"role\":\"Reseller\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end - test "advance service to inactive" do + test "advance service to feasibilityChecked" do initial_parties = create_initial_parties() initial_place = create_initial_place() @@ -95,7 +92,7 @@ defmodule DiffoExample.Access.DslAccessTest do # check the instance is a DslAccess assert is_struct(dsl_access, DslAccess) - assert dsl_access.service_state == :inactive + assert dsl_access.service_state == :feasibilityChecked assert dsl_access.service_operating_status == :feasible Places.check_places([initial_place | [esa_place]], dsl_access) @@ -103,11 +100,9 @@ defmodule DiffoExample.Access.DslAccessTest do encoding = Jason.encode!(dsl_access) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(dsl_access) assert encoding == - ~s({\"id\":\"#{dsl_access.id}",\"href\":\"serviceInventoryManagement/v4/service/#{dsl_access.id}\",\"category\":\"Network Service\",\"description\":\"A DSL Access Network Service connecting a subscriber premises to an NNI\",\"serviceSpecification\":{\"id\":\"da9b207a-26c3-451d-8abd-0640c6349979\",\"href\":\"serviceCatalogManagement/v4/serviceSpecification/da9b207a-26c3-451d-8abd-0640c6349979\",\"name\":\"dslAccess\",\"version\":\"v1.0.0\"},\"serviceDate\":\"now\",\"state\":\"inactive\",\"operatingStatus\":\"feasible\",\"feature\":[{\"name\":\"dynamic_line_management\",\"isEnabled\":true,\"featureCharacteristic\":[{\"name\":\"constraints\",\"value\":{}}]}],\"serviceCharacteristic\":[{\"name\":\"aggregate_interface\",\"value\":{\"physicalLayer\":\"GbE\",\"linkLayer\":\"QinQ\",\"svlanId\":0,\"VPI\":0}},{\"name\":\"circuit\",\"value\":{\"cvlan_id\":0,\"VCI\":0,\"encapsulation\":\"IPoE\"}},{\"name\":\"dslam\",\"value\":{\"family\":\"ISAM\",\"technology\":\"eth\"}},{\"name\":\"line\",\"value\":{\"standard\":\"ADSL2plus\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"IND000000897354\",\"name\":\"individualId\",\"role\":\"Customer\",\"@referredType\":\"Individual\",\"@type\":\"PartyRef\"},{\"id\":\"ORG000000123456\",\"name\":\"organizationId\",\"role\":\"Reseller\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(dsl_access) + ~s({\"id\":\"#{dsl_access.id}",\"href\":\"serviceInventoryManagement/v4/service/#{dsl_access.id}\",\"category\":\"Network Service\",\"description\":\"A DSL Access Network Service connecting a subscriber premises to an NNI\",\"serviceSpecification\":{\"id\":\"da9b207a-26c3-451d-8abd-0640c6349979\",\"href\":\"serviceCatalogManagement/v4/serviceSpecification/da9b207a-26c3-451d-8abd-0640c6349979\",\"name\":\"dslAccess\",\"version\":\"v1.0.0\"},\"serviceDate\":\"now\",\"state\":\"feasibilityChecked\",\"operatingStatus\":\"feasible\",\"feature\":[{\"name\":\"dynamic_line_management\",\"isEnabled\":true}],\"serviceCharacteristic\":[{\"name\":\"dslam\",\"value\":{}},{\"name\":\"aggregate_interface\",\"value\":{}},{\"name\":\"circuit\",\"value\":{}},{\"name\":\"line\",\"value\":{}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"IND000000897354\",\"name\":\"individualId\",\"role\":\"Customer\",\"@referredType\":\"Individual\",\"@type\":\"PartyRef\"},{\"id\":\"ORG000000123456\",\"name\":\"organizationId\",\"role\":\"Reseller\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end end @@ -148,11 +143,9 @@ defmodule DiffoExample.Access.DslAccessTest do encoding = Jason.encode!(dsl_access) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(dsl_access) assert encoding == - ~s({\"id\":\"#{dsl_access.id}",\"href\":\"serviceInventoryManagement/v4/service/#{dsl_access.id}\",\"category\":\"Network Service\",\"description\":\"A DSL Access Network Service connecting a subscriber premises to an NNI\",\"serviceSpecification\":{\"id\":\"da9b207a-26c3-451d-8abd-0640c6349979\",\"href\":\"serviceCatalogManagement/v4/serviceSpecification/da9b207a-26c3-451d-8abd-0640c6349979\",\"name\":\"dslAccess\",\"version\":\"v1.0.0\"},\"serviceDate\":\"now\",\"state\":\"reserved\",\"operatingStatus\":\"feasible\",\"feature\":[{\"name\":\"dynamic_line_management\",\"isEnabled\":true,\"featureCharacteristic\":[{\"name\":\"constraints\",\"value\":{}}]}],\"serviceCharacteristic\":[{\"name\":\"aggregate_interface\",\"value\":{\"name\":\"eth0\",\"physicalLayer\":\"GbE\",\"linkLayer\":\"QinQ\",\"svlanId\":3108,\"VPI\":0}},{\"name\":\"circuit\",\"value\":{\"cvlan_id\":82,\"VCI\":0,\"encapsulation\":\"IPoE\"}},{\"name\":\"dslam\",\"value\":{\"name\":\"QDONC0001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"eth\"}},{\"name\":\"line\",\"value\":{\"port\":5,\"slot\":10,\"standard\":\"ADSL2plus\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"IND000000897354\",\"name\":\"individualId\",\"role\":\"Customer\",\"@referredType\":\"Individual\",\"@type\":\"PartyRef\"},{\"id\":\"ORG000000123456\",\"name\":\"organizationId\",\"role\":\"Reseller\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(dsl_access) + ~s({\"id\":\"#{dsl_access.id}",\"href\":\"serviceInventoryManagement/v4/service/#{dsl_access.id}\",\"category\":\"Network Service\",\"description\":\"A DSL Access Network Service connecting a subscriber premises to an NNI\",\"serviceSpecification\":{\"id\":\"da9b207a-26c3-451d-8abd-0640c6349979\",\"href\":\"serviceCatalogManagement/v4/serviceSpecification/da9b207a-26c3-451d-8abd-0640c6349979\",\"name\":\"dslAccess\",\"version\":\"v1.0.0\"},\"serviceDate\":\"now\",\"state\":\"reserved\",\"operatingStatus\":\"feasible\",\"feature\":[{\"name\":\"dynamic_line_management\",\"isEnabled\":true}],\"serviceCharacteristic\":[{\"name\":\"dslam\",\"value\":{\"name\":\"QDONC0001\",\"model\":\"ISAM7330\"}},{\"name\":\"aggregate_interface\",\"value\":{\"name\":\"eth0\",\"svlanId\":3108}},{\"name\":\"circuit\",\"value\":{\"cvlan_id\":82}},{\"name\":\"line\",\"value\":{\"port\":5,\"slot\":10}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"IND000000897354\",\"name\":\"individualId\",\"role\":\"Customer\",\"@referredType\":\"Individual\",\"@type\":\"PartyRef\"},{\"id\":\"ORG000000123456\",\"name\":\"organizationId\",\"role\":\"Reseller\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end end diff --git a/test/access/path_test.exs b/test/access/path_test.exs index 1a135c7..c929ffa 100644 --- a/test/access/path_test.exs +++ b/test/access/path_test.exs @@ -16,7 +16,6 @@ defmodule DiffoExample.Access.PathTest do alias DiffoExample.Access.Path alias DiffoExample.Test.Parties alias DiffoExample.Test.Places - alias DiffoExample.Util describe "build path" do test "create a path" do @@ -52,11 +51,9 @@ defmodule DiffoExample.Access.PathTest do encoding = Jason.encode!(path) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(path) assert encoding == - ~s({\"id\":\"#{path.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{path.id}",\"category\":\"Network Resource\",\"description\":\"A Path Resource Instance\",\"name\":\"82 Rathmullen - DONC\",\"resourceSpecification\":{\"id\":\"1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"name\":\"path\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"path\",\"value\":{\"sections\":0}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC\",\"href\":\"place/telco/DONC\",\"name\":\"exchangeId\",\"role\":\"NetworkSite\",\"@referredType\":\"GeographicSite\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(path) + ~s({\"id\":\"#{path.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{path.id}",\"category\":\"Network Resource\",\"description\":\"A Path Resource Instance\",\"name\":\"82 Rathmullen - DONC\",\"resourceSpecification\":{\"id\":\"1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"name\":\"path\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"path\",\"value\":{}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC\",\"href\":\"place/telco/DONC\",\"name\":\"exchangeId\",\"role\":\"NetworkSite\",\"@referredType\":\"GeographicSite\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end end @@ -76,11 +73,9 @@ defmodule DiffoExample.Access.PathTest do encoding = Jason.encode!(path) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(path) assert encoding == - ~s({\"id\":\"#{path.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{path.id}",\"category\":\"Network Resource\",\"description\":\"A Path Resource Instance\",\"name\":\"82 Rathmullen - DONC\",\"resourceSpecification\":{\"id\":\"1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"name\":\"path\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"path\",\"value\":{\"name\":\"82 Rathmullen - DONC\",\"sections\":0,\"technology\":\"copper\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC\",\"href\":\"place/telco/DONC\",\"name\":\"exchangeId\",\"role\":\"NetworkSite\",\"@referredType\":\"GeographicSite\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(path) + ~s({\"id\":\"#{path.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{path.id}",\"category\":\"Network Resource\",\"description\":\"A Path Resource Instance\",\"name\":\"82 Rathmullen - DONC\",\"resourceSpecification\":{\"id\":\"1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"name\":\"path\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"path\",\"value\":{\"name\":\"82 Rathmullen - DONC\",\"technology\":\"copper\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC\",\"href\":\"place/telco/DONC\",\"name\":\"exchangeId\",\"role\":\"NetworkSite\",\"@referredType\":\"GeographicSite\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end test "relate cables and dslam" do @@ -143,12 +138,10 @@ defmodule DiffoExample.Access.PathTest do encoding = Jason.encode!(path) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(path) # the reverse relationships are not encoded to json assert encoding == - ~s({\"id\":\"#{path.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{path.id}",\"category\":\"Network Resource\",\"description\":\"A Path Resource Instance\",\"name\":\"82 Rathmullen - DONC\",\"resourceSpecification\":{\"id\":\"1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"name\":\"path\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"path\",\"value\":{\"name\":\"82 Rathmullen - DONC\",\"sections\":0,\"technology\":\"copper\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC\",\"href\":\"place/telco/DONC\",\"name\":\"exchangeId\",\"role\":\"NetworkSite\",\"@referredType\":\"GeographicSite\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(path) + ~s({\"id\":\"#{path.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{path.id}",\"category\":\"Network Resource\",\"description\":\"A Path Resource Instance\",\"name\":\"82 Rathmullen - DONC\",\"resourceSpecification\":{\"id\":\"1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/1d507914-8f76-48cb-aa0e-3a8f92951ab0\",\"name\":\"path\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"path\",\"value\":{\"name\":\"82 Rathmullen - DONC\",\"technology\":\"copper\"}}],\"place\":[{\"id\":\"1657363\",\"href\":\"place/telco/1657363\",\"name\":\"addressId\",\"role\":\"CustomerSite\",\"@referredType\":\"GeographicAddress\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC\",\"href\":\"place/telco/DONC\",\"name\":\"exchangeId\",\"role\":\"NetworkSite\",\"@referredType\":\"GeographicSite\",\"@type\":\"PlaceRef\"},{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end defp create_customer_place do diff --git a/test/access/shelf_test.exs b/test/access/shelf_test.exs index 0f31cce..1211a92 100644 --- a/test/access/shelf_test.exs +++ b/test/access/shelf_test.exs @@ -17,7 +17,6 @@ defmodule DiffoExample.Access.ShelfTest do alias DiffoExample.Test.Characteristics alias DiffoExample.Test.Parties alias DiffoExample.Test.Places - alias DiffoExample.Util describe "build shelf" do test "create a shelf" do @@ -52,11 +51,9 @@ defmodule DiffoExample.Access.ShelfTest do encoding = Jason.encode!(shelf) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(shelf) assert encoding == - ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"name\":\"QDONC-0001\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":1,\"free\":1,\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(shelf) + ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"name\":\"QDONC-0001\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":1,\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end end @@ -75,11 +72,9 @@ defmodule DiffoExample.Access.ShelfTest do encoding = Jason.encode!(shelf) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(shelf) assert encoding == - ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"name\":\"QDONC-0001\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{\"name\":\"QDONC-1001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"DSLAM\"}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":10,\"free\":10,\"type\":\"LineCard\",\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(shelf) + ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"name\":\"QDONC-0001\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{\"name\":\"QDONC-1001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"DSLAM\"}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":10,\"type\":\"LineCard\",\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end test "relate common cards" do @@ -102,14 +97,12 @@ defmodule DiffoExample.Access.ShelfTest do encoding = Jason.encode!(shelf) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(shelf) [card0, card1, card2, card3] = cards # resource relationships are sorted in the create order of the relationships assert encoding == - ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceRelationship\":[{\"type\":\"contains\",\"resource\":{\"id\":\"#{card0.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card0.id}\"}},{\"type\":\"contains\",\"resource\":{\"id\":\"#{card1.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card1.id}\"}},{\"type\":\"contains\",\"resource\":{\"id\":\"#{card2.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card2.id}\"}},{\"type\":\"contains\",\"resource\":{\"id\":\"#{card3.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card3.id}\"}}],\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{\"name\":\"QDONC-1001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"DSLAM\"}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":10,\"free\":10,\"type\":\"LineCard\",\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(shelf) + ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceRelationship\":[{\"type\":\"contains\",\"resource\":{\"id\":\"#{card0.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card0.id}\"}},{\"type\":\"contains\",\"resource\":{\"id\":\"#{card1.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card1.id}\"}},{\"type\":\"contains\",\"resource\":{\"id\":\"#{card2.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card2.id}\"}},{\"type\":\"contains\",\"resource\":{\"id\":\"#{card3.id}\",\"href\":\"resourceInventoryManagement/v4/resource/#{card3.id}\"}}],\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{\"name\":\"QDONC-1001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"DSLAM\"}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":10,\"type\":\"LineCard\",\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end test "auto assign line cards" do @@ -135,14 +128,12 @@ defmodule DiffoExample.Access.ShelfTest do encoding = Jason.encode!(shelf) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(shelf) lc1 = line_card1.assignee_id lc2 = line_card2.assignee_id assert encoding == - ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"name\":\"QDONC-0001\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceRelationship\":[{\"type\":\"assignedTo\",\"resource\":{\"id\":\"#{lc1}\",\"href\":\"resourceInventoryManagement/v4/resource/#{lc1}\"},\"resourceRelationshipCharacteristic\":[{\"name\":\"slot\",\"value\":1}]},{\"type\":\"assignedTo\",\"resource\":{\"id\":\"#{lc2}\",\"href\":\"resourceInventoryManagement/v4/resource/#{lc2}\"},\"resourceRelationshipCharacteristic\":[{\"name\":\"slot\",\"value\":2}]}],\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{\"name\":\"QDONC-1001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"DSLAM\"}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":10,\"free\":8,\"type\":\"LineCard\",\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) - |> Util.summarise_characteristics(shelf) + ~s({\"id\":\"#{shelf.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{shelf.id}",\"category\":\"Network Resource\",\"description\":\"A Shelf Resource Instance which contain cards\",\"name\":\"QDONC-0001\",\"resourceSpecification\":{\"id\":\"ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ef016d85-9dbd-429c-84da-1df56cc7dda5\",\"name\":\"shelf\",\"version\":\"v1.0.0\"},\"lifecycleState\":\"operating\",\"resourceRelationship\":[{\"type\":\"assignedTo\",\"resource\":{\"id\":\"#{lc1}\",\"href\":\"resourceInventoryManagement/v4/resource/#{lc1}\"},\"resourceRelationshipCharacteristic\":[{\"name\":\"slot\",\"value\":1}]},{\"type\":\"assignedTo\",\"resource\":{\"id\":\"#{lc2}\",\"href\":\"resourceInventoryManagement/v4/resource/#{lc2}\"},\"resourceRelationshipCharacteristic\":[{\"name\":\"slot\",\"value\":2}]}],\"resourceCharacteristic\":[{\"name\":\"shelf\",\"value\":{\"name\":\"QDONC-1001\",\"family\":\"ISAM\",\"model\":\"ISAM7330\",\"technology\":\"DSLAM\"}},{\"name\":\"slots\",\"value\":{\"first\":1,\"last\":10,\"type\":\"LineCard\",\"algorithm\":\"lowest\"}}],\"place\":[{\"id\":\"DONC-0001\",\"href\":\"place/telco/DONC-0001\",\"name\":\"esaId\",\"role\":\"ServingArea\",\"@referredType\":\"GeographicLocation\",\"@type\":\"PlaceRef\"}],\"relatedParty\":[{\"id\":\"Access\",\"name\":\"organizationId\",\"role\":\"Provider\",\"@referredType\":\"Organization\",\"@type\":\"PartyRef\"}]}) end defp create_common_cards() do diff --git a/test/nbn/nbn_ethernet_test.exs b/test/nbn/nbn_ethernet_test.exs index fb1677a..640b4e0 100644 --- a/test/nbn/nbn_ethernet_test.exs +++ b/test/nbn/nbn_ethernet_test.exs @@ -16,7 +16,6 @@ defmodule DiffoExample.Nbn.NbnEthernetTest do alias DiffoExample.Nbn.NniGroup alias DiffoExample.Nbn.Nni alias DiffoExample.Test.Characteristics - alias DiffoExample.Util alias Diffo.Provider.Assignment alias Diffo.Provider.Instance.Relationship @@ -47,11 +46,9 @@ defmodule DiffoExample.Nbn.NbnEthernetTest do encoding = Jason.encode!(access) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(access) assert encoding == ~s({"id":"#{access.id}","href":"resourceInventoryManagement/v4/resource/#{access.id}","category":"Network Resource","description":"An NBN Ethernet access comprising a dedicated UNI and AVC",\"name\":\"#{access.name}","resourceSpecification":{"id":"f2a4c6e8-1b3d-4f5a-8c7e-9d0b2e4f6a8c","href":"resourceCatalogManagement/v4/resourceSpecification/f2a4c6e8-1b3d-4f5a-8c7e-9d0b2e4f6a8c","name":"nbnEthernet","version":"v1.0.0"},"resourceCharacteristic":[{"name":"pri","value":{}}]}) - |> Util.summarise_characteristics(access) end test "define nbn_ethernet access" do @@ -144,11 +141,9 @@ defmodule DiffoExample.Nbn.NbnEthernetTest do encoding = Jason.encode!(access) |> Diffo.Util.summarise_dates() - |> Util.summarise_characteristics(access) assert encoding == - ~s({"id":"#{access.id}","href":"resourceInventoryManagement/v4/resource/#{access.id}","category":"Network Resource","description":"An NBN Ethernet access comprising a dedicated UNI and AVC","name":"#{access.name}","resourceSpecification":{"id":"f2a4c6e8-1b3d-4f5a-8c7e-9d0b2e4f6a8c","href":"resourceCatalogManagement/v4/resourceSpecification/f2a4c6e8-1b3d-4f5a-8c7e-9d0b2e4f6a8c","name":"nbnEthernet","version":"v1.0.0"},"resourceRelationship":[{"alias":"avc","type":"owns","resource":{"id":"#{avc.id}","href":"resourceInventoryManagement/v4/resource/#{avc.id}"}},{"alias":"uni","type":"owns","resource":{"id\":"#{uni.id}","href":"resourceInventoryManagement/v4/resource/#{uni.id}"}}],"supportingResource":[{"id":"avc","href":"resourceInventoryManagement/v4/resource/#{avc.id}"},{"id\":"uni","href":"resourceInventoryManagement/v4/resource/#{uni.id}"}],"resourceCharacteristic":[{"name":"pri","value":{"AVCID":"#{avc.name}","UNIID":"#{uni.name}","technology":"FTTP","bandwidthProfile":"home_fast","speeds":[500,50]}}]}) - |> Util.summarise_characteristics(access) + ~s({"id":"#{access.id}","href":"resourceInventoryManagement/v4/resource/#{access.id}","category":"Network Resource","description":"An NBN Ethernet access comprising a dedicated UNI and AVC","name":"#{access.name}","resourceSpecification":{"id":"f2a4c6e8-1b3d-4f5a-8c7e-9d0b2e4f6a8c","href":"resourceCatalogManagement/v4/resourceSpecification/f2a4c6e8-1b3d-4f5a-8c7e-9d0b2e4f6a8c","name":"nbnEthernet","version":"v1.0.0"},"resourceRelationship":[{"alias":"avc","type":"owns","resource":{"id":"#{avc.id}","href":"resourceInventoryManagement/v4/resource/#{avc.id}"}},{"alias":"uni","type":"owns","resource":{"id\":"#{uni.id}","href":"resourceInventoryManagement/v4/resource/#{uni.id}"}}],"supportingResource":[{"id":"avc","href":"resourceInventoryManagement/v4/resource/#{avc.id}"},{"id\":"uni","href":"resourceInventoryManagement/v4/resource/#{uni.id}"}],"resourceCharacteristic":[{"name":"pri","value":{}}]}) end end