zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

commit 3dc173d2f54daebfced83caa4eabaa2d253be300
parent 6aa0ed4bdd426f01fa9b4083d2105dc4bda9a92b
Author: Alberto Lerda <albertolerda97@gmail.com>
Date:   Wed, 16 Nov 2022 16:07:23 +0100

Zenflows.VF: More fixes to tests

Diffstat:
Mpriv/repo/migrations/20211111090805_fill_vf_spatial_thing.exs | 6+++---
Mpriv/repo/migrations/20211111111357_fill_vf_recipe_process.exs | 2+-
Mpriv/repo/migrations/20211111114050_fill_vf_recipe_flow.exs | 4++--
Mpriv/repo/migrations/20211111191749_fill_vf_scenario_definition.exs | 2+-
Mpriv/repo/migrations/20211113071804_fill_vf_economic_resource.exs | 4++--
Mpriv/repo/migrations/20211114144908_fill_vf_economic_event.exs | 4++--
Mpriv/repo/migrations/20211114190636_fill_vf_intent.exs | 6+++---
Mpriv/repo/migrations/20211115055335_fill_vf_commitment.exs | 4++--
Mpriv/repo/migrations/20211115071129_fill_vf_fulfillment.exs | 4++--
Mpriv/repo/migrations/20211115103758_fill_vf_satisfaction.exs | 4++--
Mpriv/repo/migrations/20211115173048_fill_vf_claim.exs | 4++--
Mpriv/repo/migrations/20211115181352_fill_vf_settlement.exs | 4++--
Dpriv/repo/migrations/20221116090719_float_to_decimal.exs | 54------------------------------------------------------
Msrc/zenflows/vf/claim.ex | 1-
Msrc/zenflows/vf/duration.ex | 3+--
Msrc/zenflows/vf/economic_event/domain.ex | 26+++++++++++++-------------
Msrc/zenflows/vf/economic_resource.ex | 5++---
Msrc/zenflows/vf/measure.ex | 3+--
Msrc/zenflows/vf/recipe_process.ex | 3+--
Msrc/zenflows/vf/scenario_definition.ex | 3+--
Msrc/zenflows/vf/spatial_thing.ex | 7+++----
Mtest/help/factory.ex | 14+++++++-------
Mtest/vf/claim.test.exs | 4++--
Mtest/vf/duration.test.exs | 4++--
Mtest/vf/economic_event/domain.test.exs | 92++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mtest/vf/economic_event/track_and_trace.test.exs | 2+-
Mtest/vf/economic_resource/type.test.exs | 4++--
Mtest/vf/intent/type.test.exs | 6+++---
Mtest/vf/process/track_and_trace.test.exs | 2+-
Mtest/vf/recipe_flow/type.test.exs | 4++--
Mtest/vf/recipe_process/type.test.exs | 2+-
Mtest/vf/scenario_definition/type.test.exs | 2+-
Mtest/vf/spatial_thing/domain.test.exs | 6+++---
Mtest/vf/spatial_thing/type.test.exs | 12++++++------
34 files changed, 123 insertions(+), 184 deletions(-)

