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
4 changes: 2 additions & 2 deletions lib/astarte/common/generators/datetime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ defmodule Astarte.Common.Generators.DateTime do
max <- constant(max_default()),
min = DateTime.to_unix(min, @ref_unit),
max = DateTime.to_unix(max, @ref_unit),
:_,
date_time <-
TimestampGenerator.timestamp(min: min, max: max, unit: @ref_unit)
|> map(&DateTime.from_unix!(&1, @ref_unit)),
params: params do
params: params,
exclude: [:date_time] do
date_time
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/astarte/common/generators/mqtt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ defmodule Astarte.Common.Generators.MQTT do
params gen all chars <- constant(valid_chars()),
allow_empty <- constant(false),
pre <- constant(""),
:_,
topic <-
string(chars, min_length: 1, max_length: 20)
|> list_of(min_length: allow_empty_to_length(allow_empty), max_length: 10)
|> map(&Enum.join(&1, "/"))
|> Utilities.print(pre: pre),
params: params do
params: params,
exclude: [:topic] do
topic
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/astarte/common/generators/timestamp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ defmodule Astarte.Common.Generators.Timestamp do
params gen all unit <- constant(@default_unit),
min <- constant(min_default(unit)),
max <- constant(max_default(unit)),
:_,
timestamp <- timestamp(min, max),
params: params do
params: params,
exclude: [:timestamp] do
timestamp
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/astarte/core/generators/mqtt_topic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ defmodule Astarte.Core.Generators.MQTTTopic do
def control_topic(params \\ []) do
params gen all realm_name <- RealmGenerarator.realm_name(),
device_id <- DeviceGenerarator.id(),
:_,
topic <-
MQTTGenerator.mqtt_topic(
chars: :alphanumeric,
pre: "#{realm_name}/#{device_id}/control/"
),
params: params do
params: params,
exclude: [:topic] do
topic
end
end
Expand All @@ -67,13 +67,13 @@ defmodule Astarte.Core.Generators.MQTTTopic do
params gen all realm_name <- RealmGenerarator.realm_name(),
device_id <- DeviceGenerarator.id(),
interface_name <- InterfaceGenerator.name(),
:_,
topic <-
MQTTGenerator.mqtt_topic(
chars: :alphanumeric,
pre: "#{realm_name}/#{device_id}/#{interface_name}/"
),
params: params do
params: params,
exclude: [:topic] do
topic
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ defmodule Astarte.Core.Generators.Triggers.SimpleEvents.IncomingDataEvent do
@spec incoming_data_event() :: StreamData.t(IncomingDataEvent.t())
@spec incoming_data_event(keyword :: keyword()) :: StreamData.t(IncomingDataEvent.t())
def incoming_data_event(params \\ []) do
params gen all :_,
%Interface{name: name} = interface <- InterfaceGenerator.interface(),
:_,
%{path: path} = package <- ValueGenerator.value(interface: interface),
:interface,
params gen all interface <- InterfaceGenerator.interface(),
%Interface{name: name} = interface,
package <- ValueGenerator.value(interface: interface),
%{path: path} = package,
interface_name <- constant(name),
path <- constant(path),
bson_value <- BSONValueGenerator.to_bson(%{package | path: path}),
params: params do
params: params,
exclude: [:interface, :package] do
%IncomingDataEvent{
interface: interface_name,
path: path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ defmodule Astarte.Core.Generators.Triggers.SimpleEvents.PathCreatedEvent do
@spec path_created_event() :: StreamData.t(PathCreatedEvent.t())
@spec path_created_event(keyword :: keyword()) :: StreamData.t(PathCreatedEvent.t())
def path_created_event(params \\ []) do
params gen all :_,
%Interface{name: name} = interface <- InterfaceGenerator.interface(),
:_,
%{path: path} = package <- ValueGenerator.value(interface: interface),
:interface,
params gen all interface <- InterfaceGenerator.interface(),
%Interface{name: name} = interface,
package <- ValueGenerator.value(interface: interface),
%{path: path} = package,
interface_name <- constant(name),
path <- constant(path),
bson_value <- BSONValueGenerator.to_bson(%{package | path: path}),
params: params do
params: params,
exclude: [:interface, :package] do
%PathCreatedEvent{
interface: interface_name,
path: path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ defmodule Astarte.Core.Generators.Triggers.SimpleEvents.PathRemovedEvent do
@spec path_removed_event() :: StreamData.t(PathRemovedEvent.t())
@spec path_removed_event(keyword :: keyword()) :: StreamData.t(PathRemovedEvent.t())
def path_removed_event(params \\ []) do
params gen all :_,
%Interface{name: name} = interface <- InterfaceGenerator.interface(),
:_,
%{path: path} <- ValueGenerator.value(interface: interface),
:interface,
params gen all interface <- InterfaceGenerator.interface(),
%Interface{name: name} = interface,
package <- ValueGenerator.value(interface: interface),
%{path: path} = package,
interface_name <- constant(name),
path <- constant(path),
params: params do
params: params,
exclude: [:interface, :package] do
%PathRemovedEvent{
interface: interface_name,
path: path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@ defmodule Astarte.Core.Generators.Triggers.SimpleEvents.ValueChangeAppliedEvent
@spec value_change_applied_event(keyword :: keyword()) ::
StreamData.t(ValueChangeAppliedEvent.t())
def value_change_applied_event(params \\ []) do
params gen all :_,
%Interface{name: name} = interface <- InterfaceGenerator.interface(),
:_,
%{path: path, type: type} = package <-
ValueGenerator.value(interface: interface),
:interface,
params gen all interface <- InterfaceGenerator.interface(),
%Interface{name: name} = interface,
package <- ValueGenerator.value(interface: interface),
%{path: path, type: value_type} = package,
interface_name <- constant(name),
path <- constant(path),
old_bson_value <- BSONValueGenerator.to_bson(%{package | path: path}),
new_bson_value <-
BSONValueGenerator.bson_value(interface: interface, path: path, type: type),
params: params do
BSONValueGenerator.bson_value(
interface: interface,
path: path,
type: value_type
),
params: params,
exclude: [:interface, :package] do
%ValueChangeAppliedEvent{
interface: interface_name,
path: path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ defmodule Astarte.Core.Generators.Triggers.SimpleEvents.ValueChangeEvent do
@spec value_change_event() :: StreamData.t(ValueChangeEvent.t())
@spec value_change_event(keyword :: keyword()) :: StreamData.t(ValueChangeEvent.t())
def value_change_event(params \\ []) do
params gen all :_,
%Interface{name: name} = interface <- InterfaceGenerator.interface(),
:_,
%{path: path, type: type} = package <-
ValueGenerator.value(interface: interface),
:interface,
params gen all interface <- InterfaceGenerator.interface(),
%Interface{name: name} = interface,
package <- ValueGenerator.value(interface: interface),
%{path: path, type: value_type} = package,
interface_name <- constant(name),
path <- constant(path),
old_bson_value <- BSONValueGenerator.to_bson(%{package | path: path}),
new_bson_value <-
BSONValueGenerator.bson_value(interface: interface, path: path, type: type),
params: params do
BSONValueGenerator.bson_value(
interface: interface,
path: path,
type: value_type
),
params: params,
exclude: [:interface, :package] do
%ValueChangeEvent{
interface: interface_name,
path: path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ defmodule Astarte.Core.Generators.Triggers.SimpleEvents.ValueStoredEvent do
@spec value_stored_event() :: StreamData.t(ValueStoredEvent.t())
@spec value_stored_event(keyword :: keyword()) :: StreamData.t(ValueStoredEvent.t())
def value_stored_event(params \\ []) do
params gen all :_,
%Interface{name: name} = interface <- InterfaceGenerator.interface(),
:_,
%{path: path} = package <- ValueGenerator.value(interface: interface),
:interface,
params gen all interface <- InterfaceGenerator.interface(),
%Interface{name: name} = interface,
package <- ValueGenerator.value(interface: interface),
%{path: path} = package,
interface_name <- constant(name),
path <- constant(path),
bson_value <- BSONValueGenerator.to_bson(%{package | path: path}),
params: params do
params: params,
exclude: [:interface, :package] do
%ValueStoredEvent{
interface: interface_name,
path: path,
Expand Down
Loading
Loading