Skip to content

Commit

Permalink
Merge branch 'main' into ekuiper-connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenny Goodell authored Oct 26, 2021
2 parents 52087c0 + 11dac8c commit 8537e0f
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 102 deletions.
2 changes: 1 addition & 1 deletion internal/core/metadata/application/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func AllDevices(offset int, limit int, labels []string, dic *di.Container) (devi
dbClient := container.DBClientFrom(dic.Get)
deviceModels, err := dbClient.AllDevices(offset, limit, labels)
if err == nil {
totalCount, err = dbClient.DeviceTotalCount()
totalCount, err = dbClient.DeviceCountByLabels(labels)
}
if err != nil {
return devices, totalCount, errors.NewCommonEdgeXWrapper(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/core/metadata/application/deviceprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func AllDeviceProfiles(offset int, limit int, labels []string, dic *di.Container
dbClient := container.DBClientFrom(dic.Get)
dps, err := dbClient.AllDeviceProfiles(offset, limit, labels)
if err == nil {
totalCount, err = dbClient.DeviceProfileTotalCount()
totalCount, err = dbClient.DeviceProfileCountByLabels(labels)
}
if err != nil {
return deviceProfiles, totalCount, errors.NewCommonEdgeXWrapper(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/core/metadata/application/deviceservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func AllDeviceServices(offset int, limit int, labels []string, ctx context.Conte
dbClient := container.DBClientFrom(dic.Get)
services, err := dbClient.AllDeviceServices(offset, limit, labels)
if err == nil {
totalCount, err = dbClient.DeviceServiceTotalCount()
totalCount, err = dbClient.DeviceServiceCountByLabels(labels)
}
if err != nil {
return deviceServices, totalCount, errors.NewCommonEdgeXWrapper(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/core/metadata/application/provisionwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func AllProvisionWatchers(offset int, limit int, labels []string, dic *di.Contai
dbClient := container.DBClientFrom(dic.Get)
pwModels, err := dbClient.AllProvisionWatchers(offset, limit, labels)
if err == nil {
totalCount, err = dbClient.ProvisionWatcherTotalCount()
totalCount, err = dbClient.ProvisionWatcherCountByLabels(labels)
}
if err != nil {
return provisionWatchers, totalCount, errors.NewCommonEdgeXWrapper(err)
Expand Down
3 changes: 2 additions & 1 deletion internal/core/metadata/controller/http/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ func TestAllDevices(t *testing.T) {

dic := mockDic()
dbClientMock := &dbMock.DBClient{}
dbClientMock.On("DeviceTotalCount").Return(expectedDeviceTotalCount, nil)
dbClientMock.On("DeviceCountByLabels", []string(nil)).Return(expectedDeviceTotalCount, nil)
dbClientMock.On("DeviceCountByLabels", testDeviceLabels).Return(expectedDeviceTotalCount, nil)
dbClientMock.On("AllDevices", 0, 10, []string(nil)).Return(devices, nil)
dbClientMock.On("AllDevices", 0, 5, testDeviceLabels).Return([]models.Device{devices[0], devices[1]}, nil)
dbClientMock.On("AllDevices", 1, 2, []string(nil)).Return([]models.Device{devices[1], devices[2]}, nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/core/metadata/controller/http/deviceprofile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ func TestAllDeviceProfiles(t *testing.T) {

dic := mockDic()
dbClientMock := &dbMock.DBClient{}
dbClientMock.On("DeviceProfileTotalCount").Return(expectedTotalProfileCount, nil)
dbClientMock.On("DeviceProfileCountByLabels", []string(nil)).Return(expectedTotalProfileCount, nil)
dbClientMock.On("DeviceProfileCountByLabels", testDeviceProfileLabels).Return(expectedTotalProfileCount, nil)
dbClientMock.On("AllDeviceProfiles", 0, 10, []string(nil)).Return(deviceProfiles, nil)
dbClientMock.On("AllDeviceProfiles", 0, 5, testDeviceProfileLabels).Return([]models.DeviceProfile{deviceProfiles[0], deviceProfiles[1]}, nil)
dbClientMock.On("AllDeviceProfiles", 1, 2, []string(nil)).Return([]models.DeviceProfile{deviceProfiles[1], deviceProfiles[2]}, nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/core/metadata/controller/http/deviceservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ func TestAllDeviceServices(t *testing.T) {

dic := mockDic()
dbClientMock := &dbMock.DBClient{}
dbClientMock.On("DeviceServiceTotalCount").Return(expectedTotalDeviceServiceCount, nil)
dbClientMock.On("DeviceServiceCountByLabels", []string(nil)).Return(expectedTotalDeviceServiceCount, nil)
dbClientMock.On("DeviceServiceCountByLabels", testDeviceServiceLabels).Return(expectedTotalDeviceServiceCount, nil)
dbClientMock.On("AllDeviceServices", 0, 10, []string(nil)).Return(deviceServices, nil)
dbClientMock.On("AllDeviceServices", 0, 5, testDeviceServiceLabels).Return([]models.DeviceService{deviceServices[0], deviceServices[1]}, nil)
dbClientMock.On("AllDeviceServices", 1, 2, []string(nil)).Return([]models.DeviceService{deviceServices[1], deviceServices[2]}, nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ func TestProvisionWatcherController_AllProvisionWatchers(t *testing.T) {

dic := mockDic()
dbClientMock := &mocks.DBClient{}
dbClientMock.On("ProvisionWatcherTotalCount").Return(expectedTotalPWCount, nil)
dbClientMock.On("ProvisionWatcherCountByLabels", []string(nil)).Return(expectedTotalPWCount, nil)
dbClientMock.On("ProvisionWatcherCountByLabels", testProvisionWatcherLabels).Return(expectedTotalPWCount, nil)
dbClientMock.On("AllProvisionWatchers", 0, 10, []string(nil)).Return(provisionWatchers, nil)
dbClientMock.On("AllProvisionWatchers", 0, 5, testProvisionWatcherLabels).Return([]models.ProvisionWatcher{provisionWatchers[0], provisionWatchers[1]}, nil)
dbClientMock.On("AllProvisionWatchers", 1, 2, []string(nil)).Return([]models.ProvisionWatcher{provisionWatchers[1], provisionWatchers[2]}, nil)
Expand Down
8 changes: 4 additions & 4 deletions internal/core/metadata/infrastructure/interfaces/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type DBClient interface {
DeviceProfilesByModel(offset int, limit int, model string) ([]model.DeviceProfile, errors.EdgeX)
DeviceProfilesByManufacturer(offset int, limit int, manufacturer string) ([]model.DeviceProfile, errors.EdgeX)
DeviceProfilesByManufacturerAndModel(offset int, limit int, manufacturer string, model string) ([]model.DeviceProfile, uint32, errors.EdgeX)
DeviceProfileTotalCount() (uint32, errors.EdgeX)
DeviceProfileCountByLabels(labels []string) (uint32, errors.EdgeX)
DeviceProfileCountByManufacturer(manufacturer string) (uint32, errors.EdgeX)
DeviceProfileCountByModel(model string) (uint32, errors.EdgeX)

Expand All @@ -35,7 +35,7 @@ type DBClient interface {
DeviceServiceNameExists(name string) (bool, errors.EdgeX)
AllDeviceServices(offset int, limit int, labels []string) ([]model.DeviceService, errors.EdgeX)
UpdateDeviceService(ds model.DeviceService) errors.EdgeX
DeviceServiceTotalCount() (uint32, errors.EdgeX)
DeviceServiceCountByLabels(labels []string) (uint32, errors.EdgeX)

AddDevice(d model.Device) (model.Device, errors.EdgeX)
DeleteDeviceById(id string) errors.EdgeX
Expand All @@ -48,7 +48,7 @@ type DBClient interface {
AllDevices(offset int, limit int, labels []string) ([]model.Device, errors.EdgeX)
DevicesByProfileName(offset int, limit int, profileName string) ([]model.Device, errors.EdgeX)
UpdateDevice(d model.Device) errors.EdgeX
DeviceTotalCount() (uint32, errors.EdgeX)
DeviceCountByLabels(labels []string) (uint32, errors.EdgeX)
DeviceCountByProfileName(profileName string) (uint32, errors.EdgeX)
DeviceCountByServiceName(serviceName string) (uint32, errors.EdgeX)

Expand All @@ -60,7 +60,7 @@ type DBClient interface {
AllProvisionWatchers(offset int, limit int, labels []string) ([]model.ProvisionWatcher, errors.EdgeX)
DeleteProvisionWatcherByName(name string) errors.EdgeX
UpdateProvisionWatcher(pw model.ProvisionWatcher) errors.EdgeX
ProvisionWatcherTotalCount() (uint32, errors.EdgeX)
ProvisionWatcherCountByLabels(labels []string) (uint32, errors.EdgeX)
ProvisionWatcherCountByServiceName(name string) (uint32, errors.EdgeX)
ProvisionWatcherCountByProfileName(name string) (uint32, errors.EdgeX)
}
156 changes: 78 additions & 78 deletions internal/core/metadata/infrastructure/interfaces/mocks/DBClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8537e0f

Please sign in to comment.