Skip to content

Commit 4c7b75f

Browse files
Merge pull request #18 from diffo-dev/nbn-domain-dev
rebase nbn domain
2 parents 8768002 + 9b7ca44 commit 4c7b75f

13 files changed

Lines changed: 62 additions & 68 deletions

File tree

lib/access/resources/characteristic_values/cable_value.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ defmodule DiffoExample.Access.CableValue do
2424

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

27-
field :length, :struct,
28-
constraints: [instance_of: IntegerUnit],
29-
description: "the length of the cable"
27+
field :length, DiffoExample.Access.IntegerUnit, description: "the length of the cable"
3028

31-
field :loss, :struct,
32-
constraints: [instance_of: FloatUnit],
33-
description: "the loss of the cable at 300kHz"
29+
field :loss, DiffoExample.Access.FloatUnit, description: "the loss of the cable at 300kHz"
3430

3531
field :technology, :atom, description: "the cable technology"
3632
end

lib/access/resources/characteristic_values/path_value.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ defmodule DiffoExample.Access.PathValue do
2727
constraints: [min: 0],
2828
description: "the number of sections in the path"
2929

30-
field :length, :struct,
31-
constraints: [instance_of: IntegerUnit],
32-
description: "the length of the path"
30+
field :length, DiffoExample.Access.IntegerUnit, description: "the length of the path"
3331

34-
field :loss, :struct,
35-
constraints: [instance_of: FloatUnit],
36-
description: "the loss of the path at 300kHz"
32+
field :loss, DiffoExample.Access.FloatUnit, description: "the loss of the path at 300kHz"
3733

3834
field :technology, :atom, description: "the path technology"
3935
end

lib/access/services/characteristic_values/circuit.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ defmodule DiffoExample.Access.Circuit do
4141
constraints: [one_of: [:PPPoA, :PPPoE, :IPoE]],
4242
description: "the circuit encapsulation"
4343

44-
field :bandwidth_profile, :struct,
45-
constraints: [instance_of: BandwidthProfile],
44+
field :bandwidth_profile, BandwidthProfile,
4645
description: "the circuit bandwidth profile"
4746
end
4847

lib/access/util.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ defmodule DiffoExample.Access.Util do
3030
_ ->
3131
[
3232
%Assignment{
33-
id: characteristic.value,
34-
type: type,
33+
id: Diffo.Unwrap.unwrap(characteristic.value),
34+
assignable_type: type,
3535
assignee_id: reverse_relationship.source_id
3636
}
3737
| acc

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ defmodule DiffoExample.MixProject do
7878
# Run "mix help deps" to learn about dependencies.
7979
defp deps do
8080
[
81-
{:diffo, diffo_version("~> 0.1.6")},
81+
# {:diffo, diffo_version("~> 0.1.6")},
82+
{:diffo, github: "diffo-dev/diffo", branch: "dev"},
8283
{:igniter, "~> 0.6", only: [:dev, :test]},
8384
{:ex_doc, "~> 0.37", only: [:dev, :test], runtime: false}
8485
]

mix.lock

Lines changed: 9 additions & 9 deletions
Large diffs are not rendered by default.

test/access/cable_test.exs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@ defmodule DiffoExample.Access.CableTest do
6363
encoding = Jason.encode!(cable) |> Diffo.Util.summarise_dates()
6464

6565
assert encoding ==
66-
~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\"}}]})
66+
~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\"}}]})
6767
end
6868

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

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

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

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

8181
assert encoding ==
82-
~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\"}}]})
82+
~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\"}}]})
8383
end
8484

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

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

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

106106
assert encoding ==
107-
~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\"}}]})
107+
~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\"}}]})
108108
end
109109

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

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

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

136136
assert encoding ==
137-
~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\"}}]})
137+
~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\"}}]})
138138
end
139139

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

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

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

166166
assert encoding ==
167-
~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\"}}]})
167+
~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\"}}]})
168168
end
169169
end
170170
end

0 commit comments

Comments
 (0)