Documentation ¶
Index ¶
- Variables
- func MapAll[T any](arr []any) ([]T, error)
- func MapOne[T any](v any) (T, error)
- func NewAlarmClosedHandler(svc DeviceManagement) messaging.TopicMessageHandler
- func NewAlarmCreatedHandler(svc DeviceManagement) messaging.TopicMessageHandler
- func NewDeviceStatusHandler(messenger messaging.MsgContext, svc DeviceManagement) messaging.TopicMessageHandler
- type DeviceManagement
- type DeviceManagementConfig
- type DeviceManagementMock
- func (mock *DeviceManagementMock) Create(ctx context.Context, device models.Device) error
- func (mock *DeviceManagementMock) CreateCalls() []struct{ ... }
- func (mock *DeviceManagementMock) Get(ctx context.Context, offset int, limit int, q string, tenants []string) (repositories.Collection[models.Device], error)
- func (mock *DeviceManagementMock) GetByDeviceID(ctx context.Context, deviceID string, tenants []string) (models.Device, error)
- func (mock *DeviceManagementMock) GetByDeviceIDCalls() []struct{ ... }
- func (mock *DeviceManagementMock) GetBySensorID(ctx context.Context, sensorID string, tenants []string) (models.Device, error)
- func (mock *DeviceManagementMock) GetBySensorIDCalls() []struct{ ... }
- func (mock *DeviceManagementMock) GetCalls() []struct{ ... }
- func (mock *DeviceManagementMock) GetDeviceProfiles(ctx context.Context, name ...string) (repositories.Collection[models.DeviceProfile], error)
- func (mock *DeviceManagementMock) GetDeviceProfilesCalls() []struct{ ... }
- func (mock *DeviceManagementMock) GetLwm2mTypes(ctx context.Context, urn ...string) (repositories.Collection[models.Lwm2mType], error)
- func (mock *DeviceManagementMock) GetLwm2mTypesCalls() []struct{ ... }
- func (mock *DeviceManagementMock) GetWithAlarmID(ctx context.Context, alarmID string, tenants []string) (models.Device, error)
- func (mock *DeviceManagementMock) GetWithAlarmIDCalls() []struct{ ... }
- func (mock *DeviceManagementMock) Merge(ctx context.Context, deviceID string, fields map[string]any, tenants []string) error
- func (mock *DeviceManagementMock) MergeCalls() []struct{ ... }
- func (mock *DeviceManagementMock) Seed(ctx context.Context, reader io.Reader, tenants []string) error
- func (mock *DeviceManagementMock) SeedCalls() []struct{ ... }
- func (mock *DeviceManagementMock) Update(ctx context.Context, device models.Device) error
- func (mock *DeviceManagementMock) UpdateCalls() []struct{ ... }
- func (mock *DeviceManagementMock) UpdateState(ctx context.Context, deviceID string, tenant string, ...) error
- func (mock *DeviceManagementMock) UpdateStateCalls() []struct{ ... }
- func (mock *DeviceManagementMock) UpdateStatus(ctx context.Context, deviceID string, tenant string, ...) error
- func (mock *DeviceManagementMock) UpdateStatusCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
var ErrDeviceNotFound = fmt.Errorf("device not found")
var ErrDeviceProfileNotFound = fmt.Errorf("device profile not found")
Functions ¶
func NewAlarmClosedHandler ¶
func NewAlarmClosedHandler(svc DeviceManagement) messaging.TopicMessageHandler
func NewAlarmCreatedHandler ¶
func NewAlarmCreatedHandler(svc DeviceManagement) messaging.TopicMessageHandler
func NewDeviceStatusHandler ¶
func NewDeviceStatusHandler(messenger messaging.MsgContext, svc DeviceManagement) messaging.TopicMessageHandler
Types ¶
type DeviceManagement ¶
type DeviceManagement interface { Get(ctx context.Context, offset, limit int, q string, tenants []string) (repositories.Collection[models.Device], error) GetBySensorID(ctx context.Context, sensorID string, tenants []string) (models.Device, error) GetByDeviceID(ctx context.Context, deviceID string, tenants []string) (models.Device, error) GetWithAlarmID(ctx context.Context, alarmID string, tenants []string) (models.Device, error) Create(ctx context.Context, device models.Device) error Update(ctx context.Context, device models.Device) error Merge(ctx context.Context, deviceID string, fields map[string]any, tenants []string) error UpdateStatus(ctx context.Context, deviceID, tenant string, deviceStatus models.DeviceStatus) error UpdateState(ctx context.Context, deviceID, tenant string, deviceState models.DeviceState) error Seed(ctx context.Context, reader io.Reader, tenants []string) error GetLwm2mTypes(ctx context.Context, urn ...string) (repositories.Collection[models.Lwm2mType], error) GetDeviceProfiles(ctx context.Context, name ...string) (repositories.Collection[models.DeviceProfile], error) }
func New ¶
func New(d deviceStorage.DeviceRepository, m messaging.MsgContext, config *DeviceManagementConfig) DeviceManagement
type DeviceManagementConfig ¶
type DeviceManagementConfig struct { DeviceProfiles []models.DeviceProfile `yaml:"deviceprofiles"` Types []models.Lwm2mType `yaml:"types"` }
type DeviceManagementMock ¶
type DeviceManagementMock struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, device models.Device) error // GetFunc mocks the Get method. GetFunc func(ctx context.Context, offset int, limit int, q string, tenants []string) (repositories.Collection[models.Device], error) // GetByDeviceIDFunc mocks the GetByDeviceID method. GetByDeviceIDFunc func(ctx context.Context, deviceID string, tenants []string) (models.Device, error) // GetBySensorIDFunc mocks the GetBySensorID method. GetBySensorIDFunc func(ctx context.Context, sensorID string, tenants []string) (models.Device, error) // GetDeviceProfilesFunc mocks the GetDeviceProfiles method. GetDeviceProfilesFunc func(ctx context.Context, name ...string) (repositories.Collection[models.DeviceProfile], error) // GetLwm2mTypesFunc mocks the GetLwm2mTypes method. GetLwm2mTypesFunc func(ctx context.Context, urn ...string) (repositories.Collection[models.Lwm2mType], error) // GetWithAlarmIDFunc mocks the GetWithAlarmID method. GetWithAlarmIDFunc func(ctx context.Context, alarmID string, tenants []string) (models.Device, error) // MergeFunc mocks the Merge method. MergeFunc func(ctx context.Context, deviceID string, fields map[string]any, tenants []string) error // SeedFunc mocks the Seed method. SeedFunc func(ctx context.Context, reader io.Reader, tenants []string) error // UpdateFunc mocks the Update method. UpdateFunc func(ctx context.Context, device models.Device) error // UpdateStateFunc mocks the UpdateState method. UpdateStateFunc func(ctx context.Context, deviceID string, tenant string, deviceState models.DeviceState) error // UpdateStatusFunc mocks the UpdateStatus method. UpdateStatusFunc func(ctx context.Context, deviceID string, tenant string, deviceStatus models.DeviceStatus) error // contains filtered or unexported fields }
DeviceManagementMock is a mock implementation of DeviceManagement.
func TestSomethingThatUsesDeviceManagement(t *testing.T) { // make and configure a mocked DeviceManagement mockedDeviceManagement := &DeviceManagementMock{ CreateFunc: func(ctx context.Context, device models.Device) error { panic("mock out the Create method") }, GetFunc: func(ctx context.Context, offset int, limit int, q string, tenants []string) (repositories.Collection[models.Device], error) { panic("mock out the Get method") }, GetByDeviceIDFunc: func(ctx context.Context, deviceID string, tenants []string) (models.Device, error) { panic("mock out the GetByDeviceID method") }, GetBySensorIDFunc: func(ctx context.Context, sensorID string, tenants []string) (models.Device, error) { panic("mock out the GetBySensorID method") }, GetDeviceProfilesFunc: func(ctx context.Context, name ...string) (repositories.Collection[models.DeviceProfile], error) { panic("mock out the GetDeviceProfiles method") }, GetLwm2mTypesFunc: func(ctx context.Context, urn ...string) (repositories.Collection[models.Lwm2mType], error) { panic("mock out the GetLwm2mTypes method") }, GetWithAlarmIDFunc: func(ctx context.Context, alarmID string, tenants []string) (models.Device, error) { panic("mock out the GetWithAlarmID method") }, MergeFunc: func(ctx context.Context, deviceID string, fields map[string]any, tenants []string) error { panic("mock out the Merge method") }, SeedFunc: func(ctx context.Context, reader io.Reader, tenants []string) error { panic("mock out the Seed method") }, UpdateFunc: func(ctx context.Context, device models.Device) error { panic("mock out the Update method") }, UpdateStateFunc: func(ctx context.Context, deviceID string, tenant string, deviceState models.DeviceState) error { panic("mock out the UpdateState method") }, UpdateStatusFunc: func(ctx context.Context, deviceID string, tenant string, deviceStatus models.DeviceStatus) error { panic("mock out the UpdateStatus method") }, } // use mockedDeviceManagement in code that requires DeviceManagement // and then make assertions. }
func (*DeviceManagementMock) CreateCalls ¶
func (mock *DeviceManagementMock) CreateCalls() []struct { Ctx context.Context Device models.Device }
CreateCalls gets all the calls that were made to Create. Check the length with:
len(mockedDeviceManagement.CreateCalls())
func (*DeviceManagementMock) Get ¶
func (mock *DeviceManagementMock) Get(ctx context.Context, offset int, limit int, q string, tenants []string) (repositories.Collection[models.Device], error)
Get calls GetFunc.
func (*DeviceManagementMock) GetByDeviceID ¶
func (mock *DeviceManagementMock) GetByDeviceID(ctx context.Context, deviceID string, tenants []string) (models.Device, error)
GetByDeviceID calls GetByDeviceIDFunc.
func (*DeviceManagementMock) GetByDeviceIDCalls ¶
func (mock *DeviceManagementMock) GetByDeviceIDCalls() []struct { Ctx context.Context DeviceID string Tenants []string }
GetByDeviceIDCalls gets all the calls that were made to GetByDeviceID. Check the length with:
len(mockedDeviceManagement.GetByDeviceIDCalls())
func (*DeviceManagementMock) GetBySensorID ¶
func (mock *DeviceManagementMock) GetBySensorID(ctx context.Context, sensorID string, tenants []string) (models.Device, error)
GetBySensorID calls GetBySensorIDFunc.
func (*DeviceManagementMock) GetBySensorIDCalls ¶
func (mock *DeviceManagementMock) GetBySensorIDCalls() []struct { Ctx context.Context SensorID string Tenants []string }
GetBySensorIDCalls gets all the calls that were made to GetBySensorID. Check the length with:
len(mockedDeviceManagement.GetBySensorIDCalls())
func (*DeviceManagementMock) GetCalls ¶
func (mock *DeviceManagementMock) GetCalls() []struct { Ctx context.Context Offset int Limit int Q string Tenants []string }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedDeviceManagement.GetCalls())
func (*DeviceManagementMock) GetDeviceProfiles ¶
func (mock *DeviceManagementMock) GetDeviceProfiles(ctx context.Context, name ...string) (repositories.Collection[models.DeviceProfile], error)
GetDeviceProfiles calls GetDeviceProfilesFunc.
func (*DeviceManagementMock) GetDeviceProfilesCalls ¶
func (mock *DeviceManagementMock) GetDeviceProfilesCalls() []struct { Ctx context.Context Name []string }
GetDeviceProfilesCalls gets all the calls that were made to GetDeviceProfiles. Check the length with:
len(mockedDeviceManagement.GetDeviceProfilesCalls())
func (*DeviceManagementMock) GetLwm2mTypes ¶
func (mock *DeviceManagementMock) GetLwm2mTypes(ctx context.Context, urn ...string) (repositories.Collection[models.Lwm2mType], error)
GetLwm2mTypes calls GetLwm2mTypesFunc.
func (*DeviceManagementMock) GetLwm2mTypesCalls ¶
func (mock *DeviceManagementMock) GetLwm2mTypesCalls() []struct { Ctx context.Context Urn []string }
GetLwm2mTypesCalls gets all the calls that were made to GetLwm2mTypes. Check the length with:
len(mockedDeviceManagement.GetLwm2mTypesCalls())
func (*DeviceManagementMock) GetWithAlarmID ¶
func (mock *DeviceManagementMock) GetWithAlarmID(ctx context.Context, alarmID string, tenants []string) (models.Device, error)
GetWithAlarmID calls GetWithAlarmIDFunc.
func (*DeviceManagementMock) GetWithAlarmIDCalls ¶
func (mock *DeviceManagementMock) GetWithAlarmIDCalls() []struct { Ctx context.Context AlarmID string Tenants []string }
GetWithAlarmIDCalls gets all the calls that were made to GetWithAlarmID. Check the length with:
len(mockedDeviceManagement.GetWithAlarmIDCalls())
func (*DeviceManagementMock) Merge ¶
func (mock *DeviceManagementMock) Merge(ctx context.Context, deviceID string, fields map[string]any, tenants []string) error
Merge calls MergeFunc.
func (*DeviceManagementMock) MergeCalls ¶
func (mock *DeviceManagementMock) MergeCalls() []struct { Ctx context.Context DeviceID string Fields map[string]any Tenants []string }
MergeCalls gets all the calls that were made to Merge. Check the length with:
len(mockedDeviceManagement.MergeCalls())
func (*DeviceManagementMock) Seed ¶
func (mock *DeviceManagementMock) Seed(ctx context.Context, reader io.Reader, tenants []string) error
Seed calls SeedFunc.
func (*DeviceManagementMock) SeedCalls ¶
func (mock *DeviceManagementMock) SeedCalls() []struct { Ctx context.Context Reader io.Reader Tenants []string }
SeedCalls gets all the calls that were made to Seed. Check the length with:
len(mockedDeviceManagement.SeedCalls())
func (*DeviceManagementMock) UpdateCalls ¶
func (mock *DeviceManagementMock) UpdateCalls() []struct { Ctx context.Context Device models.Device }
UpdateCalls gets all the calls that were made to Update. Check the length with:
len(mockedDeviceManagement.UpdateCalls())
func (*DeviceManagementMock) UpdateState ¶
func (mock *DeviceManagementMock) UpdateState(ctx context.Context, deviceID string, tenant string, deviceState models.DeviceState) error
UpdateState calls UpdateStateFunc.
func (*DeviceManagementMock) UpdateStateCalls ¶
func (mock *DeviceManagementMock) UpdateStateCalls() []struct { Ctx context.Context DeviceID string Tenant string DeviceState models.DeviceState }
UpdateStateCalls gets all the calls that were made to UpdateState. Check the length with:
len(mockedDeviceManagement.UpdateStateCalls())
func (*DeviceManagementMock) UpdateStatus ¶
func (mock *DeviceManagementMock) UpdateStatus(ctx context.Context, deviceID string, tenant string, deviceStatus models.DeviceStatus) error
UpdateStatus calls UpdateStatusFunc.
func (*DeviceManagementMock) UpdateStatusCalls ¶
func (mock *DeviceManagementMock) UpdateStatusCalls() []struct { Ctx context.Context DeviceID string Tenant string DeviceStatus models.DeviceStatus }
UpdateStatusCalls gets all the calls that were made to UpdateStatus. Check the length with:
len(mockedDeviceManagement.UpdateStatusCalls())