alarms

package
v0.0.0-...-1ca8fc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AlarmDeviceNotObserved string = "DeviceNotObserved"

Variables

This section is empty.

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 AlarmService

type AlarmService interface {
	Get(ctx context.Context, offset, limit int, tenants []string) (repositories.Collection[models.Alarm], error)
	GetByID(ctx context.Context, alarmID string, tenants []string) (models.Alarm, error)
	GetByRefID(ctx context.Context, refID string, offset, limit int, tenants []string) (repositories.Collection[models.Alarm], error)
	Add(ctx context.Context, alarm models.Alarm) error
	Close(ctx context.Context, alarmID string, tenants []string) error
}

type AlarmServiceMock

type AlarmServiceMock struct {
	// AddFunc mocks the Add method.
	AddFunc func(ctx context.Context, alarm models.Alarm) error

	// CloseFunc mocks the Close method.
	CloseFunc func(ctx context.Context, alarmID string, tenants []string) error

	// GetAlarmByIDFunc mocks the GetAlarmByID method.
	GetAlarmByIDFunc func(ctx context.Context, alarmID string, tenants []string) (models.Alarm, error)

	// GetAlarmsFunc mocks the GetAlarms method.
	GetAlarmsFunc func(ctx context.Context, offset int, limit int, tenants []string) (repositories.Collection[models.Alarm], error)

	// GetAlarmsByRefIDFunc mocks the GetAlarmsByRefID method.
	GetAlarmsByRefIDFunc func(ctx context.Context, refID string, offset int, limit int, tenants []string) (repositories.Collection[models.Alarm], 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 models.Alarm) error {
			panic("mock out the Add method")
		},
		CloseFunc: func(ctx context.Context, alarmID string, tenants []string) error {
			panic("mock out the Close method")
		},
		GetAlarmByIDFunc: func(ctx context.Context, alarmID string, tenants []string) (models.Alarm, error) {
			panic("mock out the GetAlarmByID method")
		},
		GetAlarmsFunc: func(ctx context.Context, offset int, limit int, tenants []string) (repositories.Collection[models.Alarm], error) {
			panic("mock out the GetAlarms method")
		},
		GetAlarmsByRefIDFunc: func(ctx context.Context, refID string, offset int, limit int, tenants []string) (repositories.Collection[models.Alarm], error) {
			panic("mock out the GetAlarmsByRefID method")
		},
	}

	// use mockedAlarmService in code that requires AlarmService
	// and then make assertions.

}

func (*AlarmServiceMock) Add

func (mock *AlarmServiceMock) Add(ctx context.Context, alarm models.Alarm) error

Add calls AddFunc.

func (*AlarmServiceMock) AddCalls

func (mock *AlarmServiceMock) AddCalls() []struct {
	Ctx   context.Context
	Alarm models.Alarm
}

AddCalls gets all the calls that were made to Add. Check the length with:

len(mockedAlarmService.AddCalls())

func (*AlarmServiceMock) Close

func (mock *AlarmServiceMock) Close(ctx context.Context, alarmID string, tenants []string) error

Close calls CloseFunc.

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) (repositories.Collection[models.Alarm], error)

Get calls GetAlarmsFunc.

func (*AlarmServiceMock) GetAlarmByIDCalls

func (mock *AlarmServiceMock) GetAlarmByIDCalls() []struct {
	Ctx     context.Context
	AlarmID string
	Tenants []string
}

GetAlarmByIDCalls gets all the calls that were made to GetAlarmByID. Check the length with:

len(mockedAlarmService.GetAlarmByIDCalls())

func (*AlarmServiceMock) GetAlarmsByRefIDCalls

func (mock *AlarmServiceMock) GetAlarmsByRefIDCalls() []struct {
	Ctx     context.Context
	RefID   string
	Offset  int
	Limit   int
	Tenants []string
}

GetAlarmsByRefIDCalls gets all the calls that were made to GetAlarmsByRefID. Check the length with:

len(mockedAlarmService.GetAlarmsByRefIDCalls())

func (*AlarmServiceMock) GetAlarmsCalls

func (mock *AlarmServiceMock) GetAlarmsCalls() []struct {
	Ctx     context.Context
	Offset  int
	Limit   int
	Tenants []string
}

GetAlarmsCalls gets all the calls that were made to GetAlarms. Check the length with:

len(mockedAlarmService.GetAlarmsCalls())

func (*AlarmServiceMock) GetByID

func (mock *AlarmServiceMock) GetByID(ctx context.Context, alarmID string, tenants []string) (models.Alarm, error)

GetByID calls GetAlarmByIDFunc.

func (*AlarmServiceMock) GetByRefID

func (mock *AlarmServiceMock) GetByRefID(ctx context.Context, refID string, offset int, limit int, tenants []string) (repositories.Collection[models.Alarm], error)

GetByRefID calls GetAlarmsByRefIDFunc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL