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
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ defmodule Diffo.MixProject do
{:ash_outstanding, "~> 0.2.3"},
{:ash_jason, "~> 3.0"},
{:ash_state_machine, "~> 0.2.12"},
{:ash_neo4j, ash_neo4j_version("~> 0.2.14")},
{:ash_neo4j, ash_neo4j_version("~> 0.2.15")},
{:ash, ash_version("~> 3.0 and >= 3.19.1")},
{:uuid, "~> 1.1"},
{:igniter, ">= 0.6.29 and < 1.0.0-0",
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"ash": {:hex, :ash, "3.19.3", "58b1bb3aea3d1d45d1c990059ffd0753409cc92fc4afe387376cb155e2a8c2a0", [:mix], [{:crux, ">= 0.1.2 and < 1.0.0-0", [hex: :crux, repo: "hexpm", optional: false]}, {:decimal, "~> 2.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.3.14 and < 3.0.0-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", "94b628319f2e144affaf1f8008277bad3340a198d48e6d2ed372990ac1643f9b"},
"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_neo4j": {:hex, :ash_neo4j, "0.2.14", "c6bb1b895510ab423afc4225840d4c4e94716490316bf75aa8da1da464f53e0a", [:mix], [{:ash, ">= 3.19.1 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:bolty, ">= 0.0.7", [hex: :bolty, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "888bd4a9fcc3c231642dfb4cb9110d9aef8a57ff61f16f078bfd278cde17cd69"},
"ash_neo4j": {:hex, :ash_neo4j, "0.2.15", "1380f3a3f6b43fb346308808d621bd19b891b859431fd4b1ac26472fcee5b372", [:mix], [{:ash, ">= 3.19.1 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:bolty, ">= 0.0.7", [hex: :bolty, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8be0a84e02ce70d691b3619c1f7cb7c8e1d9daf001673a227b27762f3690ac40"},
"ash_outstanding": {:hex, :ash_outstanding, "0.2.4", "c72b91f1b8e4859fb033eddf66d0ba36cfd8af0c2a9748c7ef9e6ccfdb5d093d", [:mix], [{:ash, ">= 3.6.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:outstanding, "~> 0.2.4", [hex: :outstanding, repo: "hexpm", optional: false]}], "hexpm", "64ba8f582ce69c9050352c75f0895db186c7a56f35039dab34c8e1ab7516f9ce"},
"ash_state_machine": {:hex, :ash_state_machine, "0.2.12", "c0f7ebb8a176584f70c6ed196b7d0118c930d73e0590ade705d2dddc48aa7311", [:mix], [{:ash, ">= 3.4.66 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}], "hexpm", "394ce761ce82358e3c715e1cae6c5cf1390be27c03a8b661f2e5a2fda849873d"},
"bolty": {:hex, :bolty, "0.0.7", "257889f71bd16a9291bda8290c1018123c4084c8761f905b97d7176e65d8b111", [:mix], [{:db_connection, "~> 2.7.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 6.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm", "fc8f88b86d292ad1336f9e246a6c0452e64774b38fac0351c141549420946e5e"},
Expand Down
46 changes: 23 additions & 23 deletions test/assigner/assigner_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Diffo.Test.AssignerTest do
alias Diffo.Provider.Assignment

alias Diffo.Test.Characteristics
alias Diffo.Test.Domain
alias Diffo.Test.Servo
alias Diffo.Test.Card

setup_all do
Expand All @@ -25,7 +25,7 @@ defmodule Diffo.Test.AssignerTest do

describe "build card" do
test "create a card" do
{:ok, card} = Domain.build_card(%{})
{:ok, card} = Servo.build_card(%{})

# check the instance is a Card
assert is_struct(card, Card)
Expand Down Expand Up @@ -67,14 +67,14 @@ defmodule Diffo.Test.AssignerTest do
end

test "define card" do
{:ok, card} = Domain.build_card(%{})
{:ok, card} = Servo.build_card(%{})

updates = [
card: [family: :ISAM, model: "EBLT48", technology: :adsl2Plus],
ports: [first: 1, last: 48, free: 48, type: "ADSL2+"]
]

{:ok, card} = Domain.define_card(card, %{characteristic_value_updates: updates})
{:ok, card} = Servo.define_card(card, %{characteristic_value_updates: updates})

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

Expand All @@ -83,19 +83,19 @@ defmodule Diffo.Test.AssignerTest do
end

test "auto assign port to resource" do
{:ok, assignee} = Domain.build_shelf()
{:ok, assignee} = Servo.build_shelf()

{:ok, card} = Domain.build_card(%{})
{:ok, card} = Servo.build_card(%{})

updates = [
card: [family: :ISAM, model: "EBLT48", technology: :adsl2Plus],
ports: [first: 1, last: 48, free: 48, type: "ADSL2+"]
]

{:ok, card} = Domain.define_card(card, %{characteristic_value_updates: updates})
{:ok, card} = Servo.define_card(card, %{characteristic_value_updates: updates})

{:ok, card} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{assignee_id: assignee.id, operation: :auto_assign}
})

Expand All @@ -108,24 +108,24 @@ defmodule Diffo.Test.AssignerTest do
end

test "auto assign two ports to same resource" do
{:ok, assignee} = Domain.build_shelf()
{:ok, assignee} = Servo.build_shelf()

{:ok, card} = Domain.build_card(%{})
{:ok, card} = Servo.build_card(%{})

updates = [
card: [family: :ISAM, model: "EBLT48", technology: :adsl2Plus],
ports: [first: 1, last: 48, free: 48, type: "ADSL2+"]
]

{:ok, card} = Domain.define_card(card, %{characteristic_value_updates: updates})
{:ok, card} = Servo.define_card(card, %{characteristic_value_updates: updates})

{:ok, card} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{assignee_id: assignee.id, operation: :auto_assign}
})

{:ok, card} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{assignee_id: assignee.id, operation: :auto_assign}
})

Expand All @@ -138,24 +138,24 @@ defmodule Diffo.Test.AssignerTest do
end

test "specific assignment rejects duplicate request" do
{:ok, assignee} = Domain.build_shelf()
{:ok, assignee} = Servo.build_shelf()

{:ok, card} = Domain.build_card(%{})
{:ok, card} = Servo.build_card(%{})

updates = [
card: [family: :ISAM, model: "EBLT48", technology: :adsl2Plus],
ports: [first: 1, last: 48, free: 48, type: "ADSL2+"]
]

{:ok, card} = Domain.define_card(card, %{characteristic_value_updates: updates})
{:ok, card} = Servo.define_card(card, %{characteristic_value_updates: updates})

{:ok, card} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{id: 5, assignee_id: assignee.id, operation: :assign}
})

{:error, _error} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{id: 5, assignee_id: assignee.id, operation: :assign}
})

Expand All @@ -168,19 +168,19 @@ defmodule Diffo.Test.AssignerTest do
end

test "unassign an auto-assigned port from a resource" do
{:ok, assignee} = Domain.build_shelf()
{:ok, assignee} = Servo.build_shelf()

{:ok, card} = Domain.build_card(%{})
{:ok, card} = Servo.build_card(%{})

updates = [
card: [family: :ISAM, model: "EBLT48", technology: :adsl2Plus],
ports: [first: 1, last: 48, free: 48, type: "ADSL2+"]
]

{:ok, card} = Domain.define_card(card, %{characteristic_value_updates: updates})
{:ok, card} = Servo.define_card(card, %{characteristic_value_updates: updates})

{:ok, card} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{assignee_id: assignee.id, operation: :auto_assign}
})

Expand All @@ -193,7 +193,7 @@ defmodule Diffo.Test.AssignerTest do
|> Map.get(:value)

{:ok, card} =
Domain.assign_port(card, %{
Servo.assign_port(card, %{
assignment: %Assignment{
id: assigned_port,
assignee_id: assignee.id,
Expand Down
6 changes: 5 additions & 1 deletion test/provider/instance_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Diffo.Provider.InstanceTest do
end

setup do
on_exit(fn ->
on_exit(fn ->
AshNeo4j.Neo4jHelper.delete_all()
end)
end
Expand Down Expand Up @@ -80,6 +80,10 @@ defmodule Diffo.Provider.InstanceTest do
refute instance.service_operating_status
assert instance.specification.id == specification.id
assert instance.href == "serviceInventoryManagement/v4/service/fibreAccess/#{instance.id}"

# both specification and instance nodes are labelled :Provider
{:ok, response} = AshNeo4j.Neo4jHelper.read_nodes(:Provider)
assert length(response.results) == 2
end

test "create a service instance with a supplied id - success" do
Expand Down
1 change: 0 additions & 1 deletion test/provider/specification_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ defmodule Diffo.Provider.SpecificationTest do
assert is_struct(error, Ash.Error.Invalid)
end

@tag debug: true
test "delete specification - failure, related instance" do
specification = Diffo.Provider.create_specification!(%{name: "bdslAccess"})
instance = Diffo.Provider.create_instance!(%{specified_by: specification.id})
Expand Down
12 changes: 6 additions & 6 deletions test/support/resource/card.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ defmodule Diffo.Test.Card do
alias Diffo.Provider.Assigner
alias Diffo.Provider.Assignment
alias Diffo.Provider.AssignableValue
alias Diffo.Test.Domain
alias Diffo.Test.Servo
alias Diffo.Test.CardValue

use Ash.Resource,
fragments: [BaseInstance],
domain: Domain
domain: Servo

resource do
description "An Ash Resource representing a Card"
Expand Down Expand Up @@ -58,7 +58,7 @@ defmodule Diffo.Test.Card do
end)

change after_action(fn changeset, result, _context ->
ActionHelper.build_after(changeset, result, Domain, :get_card_by_id)
ActionHelper.build_after(changeset, result, Servo, :get_card_by_id)
end)

change load [:href]
Expand All @@ -71,7 +71,7 @@ defmodule Diffo.Test.Card do

change after_action(fn changeset, result, _context ->
with {:ok, result} <- Characteristic.update_values(result, changeset),
{:ok, result} <- Domain.get_card_by_id(result.id),
{:ok, result} <- Servo.get_card_by_id(result.id),
do: {:ok, result}
end)
end
Expand All @@ -82,7 +82,7 @@ defmodule Diffo.Test.Card do

change after_action(fn changeset, result, _context ->
with {:ok, result} <- Relationship.relate_instance(result, changeset),
{:ok, result} <- Domain.get_card_by_id(result.id),
{:ok, result} <- Servo.get_card_by_id(result.id),
do: {:ok, result}
end)
end
Expand All @@ -93,7 +93,7 @@ defmodule Diffo.Test.Card do

change after_action(fn changeset, result, _context ->
with {:ok, result} <- Assigner.assign(result, changeset, :ports, :port),
{:ok, result} <- Domain.get_card_by_id(result.id),
{:ok, result} <- Servo.get_card_by_id(result.id),
do: {:ok, result}
end)
end
Expand Down
12 changes: 6 additions & 6 deletions test/support/resource/shelf.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ defmodule Diffo.Test.Shelf do
alias Diffo.Provider.Assignment
alias Diffo.Provider.AssignableValue

alias Diffo.Test.Domain
alias Diffo.Test.Servo
alias Diffo.Test.ShelfValue

use Ash.Resource,
fragments: [BaseInstance],
domain: Domain
domain: Servo

resource do
description "An Ash Resource representing a Shelf"
Expand Down Expand Up @@ -60,7 +60,7 @@ defmodule Diffo.Test.Shelf do
end)

change after_action(fn changeset, result, _context ->
ActionHelper.build_after(changeset, result, Domain, :get_shelf_by_id)
ActionHelper.build_after(changeset, result, Servo, :get_shelf_by_id)
end)

change load [:href]
Expand All @@ -73,7 +73,7 @@ defmodule Diffo.Test.Shelf do

change after_action(fn changeset, result, _context ->
with {:ok, result} <- Characteristic.update_values(result, changeset),
{:ok, result} <- Domain.get_shelf_by_id(result.id),
{:ok, result} <- Servo.get_shelf_by_id(result.id),
do: {:ok, result}
end)
end
Expand All @@ -84,7 +84,7 @@ defmodule Diffo.Test.Shelf do

change after_action(fn changeset, result, _context ->
with {:ok, result} <- Relationship.relate_instance(result, changeset),
{:ok, result} <- Domain.get_shelf_by_id(result.id),
{:ok, result} <- Servo.get_shelf_by_id(result.id),
do: {:ok, result}
end)
end
Expand All @@ -95,7 +95,7 @@ defmodule Diffo.Test.Shelf do

change after_action(fn changeset, result, _context ->
with {:ok, result} <- Assigner.assign(result, changeset, :slots, :slot),
{:ok, result} <- Domain.get_shelf_by_id(result.id),
{:ok, result} <- Servo.get_shelf_by_id(result.id),
do: {:ok, result}
end)
end
Expand Down
6 changes: 3 additions & 3 deletions test/support/domain.ex → test/support/servo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#
# SPDX-License-Identifier: MIT

defmodule Diffo.Test.Domain do
defmodule Diffo.Test.Servo do
@moduledoc """
Diffo - TMF Service and Resource Management with a difference

Domain - domain for testing
Servo - a service and resource management domain
"""
use Ash.Domain,
otp_app: :diffo,
Expand All @@ -16,7 +16,7 @@ defmodule Diffo.Test.Domain do
alias Diffo.Test.Card

domain do
description "A domain for testing"
description "service and resource management"
end

resources do
Expand Down
Loading