Documentation ¶
Index ¶
- Constants
- Variables
- func NewDeviceNotObservedHandler(messenger messaging.MsgContext, svc AlarmService) messaging.TopicMessageHandler
- func NewDeviceStatusHandler(messenger messaging.MsgContext, svc AlarmService) messaging.TopicMessageHandler
- type AlarmClosed
- type AlarmCreated
- type AlarmRepository
- type AlarmRepositoryMock
- func (mock *AlarmRepositoryMock) AddAlarm(ctx context.Context, alarm types.Alarm) error
- func (mock *AlarmRepositoryMock) AddAlarmCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) CloseAlarm(ctx context.Context, alarmID string, tenant string) error
- func (mock *AlarmRepositoryMock) CloseAlarmCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) GetAlarm(ctx context.Context, conditions ...storage.ConditionFunc) (types.Alarm, error)
- func (mock *AlarmRepositoryMock) GetAlarmCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) QueryAlarms(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.Alarm], error)
- func (mock *AlarmRepositoryMock) QueryAlarmsCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) QueryInformation(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.InformationItem], error)
- func (mock *AlarmRepositoryMock) QueryInformationCalls() []struct{ ... }
- type AlarmService
- type AlarmServiceMock
- func (mock *AlarmServiceMock) Add(ctx context.Context, alarm types.Alarm) error
- func (mock *AlarmServiceMock) AddCalls() []struct{ ... }
- func (mock *AlarmServiceMock) Close(ctx context.Context, alarmID string, tenants []string) error
- func (mock *AlarmServiceMock) CloseCalls() []struct{ ... }
- func (mock *AlarmServiceMock) Get(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error)
- func (mock *AlarmServiceMock) GetByID(ctx context.Context, alarmID string, tenants []string) (types.Alarm, error)
- func (mock *AlarmServiceMock) GetByIDCalls() []struct{ ... }
- func (mock *AlarmServiceMock) GetByRefID(ctx context.Context, refID string, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error)
- func (mock *AlarmServiceMock) GetByRefIDCalls() []struct{ ... }
- func (mock *AlarmServiceMock) GetCalls() []struct{ ... }
- func (mock *AlarmServiceMock) Info(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.InformationItem], error)
- func (mock *AlarmServiceMock) InfoCalls() []struct{ ... }
Constants ¶
const AlarmDeviceNotObserved string = "DeviceNotObserved"
Variables ¶
var ErrAlarmNotFound = fmt.Errorf("alarm not found")
Functions ¶
func NewDeviceNotObservedHandler ¶
func NewDeviceNotObservedHandler(messenger messaging.MsgContext, svc AlarmService) messaging.TopicMessageHandler
func NewDeviceStatusHandler ¶
func NewDeviceStatusHandler(messenger messaging.MsgContext, svc AlarmService) messaging.TopicMessageHandler
Types ¶
type AlarmClosed ¶
type AlarmClosed struct { ID string `json:"id"` Tenant string `json:"tenant"` Timestamp time.Time `json:"timestamp"` }
func (*AlarmClosed) Body ¶
func (l *AlarmClosed) Body() []byte
func (*AlarmClosed) ContentType ¶
func (l *AlarmClosed) ContentType() string
func (*AlarmClosed) TopicName ¶
func (l *AlarmClosed) TopicName() string
type AlarmCreated ¶
type AlarmCreated struct { Alarm types.Alarm `json:"alarm"` Tenant string `json:"tenant"` Timestamp time.Time `json:"timestamp"` }
func (*AlarmCreated) Body ¶
func (l *AlarmCreated) Body() []byte
func (*AlarmCreated) ContentType ¶
func (l *AlarmCreated) ContentType() string
func (*AlarmCreated) TopicName ¶
func (l *AlarmCreated) TopicName() string
type AlarmRepository ¶
type AlarmRepository interface { QueryInformation(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.InformationItem], error) QueryAlarms(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.Alarm], error) GetAlarm(ctx context.Context, conditions ...storage.ConditionFunc) (types.Alarm, error) AddAlarm(ctx context.Context, alarm types.Alarm) error CloseAlarm(ctx context.Context, alarmID, tenant string) error }
type AlarmRepositoryMock ¶
type AlarmRepositoryMock struct { // AddAlarmFunc mocks the AddAlarm method. AddAlarmFunc func(ctx context.Context, alarm types.Alarm) error // CloseAlarmFunc mocks the CloseAlarm method. CloseAlarmFunc func(ctx context.Context, alarmID string, tenant string) error // GetAlarmFunc mocks the GetAlarm method. GetAlarmFunc func(ctx context.Context, conditions ...storage.ConditionFunc) (types.Alarm, error) // QueryAlarmsFunc mocks the QueryAlarms method. QueryAlarmsFunc func(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.Alarm], error) // QueryInformationFunc mocks the QueryInformation method. QueryInformationFunc func(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.InformationItem], error) // contains filtered or unexported fields }
AlarmRepositoryMock is a mock implementation of AlarmRepository.
func TestSomethingThatUsesAlarmRepository(t *testing.T) { // make and configure a mocked AlarmRepository mockedAlarmRepository := &AlarmRepositoryMock{ AddAlarmFunc: func(ctx context.Context, alarm types.Alarm) error { panic("mock out the AddAlarm method") }, CloseAlarmFunc: func(ctx context.Context, alarmID string, tenant string) error { panic("mock out the CloseAlarm method") }, GetAlarmFunc: func(ctx context.Context, conditions ...storage.ConditionFunc) (types.Alarm, error) { panic("mock out the GetAlarm method") }, QueryAlarmsFunc: func(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.Alarm], error) { panic("mock out the QueryAlarms method") }, QueryInformationFunc: func(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.InformationItem], error) { panic("mock out the QueryInformation method") }, } // use mockedAlarmRepository in code that requires AlarmRepository // and then make assertions. }
func (*AlarmRepositoryMock) AddAlarmCalls ¶
func (mock *AlarmRepositoryMock) AddAlarmCalls() []struct { Ctx context.Context Alarm types.Alarm }
AddAlarmCalls gets all the calls that were made to AddAlarm. Check the length with:
len(mockedAlarmRepository.AddAlarmCalls())
func (*AlarmRepositoryMock) CloseAlarm ¶
func (mock *AlarmRepositoryMock) CloseAlarm(ctx context.Context, alarmID string, tenant string) error
CloseAlarm calls CloseAlarmFunc.
func (*AlarmRepositoryMock) CloseAlarmCalls ¶
func (mock *AlarmRepositoryMock) CloseAlarmCalls() []struct { Ctx context.Context AlarmID string Tenant string }
CloseAlarmCalls gets all the calls that were made to CloseAlarm. Check the length with:
len(mockedAlarmRepository.CloseAlarmCalls())
func (*AlarmRepositoryMock) GetAlarm ¶
func (mock *AlarmRepositoryMock) GetAlarm(ctx context.Context, conditions ...storage.ConditionFunc) (types.Alarm, error)
GetAlarm calls GetAlarmFunc.
func (*AlarmRepositoryMock) GetAlarmCalls ¶
func (mock *AlarmRepositoryMock) GetAlarmCalls() []struct { Ctx context.Context Conditions []storage.ConditionFunc }
GetAlarmCalls gets all the calls that were made to GetAlarm. Check the length with:
len(mockedAlarmRepository.GetAlarmCalls())
func (*AlarmRepositoryMock) QueryAlarms ¶
func (mock *AlarmRepositoryMock) QueryAlarms(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.Alarm], error)
QueryAlarms calls QueryAlarmsFunc.
func (*AlarmRepositoryMock) QueryAlarmsCalls ¶
func (mock *AlarmRepositoryMock) QueryAlarmsCalls() []struct { Ctx context.Context Conditions []storage.ConditionFunc }
QueryAlarmsCalls gets all the calls that were made to QueryAlarms. Check the length with:
len(mockedAlarmRepository.QueryAlarmsCalls())
func (*AlarmRepositoryMock) QueryInformation ¶
func (mock *AlarmRepositoryMock) QueryInformation(ctx context.Context, conditions ...storage.ConditionFunc) (types.Collection[types.InformationItem], error)
QueryInformation calls QueryInformationFunc.
func (*AlarmRepositoryMock) QueryInformationCalls ¶
func (mock *AlarmRepositoryMock) QueryInformationCalls() []struct { Ctx context.Context Conditions []storage.ConditionFunc }
QueryInformationCalls gets all the calls that were made to QueryInformation. Check the length with:
len(mockedAlarmRepository.QueryInformationCalls())
type AlarmService ¶
type AlarmService interface { Get(ctx context.Context, offset, limit int, tenants []string) (types.Collection[types.Alarm], error) Info(ctx context.Context, offset, limit int, tenants []string) (types.Collection[types.InformationItem], error) GetByID(ctx context.Context, alarmID string, tenants []string) (types.Alarm, error) GetByRefID(ctx context.Context, refID string, offset, limit int, tenants []string) (types.Collection[types.Alarm], error) Add(ctx context.Context, alarm types.Alarm) error Close(ctx context.Context, alarmID string, tenants []string) error }
func New ¶
func New(d AlarmRepository, m messaging.MsgContext) AlarmService
type AlarmServiceMock ¶
type AlarmServiceMock struct { // AddFunc mocks the Add method. AddFunc func(ctx context.Context, alarm types.Alarm) error // CloseFunc mocks the Close method. CloseFunc func(ctx context.Context, alarmID string, tenants []string) error // GetFunc mocks the Get method. GetFunc func(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error) // GetByIDFunc mocks the GetByID method. GetByIDFunc func(ctx context.Context, alarmID string, tenants []string) (types.Alarm, error) // GetByRefIDFunc mocks the GetByRefID method. GetByRefIDFunc func(ctx context.Context, refID string, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error) // InfoFunc mocks the Info method. InfoFunc func(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.InformationItem], error) // contains filtered or unexported fields }
AlarmServiceMock is a mock implementation of AlarmService.
func TestSomethingThatUsesAlarmService(t *testing.T) { // make and configure a mocked AlarmService mockedAlarmService := &AlarmServiceMock{ AddFunc: func(ctx context.Context, alarm types.Alarm) error { panic("mock out the Add method") }, CloseFunc: func(ctx context.Context, alarmID string, tenants []string) error { panic("mock out the Close method") }, GetFunc: func(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error) { panic("mock out the Get method") }, GetByIDFunc: func(ctx context.Context, alarmID string, tenants []string) (types.Alarm, error) { panic("mock out the GetByID method") }, GetByRefIDFunc: func(ctx context.Context, refID string, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error) { panic("mock out the GetByRefID method") }, InfoFunc: func(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.InformationItem], error) { panic("mock out the Info method") }, } // use mockedAlarmService in code that requires AlarmService // and then make assertions. }
func (*AlarmServiceMock) AddCalls ¶
func (mock *AlarmServiceMock) AddCalls() []struct { Ctx context.Context Alarm types.Alarm }
AddCalls gets all the calls that were made to Add. Check the length with:
len(mockedAlarmService.AddCalls())
func (*AlarmServiceMock) CloseCalls ¶
func (mock *AlarmServiceMock) CloseCalls() []struct { Ctx context.Context AlarmID string Tenants []string }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedAlarmService.CloseCalls())
func (*AlarmServiceMock) Get ¶
func (mock *AlarmServiceMock) Get(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error)
Get calls GetFunc.
func (*AlarmServiceMock) GetByID ¶
func (mock *AlarmServiceMock) GetByID(ctx context.Context, alarmID string, tenants []string) (types.Alarm, error)
GetByID calls GetByIDFunc.
func (*AlarmServiceMock) GetByIDCalls ¶
func (mock *AlarmServiceMock) GetByIDCalls() []struct { Ctx context.Context AlarmID string Tenants []string }
GetByIDCalls gets all the calls that were made to GetByID. Check the length with:
len(mockedAlarmService.GetByIDCalls())
func (*AlarmServiceMock) GetByRefID ¶
func (mock *AlarmServiceMock) GetByRefID(ctx context.Context, refID string, offset int, limit int, tenants []string) (types.Collection[types.Alarm], error)
GetByRefID calls GetByRefIDFunc.
func (*AlarmServiceMock) GetByRefIDCalls ¶
func (mock *AlarmServiceMock) GetByRefIDCalls() []struct { Ctx context.Context RefID string Offset int Limit int Tenants []string }
GetByRefIDCalls gets all the calls that were made to GetByRefID. Check the length with:
len(mockedAlarmService.GetByRefIDCalls())
func (*AlarmServiceMock) GetCalls ¶
func (mock *AlarmServiceMock) GetCalls() []struct { Ctx context.Context Offset int Limit int Tenants []string }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedAlarmService.GetCalls())
func (*AlarmServiceMock) Info ¶
func (mock *AlarmServiceMock) Info(ctx context.Context, offset int, limit int, tenants []string) (types.Collection[types.InformationItem], error)
Info calls InfoFunc.