From 62d61212ac5c66ab0499860e988cc3468359e627 Mon Sep 17 00:00:00 2001 From: Ginny Guan Date: Mon, 6 Nov 2023 14:22:29 +0800 Subject: [PATCH] EDX-4384 Update client interfaces to use int64 for time range fix xpert manager timestamp parse error on arm32 Signed-off-by: Ginny Guan --- clients/http/event.go | 4 +- clients/http/event_test.go | 6 +- clients/http/notification.go | 4 +- clients/http/notification_test.go | 6 +- clients/http/reading.go | 16 +- clients/http/reading_test.go | 24 +-- clients/http/transmission.go | 4 +- clients/http/transmission_test.go | 6 +- clients/interfaces/event.go | 2 +- clients/interfaces/mocks/EventClient.go | 23 ++- .../interfaces/mocks/NotificationClient.go | 156 ++++++++++++++---- clients/interfaces/mocks/ReadingClient.go | 41 +++-- .../interfaces/mocks/TransmissionClient.go | 23 ++- clients/interfaces/notification.go | 2 +- clients/interfaces/reading.go | 8 +- clients/interfaces/transmission.go | 2 +- 16 files changed, 228 insertions(+), 99 deletions(-) diff --git a/clients/http/event.go b/clients/http/event.go index e7d8f497..8d887595 100644 --- a/clients/http/event.go +++ b/clients/http/event.go @@ -102,9 +102,9 @@ func (ec *eventClient) DeleteByDeviceName(ctx context.Context, name string) (dto return res, nil } -func (ec *eventClient) EventsByTimeRange(ctx context.Context, start, end, offset, limit int) ( +func (ec *eventClient) EventsByTimeRange(ctx context.Context, start, end int64, offset, limit int) ( responses.MultiEventsResponse, errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiEventRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + requestPath := utils.EscapeAndJoinPath(common.ApiEventRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) diff --git a/clients/http/event_test.go b/clients/http/event_test.go index 74ddf51c..e048fcb6 100644 --- a/clients/http/event_test.go +++ b/clients/http/event_test.go @@ -91,9 +91,9 @@ func TestDeleteEventsByDeviceName(t *testing.T) { } func TestQueryEventsByTimeRange(t *testing.T) { - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiEventRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiEventRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiEventsResponse{}) defer ts.Close() diff --git a/clients/http/notification.go b/clients/http/notification.go index 70c9cff0..0c3b997f 100644 --- a/clients/http/notification.go +++ b/clients/http/notification.go @@ -103,8 +103,8 @@ func (client *NotificationClient) NotificationsByStatus(ctx context.Context, sta } // NotificationsByTimeRange query notifications with time range, offset and limit -func (client *NotificationClient) NotificationsByTimeRange(ctx context.Context, start int, end int, offset int, limit int, ack string) (res responses.MultiNotificationsResponse, err errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiNotificationRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) +func (client *NotificationClient) NotificationsByTimeRange(ctx context.Context, start, end int64, offset int, limit int, ack string) (res responses.MultiNotificationsResponse, err errors.EdgeX) { + requestPath := utils.EscapeAndJoinPath(common.ApiNotificationRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) diff --git a/clients/http/notification_test.go b/clients/http/notification_test.go index f7607b88..8dea8752 100644 --- a/clients/http/notification_test.go +++ b/clients/http/notification_test.go @@ -100,9 +100,9 @@ func TestNotificationClient_NotificationsBySubscriptionName(t *testing.T) { } func TestNotificationClient_NotificationsByTimeRange(t *testing.T) { - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiNotificationRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiNotificationRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiNotificationsResponse{}) defer ts.Close() client := NewNotificationClient(ts.URL) diff --git a/clients/http/reading.go b/clients/http/reading.go index 64e028cc..35a9f7e3 100644 --- a/clients/http/reading.go +++ b/clients/http/reading.go @@ -86,8 +86,8 @@ func (rc readingClient) ReadingsByResourceName(ctx context.Context, name string, return res, nil } -func (rc readingClient) ReadingsByTimeRange(ctx context.Context, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) +func (rc readingClient) ReadingsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { + requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) @@ -100,8 +100,8 @@ func (rc readingClient) ReadingsByTimeRange(ctx context.Context, start, end, off } // ReadingsByResourceNameAndTimeRange returns readings by resource name and specified time range. Readings are sorted in descending order of origin time. -func (rc readingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.ResourceName, name, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) +func (rc readingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { + requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.ResourceName, name, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) @@ -127,8 +127,8 @@ func (rc readingClient) ReadingsByDeviceNameAndResourceName(ctx context.Context, } -func (rc readingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName, resourceName string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.ResourceName, resourceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) +func (rc readingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName, resourceName string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { + requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.ResourceName, resourceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) @@ -140,8 +140,8 @@ func (rc readingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx cont return res, nil } -func (rc readingClient) ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) +func (rc readingClient) ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { + requestPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) diff --git a/clients/http/reading_test.go b/clients/http/reading_test.go index ff670324..64f7e923 100644 --- a/clients/http/reading_test.go +++ b/clients/http/reading_test.go @@ -77,9 +77,9 @@ func TestQueryReadingsByResourceName(t *testing.T) { } func TestQueryReadingsByTimeRange(t *testing.T) { - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{}) defer ts.Close() @@ -91,9 +91,9 @@ func TestQueryReadingsByTimeRange(t *testing.T) { func TestQueryReadingsByResourceNameAndTimeRange(t *testing.T) { resourceName := "resource" - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.ResourceName, resourceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.ResourceName, resourceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{}) defer ts.Close() @@ -119,9 +119,9 @@ func TestQueryReadingsByDeviceNameAndResourceName(t *testing.T) { func TestQueryReadingsByDeviceNameAndResourceNameAndTimeRange(t *testing.T) { deviceName := "device" resourceName := "resource" - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.ResourceName, resourceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.ResourceName, resourceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{}) defer ts.Close() @@ -134,9 +134,9 @@ func TestQueryReadingsByDeviceNameAndResourceNameAndTimeRange(t *testing.T) { func TestQueryReadingsByDeviceNameAndResourceNamesAndTimeRange(t *testing.T) { deviceName := "device" resourceNames := []string{"resource01", "resource02"} - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{}) defer ts.Close() diff --git a/clients/http/transmission.go b/clients/http/transmission.go index f6e33562..b9db3f3f 100644 --- a/clients/http/transmission.go +++ b/clients/http/transmission.go @@ -40,8 +40,8 @@ func (client *TransmissionClient) TransmissionById(ctx context.Context, id strin } // TransmissionsByTimeRange query transmissions with time range, offset and limit -func (client *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (res responses.MultiTransmissionsResponse, err errors.EdgeX) { - requestPath := utils.EscapeAndJoinPath(common.ApiTransmissionRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) +func (client *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, start, end int64, offset int, limit int) (res responses.MultiTransmissionsResponse, err errors.EdgeX) { + requestPath := utils.EscapeAndJoinPath(common.ApiTransmissionRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) requestParams := url.Values{} requestParams.Set(common.Offset, strconv.Itoa(offset)) requestParams.Set(common.Limit, strconv.Itoa(limit)) diff --git a/clients/http/transmission_test.go b/clients/http/transmission_test.go index e602c19c..229b98db 100644 --- a/clients/http/transmission_test.go +++ b/clients/http/transmission_test.go @@ -74,9 +74,9 @@ func TestTransmissionClient_TransmissionsBySubscriptionName(t *testing.T) { } func TestTransmissionClient_TransmissionsByTimeRange(t *testing.T) { - start := 1 - end := 10 - urlPath := utils.EscapeAndJoinPath(common.ApiTransmissionRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end)) + start := int64(1) + end := int64(10) + urlPath := utils.EscapeAndJoinPath(common.ApiTransmissionRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10)) ts := newTestServer(http.MethodGet, urlPath, responses.MultiTransmissionsResponse{}) defer ts.Close() client := NewTransmissionClient(ts.URL) diff --git a/clients/interfaces/event.go b/clients/interfaces/event.go index 4574254a..9c1c15a1 100644 --- a/clients/interfaces/event.go +++ b/clients/interfaces/event.go @@ -37,7 +37,7 @@ type EventClient interface { // start, end: Unix timestamp, indicating the date/time range. // offset: The number of items to skip before starting to collect the result set. Default is 0. // limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20. - EventsByTimeRange(ctx context.Context, start, end, offset, limit int) (responses.MultiEventsResponse, errors.EdgeX) + EventsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (responses.MultiEventsResponse, errors.EdgeX) // DeleteByAge deletes events that are older than the given age. Age is supposed in milliseconds from created timestamp. DeleteByAge(ctx context.Context, age int) (common.BaseResponse, errors.EdgeX) } diff --git a/clients/interfaces/mocks/EventClient.go b/clients/interfaces/mocks/EventClient.go index a77f3744..7bfb15ac 100644 --- a/clients/interfaces/mocks/EventClient.go +++ b/clients/interfaces/mocks/EventClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.5.1. DO NOT EDIT. +// Code generated by mockery v2.16.0. DO NOT EDIT. package mocks @@ -183,18 +183,18 @@ func (_m *EventClient) EventsByDeviceName(ctx context.Context, name string, offs } // EventsByTimeRange provides a mock function with given fields: ctx, start, end, offset, limit -func (_m *EventClient) EventsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (responses.MultiEventsResponse, errors.EdgeX) { +func (_m *EventClient) EventsByTimeRange(ctx context.Context, start int64, end int64, offset int, limit int) (responses.MultiEventsResponse, errors.EdgeX) { ret := _m.Called(ctx, start, end, offset, limit) var r0 responses.MultiEventsResponse - if rf, ok := ret.Get(0).(func(context.Context, int, int, int, int) responses.MultiEventsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, int64, int, int) responses.MultiEventsResponse); ok { r0 = rf(ctx, start, end, offset, limit) } else { r0 = ret.Get(0).(responses.MultiEventsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, int, int, int, int) errors.EdgeX); ok { + if rf, ok := ret.Get(1).(func(context.Context, int64, int64, int, int) errors.EdgeX); ok { r1 = rf(ctx, start, end, offset, limit) } else { if ret.Get(1) != nil { @@ -204,3 +204,18 @@ func (_m *EventClient) EventsByTimeRange(ctx context.Context, start int, end int return r0, r1 } + +type mockConstructorTestingTNewEventClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewEventClient creates a new instance of EventClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewEventClient(t mockConstructorTestingTNewEventClient) *EventClient { + mock := &EventClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/clients/interfaces/mocks/NotificationClient.go b/clients/interfaces/mocks/NotificationClient.go index 1e88ae62..172a2a90 100644 --- a/clients/interfaces/mocks/NotificationClient.go +++ b/clients/interfaces/mocks/NotificationClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.4. DO NOT EDIT. +// Code generated by mockery v2.16.0. DO NOT EDIT. package mocks @@ -90,6 +90,29 @@ func (_m *NotificationClient) DeleteNotificationById(ctx context.Context, id str return r0, r1 } +// DeleteNotificationByIds provides a mock function with given fields: ctx, ids +func (_m *NotificationClient) DeleteNotificationByIds(ctx context.Context, ids []string) (common.BaseResponse, errors.EdgeX) { + ret := _m.Called(ctx, ids) + + var r0 common.BaseResponse + if rf, ok := ret.Get(0).(func(context.Context, []string) common.BaseResponse); ok { + r0 = rf(ctx, ids) + } else { + r0 = ret.Get(0).(common.BaseResponse) + } + + var r1 errors.EdgeX + if rf, ok := ret.Get(1).(func(context.Context, []string) errors.EdgeX); ok { + r1 = rf(ctx, ids) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(errors.EdgeX) + } + } + + return r0, r1 +} + // DeleteProcessedNotificationsByAge provides a mock function with given fields: ctx, age func (_m *NotificationClient) DeleteProcessedNotificationsByAge(ctx context.Context, age int) (common.BaseResponse, errors.EdgeX) { ret := _m.Called(ctx, age) @@ -136,20 +159,43 @@ func (_m *NotificationClient) NotificationById(ctx context.Context, id string) ( return r0, r1 } -// NotificationsByCategory provides a mock function with given fields: ctx, category, offset, limit -func (_m *NotificationClient) NotificationsByCategory(ctx context.Context, category string, offset int, limit int) (responses.MultiNotificationsResponse, errors.EdgeX) { - ret := _m.Called(ctx, category, offset, limit) +// NotificationsByCategory provides a mock function with given fields: ctx, category, offset, limit, ack +func (_m *NotificationClient) NotificationsByCategory(ctx context.Context, category string, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) { + ret := _m.Called(ctx, category, offset, limit, ack) + + var r0 responses.MultiNotificationsResponse + if rf, ok := ret.Get(0).(func(context.Context, string, int, int, string) responses.MultiNotificationsResponse); ok { + r0 = rf(ctx, category, offset, limit, ack) + } else { + r0 = ret.Get(0).(responses.MultiNotificationsResponse) + } + + var r1 errors.EdgeX + if rf, ok := ret.Get(1).(func(context.Context, string, int, int, string) errors.EdgeX); ok { + r1 = rf(ctx, category, offset, limit, ack) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(errors.EdgeX) + } + } + + return r0, r1 +} + +// NotificationsByLabel provides a mock function with given fields: ctx, label, offset, limit, ack +func (_m *NotificationClient) NotificationsByLabel(ctx context.Context, label string, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) { + ret := _m.Called(ctx, label, offset, limit, ack) var r0 responses.MultiNotificationsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, int, int) responses.MultiNotificationsResponse); ok { - r0 = rf(ctx, category, offset, limit) + if rf, ok := ret.Get(0).(func(context.Context, string, int, int, string) responses.MultiNotificationsResponse); ok { + r0 = rf(ctx, label, offset, limit, ack) } else { r0 = ret.Get(0).(responses.MultiNotificationsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, int, int) errors.EdgeX); ok { - r1 = rf(ctx, category, offset, limit) + if rf, ok := ret.Get(1).(func(context.Context, string, int, int, string) errors.EdgeX); ok { + r1 = rf(ctx, label, offset, limit, ack) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.EdgeX) @@ -159,20 +205,20 @@ func (_m *NotificationClient) NotificationsByCategory(ctx context.Context, categ return r0, r1 } -// NotificationsByLabel provides a mock function with given fields: ctx, label, offset, limit -func (_m *NotificationClient) NotificationsByLabel(ctx context.Context, label string, offset int, limit int) (responses.MultiNotificationsResponse, errors.EdgeX) { - ret := _m.Called(ctx, label, offset, limit) +// NotificationsByQueryConditions provides a mock function with given fields: ctx, offset, limit, ack, conditionReq +func (_m *NotificationClient) NotificationsByQueryConditions(ctx context.Context, offset int, limit int, ack string, conditionReq requests.GetNotificationRequest) (responses.MultiNotificationsResponse, errors.EdgeX) { + ret := _m.Called(ctx, offset, limit, ack, conditionReq) var r0 responses.MultiNotificationsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, int, int) responses.MultiNotificationsResponse); ok { - r0 = rf(ctx, label, offset, limit) + if rf, ok := ret.Get(0).(func(context.Context, int, int, string, requests.GetNotificationRequest) responses.MultiNotificationsResponse); ok { + r0 = rf(ctx, offset, limit, ack, conditionReq) } else { r0 = ret.Get(0).(responses.MultiNotificationsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, int, int) errors.EdgeX); ok { - r1 = rf(ctx, label, offset, limit) + if rf, ok := ret.Get(1).(func(context.Context, int, int, string, requests.GetNotificationRequest) errors.EdgeX); ok { + r1 = rf(ctx, offset, limit, ack, conditionReq) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.EdgeX) @@ -182,20 +228,20 @@ func (_m *NotificationClient) NotificationsByLabel(ctx context.Context, label st return r0, r1 } -// NotificationsByStatus provides a mock function with given fields: ctx, status, offset, limit -func (_m *NotificationClient) NotificationsByStatus(ctx context.Context, status string, offset int, limit int) (responses.MultiNotificationsResponse, errors.EdgeX) { - ret := _m.Called(ctx, status, offset, limit) +// NotificationsByStatus provides a mock function with given fields: ctx, status, offset, limit, ack +func (_m *NotificationClient) NotificationsByStatus(ctx context.Context, status string, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) { + ret := _m.Called(ctx, status, offset, limit, ack) var r0 responses.MultiNotificationsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, int, int) responses.MultiNotificationsResponse); ok { - r0 = rf(ctx, status, offset, limit) + if rf, ok := ret.Get(0).(func(context.Context, string, int, int, string) responses.MultiNotificationsResponse); ok { + r0 = rf(ctx, status, offset, limit, ack) } else { r0 = ret.Get(0).(responses.MultiNotificationsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, int, int) errors.EdgeX); ok { - r1 = rf(ctx, status, offset, limit) + if rf, ok := ret.Get(1).(func(context.Context, string, int, int, string) errors.EdgeX); ok { + r1 = rf(ctx, status, offset, limit, ack) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.EdgeX) @@ -205,20 +251,20 @@ func (_m *NotificationClient) NotificationsByStatus(ctx context.Context, status return r0, r1 } -// NotificationsBySubscriptionName provides a mock function with given fields: ctx, subscriptionName, offset, limit -func (_m *NotificationClient) NotificationsBySubscriptionName(ctx context.Context, subscriptionName string, offset int, limit int) (responses.MultiNotificationsResponse, errors.EdgeX) { - ret := _m.Called(ctx, subscriptionName, offset, limit) +// NotificationsBySubscriptionName provides a mock function with given fields: ctx, subscriptionName, offset, limit, ack +func (_m *NotificationClient) NotificationsBySubscriptionName(ctx context.Context, subscriptionName string, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) { + ret := _m.Called(ctx, subscriptionName, offset, limit, ack) var r0 responses.MultiNotificationsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, int, int) responses.MultiNotificationsResponse); ok { - r0 = rf(ctx, subscriptionName, offset, limit) + if rf, ok := ret.Get(0).(func(context.Context, string, int, int, string) responses.MultiNotificationsResponse); ok { + r0 = rf(ctx, subscriptionName, offset, limit, ack) } else { r0 = ret.Get(0).(responses.MultiNotificationsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, int, int) errors.EdgeX); ok { - r1 = rf(ctx, subscriptionName, offset, limit) + if rf, ok := ret.Get(1).(func(context.Context, string, int, int, string) errors.EdgeX); ok { + r1 = rf(ctx, subscriptionName, offset, limit, ack) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.EdgeX) @@ -228,20 +274,20 @@ func (_m *NotificationClient) NotificationsBySubscriptionName(ctx context.Contex return r0, r1 } -// NotificationsByTimeRange provides a mock function with given fields: ctx, start, end, offset, limit -func (_m *NotificationClient) NotificationsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (responses.MultiNotificationsResponse, errors.EdgeX) { - ret := _m.Called(ctx, start, end, offset, limit) +// NotificationsByTimeRange provides a mock function with given fields: ctx, start, end, offset, limit, ack +func (_m *NotificationClient) NotificationsByTimeRange(ctx context.Context, start int64, end int64, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) { + ret := _m.Called(ctx, start, end, offset, limit, ack) var r0 responses.MultiNotificationsResponse - if rf, ok := ret.Get(0).(func(context.Context, int, int, int, int) responses.MultiNotificationsResponse); ok { - r0 = rf(ctx, start, end, offset, limit) + if rf, ok := ret.Get(0).(func(context.Context, int64, int64, int, int, string) responses.MultiNotificationsResponse); ok { + r0 = rf(ctx, start, end, offset, limit, ack) } else { r0 = ret.Get(0).(responses.MultiNotificationsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, int, int, int, int) errors.EdgeX); ok { - r1 = rf(ctx, start, end, offset, limit) + if rf, ok := ret.Get(1).(func(context.Context, int64, int64, int, int, string) errors.EdgeX); ok { + r1 = rf(ctx, start, end, offset, limit, ack) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(errors.EdgeX) @@ -275,3 +321,41 @@ func (_m *NotificationClient) SendNotification(ctx context.Context, reqs []reque return r0, r1 } + +// UpdateNotificationAckStatusByIds provides a mock function with given fields: ctx, ack, ids +func (_m *NotificationClient) UpdateNotificationAckStatusByIds(ctx context.Context, ack bool, ids []string) (common.BaseResponse, errors.EdgeX) { + ret := _m.Called(ctx, ack, ids) + + var r0 common.BaseResponse + if rf, ok := ret.Get(0).(func(context.Context, bool, []string) common.BaseResponse); ok { + r0 = rf(ctx, ack, ids) + } else { + r0 = ret.Get(0).(common.BaseResponse) + } + + var r1 errors.EdgeX + if rf, ok := ret.Get(1).(func(context.Context, bool, []string) errors.EdgeX); ok { + r1 = rf(ctx, ack, ids) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(errors.EdgeX) + } + } + + return r0, r1 +} + +type mockConstructorTestingTNewNotificationClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewNotificationClient creates a new instance of NotificationClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewNotificationClient(t mockConstructorTestingTNewNotificationClient) *NotificationClient { + mock := &NotificationClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/clients/interfaces/mocks/ReadingClient.go b/clients/interfaces/mocks/ReadingClient.go index 162acfc3..9cc3c791 100644 --- a/clients/interfaces/mocks/ReadingClient.go +++ b/clients/interfaces/mocks/ReadingClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.16.0. DO NOT EDIT. package mocks @@ -135,18 +135,18 @@ func (_m *ReadingClient) ReadingsByDeviceNameAndResourceName(ctx context.Context } // ReadingsByDeviceNameAndResourceNameAndTimeRange provides a mock function with given fields: ctx, deviceName, resourceName, start, end, offset, limit -func (_m *ReadingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName string, resourceName string, start int, end int, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { +func (_m *ReadingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName string, resourceName string, start int64, end int64, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { ret := _m.Called(ctx, deviceName, resourceName, start, end, offset, limit) var r0 responses.MultiReadingsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, string, int, int, int, int) responses.MultiReadingsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, int64, int, int) responses.MultiReadingsResponse); ok { r0 = rf(ctx, deviceName, resourceName, start, end, offset, limit) } else { r0 = ret.Get(0).(responses.MultiReadingsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, string, int, int, int, int) errors.EdgeX); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, int64, int64, int, int) errors.EdgeX); ok { r1 = rf(ctx, deviceName, resourceName, start, end, offset, limit) } else { if ret.Get(1) != nil { @@ -158,18 +158,18 @@ func (_m *ReadingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx con } // ReadingsByDeviceNameAndResourceNamesAndTimeRange provides a mock function with given fields: ctx, deviceName, resourceNames, start, end, offset, limit -func (_m *ReadingClient) ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start int, end int, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { +func (_m *ReadingClient) ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start int64, end int64, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { ret := _m.Called(ctx, deviceName, resourceNames, start, end, offset, limit) var r0 responses.MultiReadingsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, []string, int, int, int, int) responses.MultiReadingsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, []string, int64, int64, int, int) responses.MultiReadingsResponse); ok { r0 = rf(ctx, deviceName, resourceNames, start, end, offset, limit) } else { r0 = ret.Get(0).(responses.MultiReadingsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, []string, int, int, int, int) errors.EdgeX); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, []string, int64, int64, int, int) errors.EdgeX); ok { r1 = rf(ctx, deviceName, resourceNames, start, end, offset, limit) } else { if ret.Get(1) != nil { @@ -204,18 +204,18 @@ func (_m *ReadingClient) ReadingsByResourceName(ctx context.Context, name string } // ReadingsByResourceNameAndTimeRange provides a mock function with given fields: ctx, name, start, end, offset, limit -func (_m *ReadingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start int, end int, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { +func (_m *ReadingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start int64, end int64, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { ret := _m.Called(ctx, name, start, end, offset, limit) var r0 responses.MultiReadingsResponse - if rf, ok := ret.Get(0).(func(context.Context, string, int, int, int, int) responses.MultiReadingsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, int64, int64, int, int) responses.MultiReadingsResponse); ok { r0 = rf(ctx, name, start, end, offset, limit) } else { r0 = ret.Get(0).(responses.MultiReadingsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, string, int, int, int, int) errors.EdgeX); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, int64, int64, int, int) errors.EdgeX); ok { r1 = rf(ctx, name, start, end, offset, limit) } else { if ret.Get(1) != nil { @@ -227,18 +227,18 @@ func (_m *ReadingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, } // ReadingsByTimeRange provides a mock function with given fields: ctx, start, end, offset, limit -func (_m *ReadingClient) ReadingsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { +func (_m *ReadingClient) ReadingsByTimeRange(ctx context.Context, start int64, end int64, offset int, limit int) (responses.MultiReadingsResponse, errors.EdgeX) { ret := _m.Called(ctx, start, end, offset, limit) var r0 responses.MultiReadingsResponse - if rf, ok := ret.Get(0).(func(context.Context, int, int, int, int) responses.MultiReadingsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, int64, int, int) responses.MultiReadingsResponse); ok { r0 = rf(ctx, start, end, offset, limit) } else { r0 = ret.Get(0).(responses.MultiReadingsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, int, int, int, int) errors.EdgeX); ok { + if rf, ok := ret.Get(1).(func(context.Context, int64, int64, int, int) errors.EdgeX); ok { r1 = rf(ctx, start, end, offset, limit) } else { if ret.Get(1) != nil { @@ -248,3 +248,18 @@ func (_m *ReadingClient) ReadingsByTimeRange(ctx context.Context, start int, end return r0, r1 } + +type mockConstructorTestingTNewReadingClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewReadingClient creates a new instance of ReadingClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewReadingClient(t mockConstructorTestingTNewReadingClient) *ReadingClient { + mock := &ReadingClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/clients/interfaces/mocks/TransmissionClient.go b/clients/interfaces/mocks/TransmissionClient.go index be397cb5..7ec5c2e6 100644 --- a/clients/interfaces/mocks/TransmissionClient.go +++ b/clients/interfaces/mocks/TransmissionClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.9.4. DO NOT EDIT. +// Code generated by mockery v2.16.0. DO NOT EDIT. package mocks @@ -158,18 +158,18 @@ func (_m *TransmissionClient) TransmissionsBySubscriptionName(ctx context.Contex } // TransmissionsByTimeRange provides a mock function with given fields: ctx, start, end, offset, limit -func (_m *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (responses.MultiTransmissionsResponse, errors.EdgeX) { +func (_m *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, start int64, end int64, offset int, limit int) (responses.MultiTransmissionsResponse, errors.EdgeX) { ret := _m.Called(ctx, start, end, offset, limit) var r0 responses.MultiTransmissionsResponse - if rf, ok := ret.Get(0).(func(context.Context, int, int, int, int) responses.MultiTransmissionsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, int64, int, int) responses.MultiTransmissionsResponse); ok { r0 = rf(ctx, start, end, offset, limit) } else { r0 = ret.Get(0).(responses.MultiTransmissionsResponse) } var r1 errors.EdgeX - if rf, ok := ret.Get(1).(func(context.Context, int, int, int, int) errors.EdgeX); ok { + if rf, ok := ret.Get(1).(func(context.Context, int64, int64, int, int) errors.EdgeX); ok { r1 = rf(ctx, start, end, offset, limit) } else { if ret.Get(1) != nil { @@ -179,3 +179,18 @@ func (_m *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, star return r0, r1 } + +type mockConstructorTestingTNewTransmissionClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewTransmissionClient creates a new instance of TransmissionClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewTransmissionClient(t mockConstructorTestingTNewTransmissionClient) *TransmissionClient { + mock := &TransmissionClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/clients/interfaces/notification.go b/clients/interfaces/notification.go index c95eca31..5c1ea19d 100644 --- a/clients/interfaces/notification.go +++ b/clients/interfaces/notification.go @@ -29,7 +29,7 @@ type NotificationClient interface { // NotificationsByStatus queries notifications with status, offset, ack and limit NotificationsByStatus(ctx context.Context, status string, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) // NotificationsByTimeRange query notifications with time range, offset, ack and limit - NotificationsByTimeRange(ctx context.Context, start int, end int, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) + NotificationsByTimeRange(ctx context.Context, start, end int64, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) // NotificationsBySubscriptionName query notifications with subscriptionName, offset, ack and limit NotificationsBySubscriptionName(ctx context.Context, subscriptionName string, offset int, limit int, ack string) (responses.MultiNotificationsResponse, errors.EdgeX) // CleanupNotificationsByAge removes notifications that are older than age. And the corresponding transmissions will also be deleted. diff --git a/clients/interfaces/reading.go b/clients/interfaces/reading.go index cb40d5fc..034d2010 100644 --- a/clients/interfaces/reading.go +++ b/clients/interfaces/reading.go @@ -36,12 +36,12 @@ type ReadingClient interface { // start, end: Unix timestamp, indicating the date/time range. // offset: The number of items to skip before starting to collect the result set. Default is 0. // limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20. - ReadingsByTimeRange(ctx context.Context, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) + ReadingsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) // ReadingsByResourceNameAndTimeRange returns readings by resource name and specified time range. Readings are sorted in descending order of origin time. // start, end: Unix timestamp, indicating the date/time range // offset: The number of items to skip before starting to collect the result set. Default is 0. // limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20. - ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) + ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) // ReadingsByDeviceNameAndResourceName returns readings by device name and resource name. Readings are sorted in descending order of origin time. // offset: The number of items to skip before starting to collect the result set. Default is 0. // limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20. @@ -50,11 +50,11 @@ type ReadingClient interface { // start, end: Unix timestamp, indicating the date/time range // offset: The number of items to skip before starting to collect the result set. Default is 0. // limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20. - ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName, resourceName string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) + ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName, resourceName string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) // ReadingsByDeviceNameAndResourceNamesAndTimeRange returns readings by device name, multiple resource names and specified time range. Readings are sorted in descending order of origin time. // If none of resourceNames is specified, return all Readings under specified deviceName and within specified time range // start, end: Unix timestamp, indicating the date/time range // offset: The number of items to skip before starting to collect the result set. Default is 0. // limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20. - ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) + ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) } diff --git a/clients/interfaces/transmission.go b/clients/interfaces/transmission.go index 56ac3e74..61fc9134 100644 --- a/clients/interfaces/transmission.go +++ b/clients/interfaces/transmission.go @@ -18,7 +18,7 @@ type TransmissionClient interface { // TransmissionById query transmission by id. TransmissionById(ctx context.Context, id string) (responses.TransmissionResponse, errors.EdgeX) // TransmissionsByTimeRange query transmissions with time range, offset and limit - TransmissionsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (responses.MultiTransmissionsResponse, errors.EdgeX) + TransmissionsByTimeRange(ctx context.Context, start, end int64, offset int, limit int) (responses.MultiTransmissionsResponse, errors.EdgeX) // AllTransmissions query transmissions with offset and limit AllTransmissions(ctx context.Context, offset int, limit int) (responses.MultiTransmissionsResponse, errors.EdgeX) // TransmissionsByStatus queries transmissions with status, offset and limit