diff --git a/priv/repo/migrations/20211111090805_fill_vf_spatial_thing.exs b/priv/repo/migrations/20211111090805_fill_vf_spatial_thing.exs @@ -23,9 +23,9 @@ def change() do add :name, :text, null: false add :note, :text add :mappable_address, :text - add :lat, :float - add :long, :float - add :alt, :float + add :lat, :decimal + add :long, :decimal + add :alt, :decimal timestamps() end end diff --git a/priv/repo/migrations/20211111111357_fill_vf_recipe_process.exs b/priv/repo/migrations/20211111111357_fill_vf_recipe_process.exs @@ -31,7 +31,7 @@ def change() do add :process_conforms_to_id, references("vf_process_specification"), null: false add :process_classified_as, {:array, :text} add :has_duration_unit_type, :vf_time_unit - add :has_duration_numeric_duration, :float + add :has_duration_numeric_duration, :decimal timestamps() end diff --git a/priv/repo/migrations/20211111114050_fill_vf_recipe_flow.exs b/priv/repo/migrations/20211111114050_fill_vf_recipe_flow.exs @@ -43,9 +43,9 @@ def change() do add :recipe_clause_of_id, references("vf_recipe_exchange") add :recipe_flow_resource_id, references("vf_recipe_resource"), null: false add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal timestamps() end diff --git a/priv/repo/migrations/20211111191749_fill_vf_scenario_definition.exs b/priv/repo/migrations/20211111191749_fill_vf_scenario_definition.exs @@ -29,7 +29,7 @@ def change() do add :name, :text, null: false add :note, :text add :has_duration_unit_type, :vf_time_unit - add :has_duration_numeric_duration, :float + add :has_duration_numeric_duration, :decimal timestamps() end diff --git a/priv/repo/migrations/20211113071804_fill_vf_economic_resource.exs b/priv/repo/migrations/20211113071804_fill_vf_economic_resource.exs @@ -26,9 +26,9 @@ def change() do add :classified_as, {:array, :text} add :conforms_to_id, references("vf_resource_specification"), null: false add :accounting_quantity_has_unit_id, references("vf_unit"), null: false - add :accounting_quantity_has_numerical_value, :float, null: false + add :accounting_quantity_has_numerical_value, :decimal, null: false add :onhand_quantity_has_unit_id, references("vf_unit"), null: false - add :onhand_quantity_has_numerical_value, :float, nulL: false + add :onhand_quantity_has_numerical_value, :decimal, nulL: false add :primary_accountable_id, references("vf_agent"), null: false add :custodian_id, references("vf_agent"), null: false add :stage_id, references("vf_process_specification") diff --git a/priv/repo/migrations/20211114144908_fill_vf_economic_event.exs b/priv/repo/migrations/20211114144908_fill_vf_economic_event.exs @@ -30,9 +30,9 @@ def change() do add :resource_classified_as, {:array, :text} add :resource_conforms_to_id, references("vf_resource_specification") add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :has_beginning, :timestamptz add :has_end, :timestamptz add :has_point_in_time, :timestamptz diff --git a/priv/repo/migrations/20211114190636_fill_vf_intent.exs b/priv/repo/migrations/20211114190636_fill_vf_intent.exs @@ -30,11 +30,11 @@ def change() do add :resource_conforms_to_id, references("vf_resource_specification") add :resource_inventoried_as_id, references("vf_economic_resource") add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :available_quantity_has_unit_id, references("vf_unit") - add :available_quantity_has_numerical_value, :float + add :available_quantity_has_numerical_value, :decimal add :at_location_id, references("vf_spatial_thing") add :has_beginning, :timestamptz add :has_end, :timestamptz diff --git a/priv/repo/migrations/20211115055335_fill_vf_commitment.exs b/priv/repo/migrations/20211115055335_fill_vf_commitment.exs @@ -29,9 +29,9 @@ def change() do add :resource_conforms_to_id, references("vf_resource_specification") add :resource_inventoried_as_id, references("vf_economic_resource") add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :has_beginning, :timestamptz add :has_end, :timestamptz add :has_point_in_time, :timestamptz diff --git a/priv/repo/migrations/20211115071129_fill_vf_fulfillment.exs b/priv/repo/migrations/20211115071129_fill_vf_fulfillment.exs @@ -23,9 +23,9 @@ def change() do add :fulfilled_by_id, references("vf_economic_event"), null: false add :fulfills_id, references("vf_commitment"), null: false add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :note, :text timestamps() end diff --git a/priv/repo/migrations/20211115103758_fill_vf_satisfaction.exs b/priv/repo/migrations/20211115103758_fill_vf_satisfaction.exs @@ -23,9 +23,9 @@ def change() do add :satisfies_id, references("vf_intent"), null: false add :satisfied_by_id, references("vf_event_or_commitment"), null: false add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :note, :text timestamps() end diff --git a/priv/repo/migrations/20211115173048_fill_vf_claim.exs b/priv/repo/migrations/20211115173048_fill_vf_claim.exs @@ -26,9 +26,9 @@ def change() do add :resource_classified_as, {:array, :text} add :resource_conforms_to_id, references("vf_resource_specification") add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :triggered_by_id, references("vf_economic_event") add :due, :timestamptz add :created, :timestamptz diff --git a/priv/repo/migrations/20211115181352_fill_vf_settlement.exs b/priv/repo/migrations/20211115181352_fill_vf_settlement.exs @@ -23,9 +23,9 @@ def change() do add :settled_by_id, references("vf_economic_event"), null: false add :settles_id, references("vf_claim"), null: false add :resource_quantity_has_unit_id, references("vf_unit") - add :resource_quantity_has_numerical_value, :float + add :resource_quantity_has_numerical_value, :decimal add :effort_quantity_has_unit_id, references("vf_unit") - add :effort_quantity_has_numerical_value, :float + add :effort_quantity_has_numerical_value, :decimal add :note, :text timestamps() end diff --git a/priv/repo/migrations/20221116090719_float_to_decimal.exs b/priv/repo/migrations/20221116090719_float_to_decimal.exs @@ -1,54 +0,0 @@ -defmodule Zenflows.DB.Repo.Migrations.FloatToDecimal do - use Ecto.Migration - - def change do - alter table("vf_spatial_thing") do - modify :lat, :decimal - modify :long, :decimal - modify :alt, :decimal - end - alter table("vf_scenario_definition") do - modify :has_duration_numeric_duration, :decimal - end - alter table("vf_commitment") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - alter table("vf_intent") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - modify :available_quantity_has_numerical_value, :decimal - end - alter table("vf_economic_event") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - alter table("vf_recipe_process") do - modify :has_duration_numeric_duration, :decimal - end - alter table("vf_claim") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - alter table("vf_settlement") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - alter table("vf_fulfillment") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - alter table("vf_recipe_flow") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - alter table("vf_economic_resource") do - modify :accounting_quantity_has_numerical_value, :decimal - modify :onhand_quantity_has_numerical_value, :decimal - end - alter table("vf_satisfaction") do - modify :resource_quantity_has_numerical_value, :decimal - modify :effort_quantity_has_numerical_value, :decimal - end - end -end diff --git a/src/zenflows/vf/claim.ex b/src/zenflows/vf/claim.ex @@ -33,7 +33,6 @@ alias Zenflows.VF.{ ResourceSpecification, Unit, } -alias Decimal, as: D @type t() :: %__MODULE__{ action: Action.t(), diff --git a/src/zenflows/vf/duration.ex b/src/zenflows/vf/duration.ex @@ -25,11 +25,10 @@ use Zenflows.DB.Schema alias Ecto.Changeset alias Zenflows.DB.Schema alias Zenflows.VF.TimeUnitEnum -alias Decimal, as: D @type t() :: %__MODULE__{ unit_type: TimeUnitEnum.t(), - numeric_duration: D.decimal(), + numeric_duration: Decimal.t(), } @primary_key false diff --git a/src/zenflows/vf/economic_event/domain.ex b/src/zenflows/vf/economic_event/domain.ex @@ -515,7 +515,7 @@ defp handle_insert(key, %{action_id: "accept"} = evt, _) do evt.resource_quantity_has_numerical_value != res.onhand_quantity_has_numerical_value -> {:error, "the accept events need to fully accept the resource"} - res.container? and res.onhand_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.onhand_quantity_has_numerical_value, 0) != :gt -> {:error, "the accept events need container resources to have positive onhand quantity"} any_combine_separate?.() -> @@ -640,7 +640,7 @@ defp handle_insert(key, %{action_id: "transferCustody"} = evt, res_params) do {:error, "you can't transfer-custody a contained resource"} evt.resource_quantity_has_unit_id != res.onhand_quantity_has_unit_id -> {:error, "the unit of resource-quantity must match with the unit of resource-inventoried-as"} - res.container? and res.onhand_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.onhand_quantity_has_numerical_value, 0) != :gt -> {:error, "the transfer-custody events need container resources to have positive onhand-quantity"} res.container? && evt.resource_quantity_has_numerical_value != res.onhand_quantity_has_numerical_value -> {:error, "the transfer-custody events need to fully transfer the resource"} @@ -668,7 +668,7 @@ defp handle_insert(key, %{action_id: "transferCustody"} = evt, res_params) do where(EconomicResource, id: ^evt.resource_inventoried_as_id), set: [previous_event_id: evt.id], inc: [ - onhand_quantity_has_numerical_value: -evt.resource_quantity_has_numerical_value, + onhand_quantity_has_numerical_value: Decimal.negate(evt.resource_quantity_has_numerical_value), ]) |> Multi.update_all("#{key}.inc", where(EconomicResource, id: ^evt.to_resource_inventoried_as_id), inc: [ onhand_quantity_has_numerical_value: evt.resource_quantity_has_numerical_value, @@ -765,7 +765,7 @@ defp handle_insert(key, %{action_id: "transferAllRights"} = evt, res_params) do {:error, "you can't transfer-all-rights a contained resource"} evt.resource_quantity_has_unit_id != res.accounting_quantity_has_unit_id -> {:error, "the unit of resource-quantity must match with the unit of resource-inventoried-as"} - res.container? and res.accounting_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.accounting_quantity_has_numerical_value, 0) != :gt -> {:error, "the transfer-all-rights events need container resources to have positive accounting-quantity"} res.container? && evt.resource_quantity_has_numerical_value != res.accounting_quantity_has_numerical_value -> {:error, "the transfer-all-rights events need to fully transfer the resource"} @@ -793,7 +793,7 @@ defp handle_insert(key, %{action_id: "transferAllRights"} = evt, res_params) do where(EconomicResource, id: ^evt.resource_inventoried_as_id), set: [previous_event_id: evt.id], inc: [ - accounting_quantity_has_numerical_value: -evt.resource_quantity_has_numerical_value, + accounting_quantity_has_numerical_value: Decimal.negate(evt.resource_quantity_has_numerical_value), ]) |> Multi.update_all(:inc, where(EconomicResource, id: ^evt.to_resource_inventoried_as_id), inc: [ accounting_quantity_has_numerical_value: evt.resource_quantity_has_numerical_value, @@ -891,9 +891,9 @@ defp handle_insert(key, %{action_id: "transfer"} = evt, res_params) do {:error, "you can't transfer a contained resource"} evt.resource_quantity_has_unit_id != res.accounting_quantity_has_unit_id -> {:error, "the unit of resource-quantity must match with the unit of resource-inventoried-as"} - res.container? and res.accounting_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.accounting_quantity_has_numerical_value, 0) != :gt -> {:error, "the transfer events need container resources to have positive accounting-quantity"} - res.container? and res.onhand_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.onhand_quantity_has_numerical_value, 0) != :gt -> {:error, "the transfer events need container resources to have positive onhand-quantity"} res.container? && evt.resource_quantity_has_numerical_value != res.accounting_quantity_has_numerical_value -> {:error, "the transfer events need to fully transfer the resource"} @@ -923,8 +923,8 @@ defp handle_insert(key, %{action_id: "transfer"} = evt, res_params) do where(EconomicResource, id: ^evt.resource_inventoried_as_id), set: [previous_event_id: evt.id], inc: [ - accounting_quantity_has_numerical_value: -evt.resource_quantity_has_numerical_value, - onhand_quantity_has_numerical_value: -evt.resource_quantity_has_numerical_value, + accounting_quantity_has_numerical_value: Decimal.negate(evt.resource_quantity_has_numerical_value), + onhand_quantity_has_numerical_value: Decimal.negate(evt.resource_quantity_has_numerical_value), ]) |> Multi.update_all("#{key}.inc", where(EconomicResource, id: ^evt.to_resource_inventoried_as_id), inc: [ accounting_quantity_has_numerical_value: evt.resource_quantity_has_numerical_value, @@ -1026,9 +1026,9 @@ defp handle_insert(key, %{action_id: "move"} = evt, res_params) do {:error, "you can't move a contained resource"} evt.resource_quantity_has_unit_id != res.accounting_quantity_has_unit_id -> {:error, "the unit of resource-quantity must match with the unit of resource-inventoried-as"} - res.container? and res.accounting_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.accounting_quantity_has_numerical_value, 0) != :gt -> {:error, "the move events need container resources to have positive accounting-quantity"} - res.container? and res.onhand_quantity_has_numerical_value <= 0 -> + res.container? and Decimal.compare(res.onhand_quantity_has_numerical_value, 0) != :gt -> {:error, "the move events need container resources to have positive onhand-quantity"} res.container? && evt.resource_quantity_has_numerical_value != res.accounting_quantity_has_numerical_value -> {:error, "the move events need to fully move the resource"} @@ -1062,8 +1062,8 @@ defp handle_insert(key, %{action_id: "move"} = evt, res_params) do where(EconomicResource, id: ^evt.resource_inventoried_as_id), set: [previous_event_id: evt.id], inc: [ - accounting_quantity_has_numerical_value: -evt.resource_quantity_has_numerical_value, - onhand_quantity_has_numerical_value: -evt.resource_quantity_has_numerical_value, + accounting_quantity_has_numerical_value: Decimal.negate(evt.resource_quantity_has_numerical_value), + onhand_quantity_has_numerical_value: Decimal.negate(evt.resource_quantity_has_numerical_value), ]) |> Multi.update_all("#{key}.inc", where(EconomicResource, id: ^evt.to_resource_inventoried_as_id), inc: [ accounting_quantity_has_numerical_value: evt.resource_quantity_has_numerical_value, diff --git a/src/zenflows/vf/economic_resource.ex b/src/zenflows/vf/economic_resource.ex @@ -35,7 +35,6 @@ alias Zenflows.VF.{ SpatialThing, Unit, } -alias Decimal, as: D @type t() :: %__MODULE__{ name: String.t(), @@ -46,10 +45,10 @@ alias Decimal, as: D conforms_to: ResourceSpecification.t(), accounting_quantity: Measure.t() | nil, accounting_quantity_has_unit: Unit.t(), - accounting_quantity_has_numerical_value: D.decimal(), + accounting_quantity_has_numerical_value: Decimal.t(), onhand_quantity: Measure.t() | nil, onhand_quantity_has_unit: Unit.t(), - onhand_quantity_has_numerical_value: D.decimal(), + onhand_quantity_has_numerical_value: Decimal.t(), primary_accountable: Agent.t(), custodian: Agent.t(), stage: ProcessSpecification.t() | nil, diff --git a/src/zenflows/vf/measure.ex b/src/zenflows/vf/measure.ex @@ -26,11 +26,10 @@ use Zenflows.DB.Schema alias Ecto.Changeset alias Zenflows.DB.Schema alias Zenflows.VF.Unit -alias Decimal, as: D @type t() :: %__MODULE__{ has_unit_id: Zenflows.DB.ID.t(), - has_numerical_value: D.decimal(), + has_numerical_value: Decimal.t(), } @primary_key false diff --git a/src/zenflows/vf/recipe_process.ex b/src/zenflows/vf/recipe_process.ex @@ -29,7 +29,6 @@ alias Zenflows.VF.{ ProcessSpecification, TimeUnitEnum, } -alias Decimal, as: D @type t() :: %__MODULE__{ @@ -39,7 +38,7 @@ alias Decimal, as: D process_classified_as: [String.t()] | nil, has_duration: Duration.t() | nil, has_duration_unit_type: TimeUnitEnum.t() | nil, - has_duration_numeric_duration: D.decimal() | nil, + has_duration_numeric_duration: Decimal.t() | nil, } schema "vf_recipe_process" do diff --git a/src/zenflows/vf/scenario_definition.ex b/src/zenflows/vf/scenario_definition.ex @@ -28,13 +28,12 @@ alias Zenflows.VF.{ Duration, TimeUnitEnum, } -alias Decimal, as: D @type t() :: %__MODULE__{ name: String.t(), note: String.t() | nil, has_duration_unit_type: TimeUnitEnum.t() | nil, - has_duration_numeric_duration: D.decimal() | nil, + has_duration_numeric_duration: Decimal.t() | nil, has_duration: Duration.t() | nil, } diff --git a/src/zenflows/vf/spatial_thing.ex b/src/zenflows/vf/spatial_thing.ex @@ -24,15 +24,14 @@ use Zenflows.DB.Schema alias Ecto.Changeset alias Zenflows.DB.{Schema, Validate} -alias Decimal, as: D @type t() :: %__MODULE__{ id: String.t(), name: String.t(), mappable_address: String.t() | nil, - lat: D.decimal() | nil, - long: D.decimal() | nil, - alt: D.decimal() | nil, + lat: Decimal.t() | nil, + long: Decimal.t() | nil, + alt: Decimal.t() | nil, note: String.t() | nil, } diff --git a/test/help/factory.ex b/test/help/factory.ex @@ -75,7 +75,7 @@ def float(mul \\ 100) do end @doc """ -Returns a random float of the from 0 (inclusive) and 1 (exclusive) +Returns a random decimal of the from 0 (inclusive) and 1 (exclusive) multiplied by `mul`. """ @spec decimal() :: D.decimal() @@ -148,7 +148,7 @@ end def build(:iduration) do %{ unit_type: build(:time_unit), - numeric_duration: float(), + numeric_duration: decimal(), } end @@ -162,7 +162,7 @@ end def build(:imeasure) do %VF.Measure{ has_unit: build(:unit), - has_numerical_value: float(), + has_numerical_value: decimal(), } end @@ -170,9 +170,9 @@ def build(:spatial_thing) do %VF.SpatialThing{ name: str("some name"), mappable_address: str("some mappable_address"), - lat: float(), - long: float(), - alt: float(), + lat: decimal(), + long: decimal(), + alt: decimal(), note: str("some note"), } end @@ -560,7 +560,7 @@ def insert_economic_event!() do resource_classified_as: str_list("some uri"), resource_conforms_to_id: insert!(:resource_specification).id, resource_quantity: %{ - has_numerical_value: float(), + has_numerical_value: decimal(), has_unit_id: insert!(:unit).id, }, has_point_in_time: now(), diff --git a/test/vf/claim.test.exs b/test/vf/claim.test.exs @@ -29,11 +29,11 @@ setup do resource_conforms_to_id: Factory.insert!(:resource_specification).id, resource_quantity: %{ has_unit_id: Factory.insert!(:unit).id, - has_numerical_value: Factory.float(), + has_numerical_value: Factory.decimal(), }, effort_quantity: %{ has_unit_id: Factory.insert!(:unit).id, - has_numerical_value: Factory.float(), + has_numerical_value: Factory.decimal(), }, triggered_by_id: Factory.insert!(:economic_event).id, due: Factory.now(), diff --git a/test/vf/duration.test.exs b/test/vf/duration.test.exs @@ -29,7 +29,7 @@ alias Zenflows.VF.{Duration, TimeUnit} embedded_schema do field :has_duration, :map, virtual: true field :has_duration_unit_type, TimeUnit - field :has_duration_numeric_duration, :float + field :has_duration_numeric_duration, :decimal end def changeset(params) do @@ -59,7 +59,7 @@ setup do }, inserted: %Dummy{ has_duration_unit_type: Factory.build(:time_unit), - has_duration_numeric_duration: Factory.float(), + has_duration_numeric_duration: Factory.decimal(), }, } end diff --git a/test/vf/economic_event/domain.test.exs b/test/vf/economic_event/domain.test.exs @@ -165,9 +165,9 @@ describe "`create/2` with raise:" do res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when the agent doesn't have ownership over the resource", %{params: params} do @@ -279,9 +279,9 @@ describe "`create/2` with produce:" do res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when the agent doesn't have ownership over the resource", %{params: params} do @@ -331,9 +331,9 @@ describe "`create/2` with lower:" do assert {:ok, %EconomicEvent{}} = Domain.create(params) res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when the agent doesn't have ownership over the resource", %{params: params} do @@ -386,9 +386,9 @@ describe "`create/2` with consume:" do res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when the agent doesn't have ownership over the resource", %{params: params} do @@ -502,7 +502,7 @@ describe "`create/2` with pickup:" do end test "fail when event's quantity value and resource's onhand-quantity value differ", %{params: params} do - params = update_in(params.resource_quantity.has_numerical_value, &(&1 + 1)) + params = update_in(params.resource_quantity.has_numerical_value, &(Decimal.add(&1, 1))) assert {:error, "the pickup events need to fully pickup the resource"} = Domain.create(params) end @@ -571,7 +571,7 @@ describe "`create/2` with dropoff:" do @tag :want_container test "fail when the resource is a container and event's quantity value and resource's onhand-quantity value differ", %{params: params} do - params = update_in(params.resource_quantity.has_numerical_value, &(&1 + 1)) + params = update_in(params.resource_quantity.has_numerical_value, &(Decimal.add(&1, 1))) assert {:error, "the dropoff events need to fully dropoff the resource"} = Domain.create(params) end @@ -607,7 +607,7 @@ describe "`create/2` with accept:" do assert res_after.accounting_quantity_has_numerical_value == res_before.accounting_quantity_has_numerical_value assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when provider doesn't have custody over the resource", %{params: params} do @@ -633,7 +633,7 @@ describe "`create/2` with accept:" do end test "fail when event's quantity value and resource's onhand-quantity value differ", %{params: params} do - params = update_in(params.resource_quantity.has_numerical_value, &(&1 + 1)) + params = update_in(params.resource_quantity.has_numerical_value, &(Decimal.add(&1, 1))) assert {:error, "the accept events need to fully accept the resource"} = Domain.create(params) end @@ -705,7 +705,7 @@ describe "`create/2` with modify:" do assert res_after.accounting_quantity_has_numerical_value == res_before.accounting_quantity_has_numerical_value assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when provider doesn't have custody over the resource", %{params: params} do @@ -727,7 +727,7 @@ describe "`create/2` with modify:" do end test "fail when event's quantity value and resource's onhand-quantity value differ", %{params: params} do - params = update_in(params.resource_quantity.has_numerical_value, &(&1 + 1)) + params = update_in(params.resource_quantity.has_numerical_value, &(Decimal.add(&1, 1))) assert {:error, "the modify events need to fully modify the resource"} = Domain.create(params) end @@ -837,7 +837,7 @@ describe "`create/2` with transferCustody:" do assert res_after.accounting_quantity_has_numerical_value == res_before.accounting_quantity_has_numerical_value assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res.name == res_params.name assert to_res.note == res_params.note @@ -853,7 +853,7 @@ describe "`create/2` with transferCustody:" do assert to_res.primary_accountable_id == params.receiver_id assert to_res.custodian_id == params.receiver_id - assert to_res.accounting_quantity_has_numerical_value == 0 + assert to_string(to_res.accounting_quantity_has_numerical_value) == "0" assert to_res.accounting_quantity_has_unit_id == params.resource_quantity.has_unit_id assert to_res.onhand_quantity_has_numerical_value == params.resource_quantity.has_numerical_value assert to_res.onhand_quantity_has_unit_id == params.resource_quantity.has_unit_id @@ -881,12 +881,12 @@ describe "`create/2` with transferCustody:" do assert res_after.accounting_quantity_has_numerical_value == res_before.accounting_quantity_has_numerical_value assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res_after.accounting_quantity_has_numerical_value == to_res_before.accounting_quantity_has_numerical_value assert to_res_after.onhand_quantity_has_numerical_value == - to_res_before.onhand_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(to_res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when provider doesn't have custody over the resource", %{params: params} do @@ -925,7 +925,7 @@ describe "`create/2` with transferCustody:" do @tag :want_container test "fail when event's quantity value and resource's onhand-quantity value differ", %{params: params} do - params = update_in(params.resource_quantity.has_numerical_value, &(&1 + 1)) + params = update_in(params.resource_quantity.has_numerical_value, &(Decimal.add(&1, 1))) assert {:error, "the transfer-custody events need to fully transfer the resource"} = Domain.create(params) end @@ -1101,7 +1101,7 @@ describe "`create/2` with transferAllRights:" do res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == res_before.onhand_quantity_has_numerical_value @@ -1121,7 +1121,7 @@ describe "`create/2` with transferAllRights:" do assert to_res.custodian_id == params.receiver_id assert to_res.accounting_quantity_has_numerical_value == params.resource_quantity.has_numerical_value assert to_res.accounting_quantity_has_unit_id == params.resource_quantity.has_unit_id - assert to_res.onhand_quantity_has_numerical_value == 0 + assert to_string(to_res.onhand_quantity_has_numerical_value) == "0" assert to_res.onhand_quantity_has_unit_id == params.resource_quantity.has_unit_id from(r in EconomicResource, @@ -1144,12 +1144,12 @@ describe "`create/2` with transferAllRights:" do to_res_after = EconomicResource.Domain.one!(params.to_resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == res_before.onhand_quantity_has_numerical_value assert to_res_after.accounting_quantity_has_numerical_value == - to_res_before.accounting_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(to_res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res_after.onhand_quantity_has_numerical_value == to_res_before.onhand_quantity_has_numerical_value end @@ -1181,16 +1181,16 @@ describe "`create/2` with transferAllRights:" do err = "the transfer-all-rights events need container resources to have positive accounting-quantity" res = EconomicResource.Domain.one!(params.resource_inventoried_as_id) - Changeset.change(res, accounting_quantity_has_numerical_value: 0.0) |> Repo.update!() + Changeset.change(res, accounting_quantity_has_numerical_value: Decimal.new("0.0")) |> Repo.update!() assert {:error, ^err} = Domain.create(params) - Changeset.change(res, accounting_quantity_has_numerical_value: -1.0) |> Repo.update!() + Changeset.change(res, accounting_quantity_has_numerical_value: Decimal.new("-1.0")) |> Repo.update!() assert {:error, ^err} = Domain.create(params) end @tag :want_container test "fail when event's quantity value and resource's accounting-quantity value differ", %{params: params} do - params = update_in(params.resource_quantity.has_numerical_value, &(&1 + 1)) + params = update_in(params.resource_quantity.has_numerical_value, &(Decimal.add(&1, 1))) assert {:error, "the transfer-all-rights events need to fully transfer the resource"} = Domain.create(params) end @@ -1368,9 +1368,9 @@ describe "`create/2` with transfer:" do res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res.name == res_params.name assert to_res.note == res_params.note @@ -1412,14 +1412,14 @@ describe "`create/2` with transfer:" do to_res_after = EconomicResource.Domain.one!(params.to_resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res_after.accounting_quantity_has_numerical_value == - to_res_before.accounting_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(to_res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res_after.onhand_quantity_has_numerical_value == - to_res_before.onhand_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(to_res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when provider doesn't have accountability over the resource", %{params: params} do @@ -1467,11 +1467,11 @@ describe "`create/2` with transfer:" do err = "the transfer events need container resources to have positive accounting-quantity" res = EconomicResource.Domain.one!(params.resource_inventoried_as_id) - Changeset.change(res, accounting_quantity_has_numerical_value: 0.0) + Changeset.change(res, accounting_quantity_has_numerical_value: Decimal.new("0.0")) |> Repo.update!() assert {:error, ^err} = Domain.create(params) - Changeset.change(res, accounting_quantity_has_numerical_value: -1.0) |> Repo.update!() + Changeset.change(res, accounting_quantity_has_numerical_value: Decimal.new("-1.0")) |> Repo.update!() assert {:error, ^err} = Domain.create(params) end @@ -1480,11 +1480,11 @@ describe "`create/2` with transfer:" do err = "the transfer events need container resources to have positive onhand-quantity" res = EconomicResource.Domain.one!(params.resource_inventoried_as_id) - Changeset.change(res, onhand_quantity_has_numerical_value: 0.0) + Changeset.change(res, onhand_quantity_has_numerical_value: Decimal.new("0.0")) |> Repo.update!() assert {:error, ^err} = Domain.create(params) - Changeset.change(res, onhand_quantity_has_numerical_value: -1.0) + Changeset.change(res, onhand_quantity_has_numerical_value: Decimal.new("-1.0")) |> Repo.update!() assert {:error, ^err} = Domain.create(params) end @@ -1492,7 +1492,7 @@ describe "`create/2` with transfer:" do @tag :want_container test "fail when event's quantity value and resource's accounting-quantity value differ", %{params: params} do EconomicResource.Domain.one!(params.resource_inventoried_as_id) - |> Changeset.change(accounting_quantity_has_numerical_value: params.resource_quantity.has_numerical_value + 1) + |> Changeset.change(accounting_quantity_has_numerical_value: Decimal.add(params.resource_quantity.has_numerical_value, 1)) |> Repo.update!() assert {:error, "the transfer events need to fully transfer the resource"} = @@ -1502,7 +1502,7 @@ describe "`create/2` with transfer:" do @tag :want_container test "fail when event's quantity value and resource's onhnad-quantity value differ", %{params: params} do EconomicResource.Domain.one!(params.resource_inventoried_as_id) - |> Changeset.change(onhand_quantity_has_numerical_value: params.resource_quantity.has_numerical_value + 1) + |> Changeset.change(onhand_quantity_has_numerical_value: Decimal.add(params.resource_quantity.has_numerical_value, 1)) |> Repo.update!() assert {:error, "the transfer events need to fully transfer the resource"} = Domain.create(params) @@ -1668,9 +1668,9 @@ describe "`create/2` with move:" do res_after = EconomicResource.Domain.one!(params.resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res.name == res_params.name assert to_res.note == res_params.note @@ -1712,14 +1712,14 @@ describe "`create/2` with move:" do to_res_after = EconomicResource.Domain.one!(params.to_resource_inventoried_as_id) assert res_after.accounting_quantity_has_numerical_value == - res_before.accounting_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert res_after.onhand_quantity_has_numerical_value == - res_before.onhand_quantity_has_numerical_value - params.resource_quantity.has_numerical_value + Decimal.sub(res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res_after.accounting_quantity_has_numerical_value == - to_res_before.accounting_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(to_res_before.accounting_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) assert to_res_after.onhand_quantity_has_numerical_value == - to_res_before.onhand_quantity_has_numerical_value + params.resource_quantity.has_numerical_value + Decimal.add(to_res_before.onhand_quantity_has_numerical_value, params.resource_quantity.has_numerical_value) end test "fail when provider doesn't have accountability over the resource", %{params: params} do @@ -1809,7 +1809,7 @@ describe "`create/2` with move:" do @tag :want_container test "fail when event's quantity value and resource's accounting-quantity value differ", %{params: params} do EconomicResource.Domain.one!(params.resource_inventoried_as_id) - |> Changeset.change(accounting_quantity_has_numerical_value: params.resource_quantity.has_numerical_value + 1) + |> Changeset.change(accounting_quantity_has_numerical_value: Decimal.add(params.resource_quantity.has_numerical_value, 1)) |> Repo.update!() assert {:error, "the move events need to fully move the resource"} = @@ -1819,7 +1819,7 @@ describe "`create/2` with move:" do @tag :want_container test "fail when event's quantity value and resource's onhnad-quantity value differ", %{params: params} do EconomicResource.Domain.one!(params.resource_inventoried_as_id) - |> Changeset.change(onhand_quantity_has_numerical_value: params.resource_quantity.has_numerical_value + 1) + |> Changeset.change(onhand_quantity_has_numerical_value: Decimal.add(params.resource_quantity.has_numerical_value, 1)) |> Repo.update!() assert {:error, "the move events need to fully move the resource"} = diff --git a/test/vf/economic_event/track_and_trace.test.exs b/test/vf/economic_event/track_and_trace.test.exs @@ -110,7 +110,7 @@ test "previous/2 works" do has_unit_id: unit.id, }, effort_quantity: %{ - has_numerical_value: Factory.float(), + has_numerical_value: Factory.decimal(), has_unit_id: Factory.insert!(:unit).id, }, has_point_in_time: Factory.now(), diff --git a/test/vf/economic_resource/type.test.exs b/test/vf/economic_resource/type.test.exs @@ -81,9 +81,9 @@ describe "Query" do assert data["classifiedAs"] == new.classified_as assert data["conformsTo"]["id"] == new.conforms_to_id assert data["accountingQuantity"]["hasUnit"]["id"] == new.accounting_quantity_has_unit_id - assert data["accountingQuantity"]["hasNumericalValue"] == new.accounting_quantity_has_numerical_value + assert data["accountingQuantity"]["hasNumericalValue"] == to_string(new.accounting_quantity_has_numerical_value) assert data["onhandQuantity"]["hasUnit"]["id"] == new.onhand_quantity_has_unit_id - assert data["onhandQuantity"]["hasNumericalValue"] == new.onhand_quantity_has_numerical_value + assert data["onhandQuantity"]["hasNumericalValue"] == to_string(new.onhand_quantity_has_numerical_value) assert data["primaryAccountable"]["id"] == new.primary_accountable_id assert data["custodian"]["id"] == new.custodian_id assert data["stage"]["id"] == new.stage_id diff --git a/test/vf/intent/type.test.exs b/test/vf/intent/type.test.exs @@ -109,11 +109,11 @@ describe "Query" do assert data["resourceInventoriedAs"]["id"] == int.resource_inventoried_as_id assert data["resourceConformsTo"]["id"] == int.resource_conforms_to_id assert data["resourceClassifiedAs"] == int.resource_classified_as - assert data["resourceQuantity"]["hasNumericalValue"] == int.resource_quantity_has_numerical_value + assert data["resourceQuantity"]["hasNumericalValue"] == to_string(int.resource_quantity_has_numerical_value) assert data["resourceQuantity"]["hasUnit"]["id"] == int.resource_quantity_has_unit_id - assert data["effortQuantity"]["hasNumericalValue"] == int.effort_quantity_has_numerical_value + assert data["effortQuantity"]["hasNumericalValue"] == to_string(int.effort_quantity_has_numerical_value) assert data["effortQuantity"]["hasUnit"]["id"] == int.effort_quantity_has_unit_id - assert data["availableQuantity"]["hasNumericalValue"] == int.available_quantity_has_numerical_value + assert data["availableQuantity"]["hasNumericalValue"] == to_string(int.available_quantity_has_numerical_value) assert data["availableQuantity"]["hasUnit"]["id"] == int.available_quantity_has_unit_id assert data["hasBeginning"] == DateTime.to_iso8601(int.has_beginning) assert data["hasEnd"] == DateTime.to_iso8601(int.has_end) diff --git a/test/vf/process/track_and_trace.test.exs b/test/vf/process/track_and_trace.test.exs @@ -101,7 +101,7 @@ test "previous/2 works" do has_unit_id: unit.id, }, effort_quantity: %{ - has_numerical_value: Factory.float(), + has_numerical_value: Factory.decimal(), has_unit_id: Factory.insert!(:unit).id, }, has_point_in_time: Factory.now(), diff --git a/test/vf/recipe_flow/type.test.exs b/test/vf/recipe_flow/type.test.exs @@ -74,9 +74,9 @@ describe "Query" do assert data["note"] == new.note assert data["action"]["id"] == new.action_id assert data["resourceQuantity"]["hasUnit"]["id"] == new.resource_quantity_has_unit_id - assert data["resourceQuantity"]["hasNumericalValue"] == new.resource_quantity_has_numerical_value + assert data["resourceQuantity"]["hasNumericalValue"] == to_string(new.resource_quantity_has_numerical_value) assert data["effortQuantity"]["hasUnit"]["id"] == new.effort_quantity_has_unit_id - assert data["effortQuantity"]["hasNumericalValue"] == new.effort_quantity_has_numerical_value + assert data["effortQuantity"]["hasNumericalValue"] == to_string(new.effort_quantity_has_numerical_value) assert data["recipeFlowResource"]["id"] == new.recipe_flow_resource_id assert data["recipeInputOf"]["id"] == new.recipe_input_of_id assert data["recipeOutputOf"]["id"] == new.recipe_output_of_id diff --git a/test/vf/recipe_process/type.test.exs b/test/vf/recipe_process/type.test.exs @@ -64,7 +64,7 @@ describe "Query" do assert data["processClassifiedAs"] == new.process_classified_as assert data["processConformsTo"]["id"] == new.process_conforms_to_id assert data["hasDuration"]["unitType"] == to_string(new.has_duration_unit_type) - assert data["hasDuration"]["numericDuration"] == new.has_duration_numeric_duration + assert data["hasDuration"]["numericDuration"] == to_string(new.has_duration_numeric_duration) end end diff --git a/test/vf/scenario_definition/type.test.exs b/test/vf/scenario_definition/type.test.exs @@ -58,7 +58,7 @@ describe "Query" do assert data["name"] == new.name assert data["note"] == new.note assert data["hasDuration"]["unitType"] == to_string(new.has_duration_unit_type) - assert data["hasDuration"]["numericDuration"] == new.has_duration_numeric_duration + assert data["hasDuration"]["numericDuration"] == to_string(new.has_duration_numeric_duration) end end diff --git a/test/vf/spatial_thing/domain.test.exs b/test/vf/spatial_thing/domain.test.exs @@ -26,9 +26,9 @@ setup do params: %{ name: Factory.str("name"), mappable_address: Factory.str("address"), - lat: Factory.float(), - long: Factory.float(), - alt: Factory.float(), + lat: Factory.decimal(), + long: Factory.decimal(), + alt: Factory.decimal(), note: Factory.str("note"), }, inserted: Factory.insert!(:spatial_thing), diff --git a/test/vf/spatial_thing/type.test.exs b/test/vf/spatial_thing/type.test.exs @@ -23,9 +23,9 @@ setup do params: %{ "name" => Factory.str("name"), "mappableAddress" => Factory.str("address"), - "lat" => Factory.float(), - "long" => Factory.float(), - "alt" => Factory.float(), + "lat" => Factory.decimal(), + "long" => Factory.decimal(), + "alt" => Factory.decimal(), "note" => Factory.str("note"), }, inserted: Factory.insert!(:spatial_thing), @@ -57,9 +57,9 @@ describe "Query" do assert data["id"] == new.id assert data["name"] == new.name assert data["mappableAddress"] == new.mappable_address - assert data["lat"] == new.lat - assert data["long"] == new.long - assert data["alt"] == new.alt + assert data["lat"] == to_string(new.lat) + assert data["long"] == to_string(new.long) + assert data["alt"] == to_string(new.alt) assert data["note"] == new.note end end