Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/access/resources/characteristic_values/cable_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ defmodule DiffoExample.Access.CableValue do

field :pairs, :integer, description: "the number of pairs in the cable"

field :length, :struct,
constraints: [instance_of: IntegerUnit],
description: "the length of the cable"
field :length, DiffoExample.Access.IntegerUnit, description: "the length of the cable"

field :loss, :struct,
constraints: [instance_of: FloatUnit],
description: "the loss of the cable at 300kHz"
field :loss, DiffoExample.Access.FloatUnit, description: "the loss of the cable at 300kHz"

field :technology, :atom, description: "the cable technology"
end
Expand Down
8 changes: 2 additions & 6 deletions lib/access/resources/characteristic_values/path_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ defmodule DiffoExample.Access.PathValue do
constraints: [min: 0],
description: "the number of sections in the path"

field :length, :struct,
constraints: [instance_of: IntegerUnit],
description: "the length of the path"
field :length, DiffoExample.Access.IntegerUnit, description: "the length of the path"

field :loss, :struct,
constraints: [instance_of: FloatUnit],
description: "the loss of the path at 300kHz"
field :loss, DiffoExample.Access.FloatUnit, description: "the loss of the path at 300kHz"

field :technology, :atom, description: "the path technology"
end
Expand Down
3 changes: 1 addition & 2 deletions lib/access/services/characteristic_values/circuit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ defmodule DiffoExample.Access.Circuit do
constraints: [one_of: [:PPPoA, :PPPoE, :IPoE]],
description: "the circuit encapsulation"

field :bandwidth_profile, :struct,
constraints: [instance_of: BandwidthProfile],
field :bandwidth_profile, BandwidthProfile,
description: "the circuit bandwidth profile"
end

Expand Down
4 changes: 2 additions & 2 deletions lib/access/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ defmodule DiffoExample.Access.Util do
_ ->
[
%Assignment{
id: characteristic.value,
type: type,
id: Diffo.Unwrap.unwrap(characteristic.value),
assignable_type: type,
assignee_id: reverse_relationship.source_id
}
| acc
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ defmodule DiffoExample.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:diffo, diffo_version("~> 0.1.6")},
# {:diffo, diffo_version("~> 0.1.6")},
{:diffo, github: "diffo-dev/diffo", branch: "dev"},
{:igniter, "~> 0.6", only: [:dev, :test]},
{:ex_doc, "~> 0.37", only: [:dev, :test], runtime: false}
]
Expand Down
18 changes: 9 additions & 9 deletions mix.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions test/access/cable_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ defmodule DiffoExample.Access.CableTest do
encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates()

assert encoding ==
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/cable/#{cable.id}",\"category\":\"Network Resource\",\"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,\"free\":1,\"algorithm\":\"lowest\"}}]})
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"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,\"free\":1,\"algorithm\":\"lowest\"}}]})
end

test "define cable" do
{:ok, cable} = Access.build_cable(%{})

updates = [
cable: [pairs: 60, length: %IntegerUnit{amount: 600, unit: :m}, technology: :PIUT],
pairs: [first: 1, last: 60, free: 60, type: "copper"]
pairs: [first: 1, last: 60, free: 60, assignable_type: "copper"]
]

{:ok, cable} = Access.define_cable(cable, %{characteristic_value_updates: updates})

encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates()

assert encoding ==
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/cable/#{cable.id}",\"category\":\"Network Resource\",\"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\":{\"pairs\":60,\"length\":{\"amount\":600,\"unit\":\"m\"},\"technology\":\"PIUT\"}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":60,\"free\":60,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"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\":{\"pairs\":60,\"length\":{\"amount\":600,\"unit\":\"m\"},\"technology\":\"PIUT\"}},{\"name\":\"pairs\",\"value\":{\"first\":1,\"last\":60,\"free\":60,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
end

test "auto assign pair to service" do
Expand All @@ -89,7 +89,7 @@ defmodule DiffoExample.Access.CableTest do

updates = [
cable: [pairs: 60, length: %IntegerUnit{amount: 600, unit: :m}, technology: :PIUT],
pairs: [first: 1, last: 60, free: 60, type: "copper"]
pairs: [first: 1, last: 60, free: 60, assignable_type: "copper"]
]

{:ok, cable} = Access.define_cable(cable, %{characteristic_value_updates: updates})
Expand All @@ -104,7 +104,7 @@ defmodule DiffoExample.Access.CableTest do
encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates()

assert encoding ==
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/cable/#{cable.id}",\"category\":\"Network Resource\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/dslAccess/#{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,\"free\":59,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"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,\"free\":59,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
end

test "auto assign two pairs to same service" do
Expand All @@ -114,7 +114,7 @@ defmodule DiffoExample.Access.CableTest do

updates = [
cable: [pairs: 60, length: %IntegerUnit{amount: 600, unit: :m}, technology: :PIUT],
pairs: [first: 1, last: 60, free: 60, type: "copper"]
pairs: [first: 1, last: 60, free: 60, assignable_type: "copper"]
]

{:ok, cable} = Access.define_cable(cable, %{characteristic_value_updates: updates})
Expand All @@ -134,7 +134,7 @@ defmodule DiffoExample.Access.CableTest do
encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates()

assert encoding ==
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/cable/#{cable.id}",\"category\":\"Network Resource\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/dslAccess/#{assignee.id}\"},\"serviceRelationshipCharacteristic\":[{\"name\":\"pair\",\"value\":1}]},{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/dslAccess/#{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,\"free\":58,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"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,\"free\":58,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
end

test "specific assignment rejects duplicate request" do
Expand All @@ -144,7 +144,7 @@ defmodule DiffoExample.Access.CableTest do

updates = [
cable: [pairs: 60, length: %IntegerUnit{amount: 600, unit: :m}, technology: :PIUT],
pairs: [first: 1, last: 60, free: 60, type: "copper"]
pairs: [first: 1, last: 60, free: 60, assignable_type: "copper"]
]

{:ok, cable} = Access.define_cable(cable, %{characteristic_value_updates: updates})
Expand All @@ -164,7 +164,7 @@ defmodule DiffoExample.Access.CableTest do
encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates()

assert encoding ==
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/cable/#{cable.id}",\"category\":\"Network Resource\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"serviceRelationship\":[{\"type\":\"assignedTo\",\"service\":{\"id\":\"#{assignee.id}\",\"href\":\"serviceInventoryManagement/v4/service/dslAccess/#{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,\"free\":59,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
~s({\"id\":\"#{cable.id}",\"href\":\"resourceInventoryManagement/v4/resource/#{cable.id}",\"category\":\"Network Resource\",\"resourceSpecification\":{\"id\":\"ce0a567a-6abb-4862-9e33-851fd79fa595\",\"href\":\"resourceCatalogManagement/v4/resourceSpecification/ce0a567a-6abb-4862-9e33-851fd79fa595\",\"name\":\"cable\",\"version\":\"v1.0.0\"},\"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,\"free\":59,\"type\":\"copper\",\"algorithm\":\"lowest\"}}]})
end
end
end
Loading
Loading