From 24f5622f1132f88af426bf107bb6fb8e5d3a21c6 Mon Sep 17 00:00:00 2001 From: Cloud Tsai Date: Sun, 11 Oct 2020 11:19:24 +0800 Subject: [PATCH] fix: replace ID to Id in V2 Replace RequestID with RequestId and Event.ID with Event.Id to make the term consistent. Fix https://github.com/edgexfoundry/go-mod-core-contracts/issues/328 Signed-off-by: Cloud Tsai --- v2/dtos/common/base.go | 6 ++-- v2/dtos/common/base_test.go | 24 +++++++------- v2/dtos/event.go | 4 +-- v2/dtos/event_test.go | 4 +-- v2/dtos/requests/device_test.go | 28 ++++++++-------- v2/dtos/requests/deviceprofile_test.go | 2 +- v2/dtos/requests/deviceservice_test.go | 28 ++++++++-------- v2/dtos/requests/event.go | 2 +- v2/dtos/requests/event_test.go | 28 ++++++++-------- v2/dtos/responses/device_test.go | 12 +++---- v2/dtos/responses/deviceprofile_test.go | 12 +++---- v2/dtos/responses/deviceservice_test.go | 12 +++---- v2/dtos/responses/event.go | 4 +-- v2/dtos/responses/event_test.go | 44 ++++++++++++------------- v2/dtos/responses/reading_test.go | 24 +++++++------- v2/models/device.go | 2 +- 16 files changed, 118 insertions(+), 118 deletions(-) diff --git a/v2/dtos/common/base.go b/v2/dtos/common/base.go index 22560033..1d933024 100644 --- a/v2/dtos/common/base.go +++ b/v2/dtos/common/base.go @@ -11,7 +11,7 @@ import v2 "github.com/edgexfoundry/go-mod-core-contracts/v2" // This object and its properties correspond to the BaseRequest object in the APIv2 specification: // https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/core-data/2.x#/BaseRequest type BaseRequest struct { - RequestID string `json:"requestId" validate:"len=0|uuid"` + RequestId string `json:"requestId" validate:"len=0|uuid"` } // BaseResponse defines the base content for response DTOs (data transfer objects). @@ -19,7 +19,7 @@ type BaseRequest struct { // https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/core-data/2.x#/BaseResponse type BaseResponse struct { Versionable `json:",inline"` - RequestID string `json:"requestId"` + RequestId string `json:"requestId"` Message interface{} `json:"message,omitempty"` StatusCode int `json:"statusCode"` } @@ -44,7 +44,7 @@ func NewBaseResponseNoMessage(requestId string, statusCode int) BaseResponse { func NewBaseResponse(requestId string, message string, statusCode int) BaseResponse { return BaseResponse{ Versionable: NewVersionable(), - RequestID: requestId, + RequestId: requestId, Message: message, StatusCode: statusCode, } diff --git a/v2/dtos/common/base_test.go b/v2/dtos/common/base_test.go index 3c1ce644..cec845ce 100644 --- a/v2/dtos/common/base_test.go +++ b/v2/dtos/common/base_test.go @@ -15,22 +15,22 @@ import ( ) func TestNewBaseResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" - actual := NewBaseResponse(expectedRequestID, expectedMessage, expectedStatusCode) + actual := NewBaseResponse(expectedRequestId, expectedMessage, expectedStatusCode) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) } func TestNewBaseResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 - actual := NewBaseResponseNoMessage(expectedRequestID, expectedStatusCode) + actual := NewBaseResponseNoMessage(expectedRequestId, expectedStatusCode) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Empty(t, actual.Message) } @@ -41,25 +41,25 @@ func TestNewVersionable(t *testing.T) { } func TestNewBaseWithIdResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedId := "7a1707f0-166f-4c4b-bc9d-1d54c74e0137" - actual := NewBaseWithIdResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedId) + actual := NewBaseWithIdResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedId) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedId, actual.Id) } func TestNewBaseWithIdResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedId := "7a1707f0-166f-4c4b-bc9d-1d54c74e0137" - actual := NewBaseWithIdResponseNoMessage(expectedRequestID, expectedStatusCode, expectedId) + actual := NewBaseWithIdResponseNoMessage(expectedRequestId, expectedStatusCode, expectedId) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedId, actual.Id) } diff --git a/v2/dtos/event.go b/v2/dtos/event.go index 3b024995..2bec5102 100644 --- a/v2/dtos/event.go +++ b/v2/dtos/event.go @@ -20,7 +20,7 @@ import ( // https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/core-data/2.x#/Event type Event struct { common.Versionable `json:",inline"` - ID string `json:"id" validate:"required,uuid"` + Id string `json:"id" validate:"required,uuid"` Pushed int64 `json:"pushed,omitempty"` DeviceName string `json:"deviceName" validate:"required"` Created int64 `json:"created"` @@ -42,7 +42,7 @@ func FromEventModelToDTO(event models.Event) Event { return Event{ Versionable: common.Versionable{ApiVersion: v2.ApiVersion}, - ID: event.Id, + Id: event.Id, Pushed: event.Pushed, DeviceName: event.DeviceName, Created: event.Created, diff --git a/v2/dtos/event_test.go b/v2/dtos/event_test.go index 8680caf9..9953491c 100644 --- a/v2/dtos/event_test.go +++ b/v2/dtos/event_test.go @@ -31,7 +31,7 @@ var valid = models.Event{ var expectedDTO = Event{ Versionable: common.Versionable{ApiVersion: v2.ApiVersion}, - ID: TestUUID, + Id: TestUUID, Pushed: TestTimestamp, DeviceName: TestDeviceName, Created: TestTimestamp, @@ -61,7 +61,7 @@ func TestFromEventModelToDTO(t *testing.T) { func TestEvent_ToXML(t *testing.T) { // Since the order in map is random we have to verify the individual items exists without depending on order contains := []string{ - "v27a1707f0-166f-4c4b-bc9d-1d54c74e01371594963842TestDevice15949638421594963842", + "v27a1707f0-166f-4c4b-bc9d-1d54c74e01371594963842TestDevice15949638421594963842", "Houston-0001", "29.630771", "-95.377603", diff --git a/v2/dtos/requests/device_test.go b/v2/dtos/requests/device_test.go index 78071533..da027725 100644 --- a/v2/dtos/requests/device_test.go +++ b/v2/dtos/requests/device_test.go @@ -36,7 +36,7 @@ var testProtocols = map[string]dtos.ProtocolProperties{ } var testAddDevice = AddDeviceRequest{ BaseRequest: common.BaseRequest{ - RequestID: ExampleUUID, + RequestId: ExampleUUID, }, Device: dtos.Device{ Name: TestDeviceName, @@ -54,7 +54,7 @@ var testAddDevice = AddDeviceRequest{ var testNowTime = time.Now().Unix() var testUpdateDevice = UpdateDeviceRequest{ BaseRequest: common.BaseRequest{ - RequestID: ExampleUUID, + RequestId: ExampleUUID, }, Device: mockUpdateDevice(), } @@ -88,10 +88,10 @@ func TestAddDeviceRequest_Validate(t *testing.T) { valid := testAddDevice invalidFrequency := testAddDevice invalidFrequency.Device.AutoEvents = testAutoEventsWithInvalidFrequency - noReqID := testAddDevice - noReqID.RequestID = "" - invalidReqID := testAddDevice - invalidReqID.RequestID = "abc" + noReqId := testAddDevice + noReqId.RequestId = "" + invalidReqId := testAddDevice + invalidReqId.RequestId = "abc" noDeviceName := testAddDevice noDeviceName.Device.Name = "" noServiceName := testAddDevice @@ -115,8 +115,8 @@ func TestAddDeviceRequest_Validate(t *testing.T) { }{ {"valid AddDeviceRequest", valid, false}, {"invalid AddDeviceRequest, invalid autoEvent frequency", invalidFrequency, true}, - {"valid AddDeviceRequest, no Request Id", noReqID, false}, - {"invalid AddDeviceRequest, Request Id is not an uuid", invalidReqID, true}, + {"valid AddDeviceRequest, no Request Id", noReqId, false}, + {"invalid AddDeviceRequest, Request Id is not an uuid", invalidReqId, true}, {"invalid AddDeviceRequest, no DeviceName", noDeviceName, true}, {"invalid AddDeviceRequest, no ServiceName", noServiceName, true}, {"invalid AddDeviceRequest, no ProfileName", noProfileName, true}, @@ -227,10 +227,10 @@ func TestUpdateDeviceRequest_Validate(t *testing.T) { validWithoutId.Device.Id = nil validWithoutDeviceName := testUpdateDevice validWithoutDeviceName.Device.Name = nil - noReqID := testUpdateDevice - noReqID.RequestID = "" - invalidReqID := testUpdateDevice - invalidReqID.RequestID = "123" + noReqId := testUpdateDevice + noReqId.RequestId = "" + invalidReqId := testUpdateDevice + invalidReqId.RequestId = "123" noIdAndDeviceName := testUpdateDevice noIdAndDeviceName.Device.Id = nil noIdAndDeviceName.Device.Name = nil @@ -251,8 +251,8 @@ func TestUpdateDeviceRequest_Validate(t *testing.T) { {"valid UpdateDeviceRequest", valid, false}, {"valid UpdateDeviceRequest without Id", validWithoutId, false}, {"valid UpdateDeviceRequest without Name", validWithoutDeviceName, false}, - {"valid UpdateDeviceRequest, no Request Id", noReqID, false}, - {"invalid UpdateDeviceRequest, Request Id is not an uuid", invalidReqID, true}, + {"valid UpdateDeviceRequest, no Request Id", noReqId, false}, + {"invalid UpdateDeviceRequest, Request Id is not an uuid", invalidReqId, true}, {"invalid UpdateDeviceRequest, invalid admin state", invalidAdminState, true}, {"invalid UpdateDeviceRequest, invalid operating state", invalidOperatingState, true}, {"invalid UpdateDeviceRequest, invalid autoEvent frequency", invalidFrequency, true}, diff --git a/v2/dtos/requests/deviceprofile_test.go b/v2/dtos/requests/deviceprofile_test.go index f9ff384c..2529a23d 100644 --- a/v2/dtos/requests/deviceprofile_test.go +++ b/v2/dtos/requests/deviceprofile_test.go @@ -51,7 +51,7 @@ var testCoreCommands = []dtos.Command{{ var testAddDeviceProfileReq = DeviceProfileRequest{ BaseRequest: common.BaseRequest{ - RequestID: ExampleUUID, + RequestId: ExampleUUID, }, Profile: dtos.DeviceProfile{ Name: TestDeviceProfileName, diff --git a/v2/dtos/requests/deviceservice_test.go b/v2/dtos/requests/deviceservice_test.go index a176a72e..de267604 100644 --- a/v2/dtos/requests/deviceservice_test.go +++ b/v2/dtos/requests/deviceservice_test.go @@ -20,7 +20,7 @@ import ( var testAddDeviceService = AddDeviceServiceRequest{ BaseRequest: common.BaseRequest{ - RequestID: ExampleUUID, + RequestId: ExampleUUID, }, Service: dtos.DeviceService{ Name: TestDeviceServiceName, @@ -33,7 +33,7 @@ var testAddDeviceService = AddDeviceServiceRequest{ var testUpdateDeviceService = UpdateDeviceServiceRequest{ BaseRequest: common.BaseRequest{ - RequestID: ExampleUUID, + RequestId: ExampleUUID, }, Service: mockDeviceServiceDTO(), } @@ -56,10 +56,10 @@ func mockDeviceServiceDTO() dtos.UpdateDeviceService { func TestAddDeviceServiceRequest_Validate(t *testing.T) { valid := testAddDeviceService - noReqID := testAddDeviceService - noReqID.RequestID = "" - invalidReqID := testAddDeviceService - invalidReqID.RequestID = "jfdw324" + noReqId := testAddDeviceService + noReqId.RequestId = "" + invalidReqId := testAddDeviceService + invalidReqId.RequestId = "jfdw324" noName := testAddDeviceService noName.Service.Name = "" noOperatingState := testAddDeviceService @@ -80,8 +80,8 @@ func TestAddDeviceServiceRequest_Validate(t *testing.T) { expectError bool }{ {"valid AddDeviceServiceRequest", valid, false}, - {"valid AddDeviceServiceRequest, no Request Id", noReqID, false}, - {"invalid AddDeviceServiceRequest, Request Id is not an uuid", invalidReqID, true}, + {"valid AddDeviceServiceRequest, no Request Id", noReqId, false}, + {"invalid AddDeviceServiceRequest, Request Id is not an uuid", invalidReqId, true}, {"invalid AddDeviceServiceRequest, no Name", noName, true}, {"invalid AddDeviceServiceRequest, no OperatingState", noOperatingState, true}, {"invalid AddDeviceServiceRequest, invalid OperatingState", invalidOperatingState, true}, @@ -179,10 +179,10 @@ func TestUpdateDeviceServiceRequest_Validate(t *testing.T) { validWithoutId.Service.Id = nil validWithoutName := valid validWithoutName.Service.Name = nil - noReqID := valid - noReqID.RequestID = "" - invalidReqID := valid - invalidReqID.RequestID = "2h022mc" + noReqId := valid + noReqId.RequestId = "" + invalidReqId := valid + invalidReqId.RequestId = "2h022mc" noIdAndName := valid noIdAndName.Service.Id = nil noIdAndName.Service.Name = nil @@ -199,8 +199,8 @@ func TestUpdateDeviceServiceRequest_Validate(t *testing.T) { {"valid UpdateDeviceServiceRequest", valid, false}, {"valid UpdateDeviceServiceRequest without Id", validWithoutId, false}, {"valid UpdateDeviceServiceRequest without name", validWithoutName, false}, - {"valid UpdateDeviceServiceRequest, no Request Id", noReqID, false}, - {"invalid UpdateDeviceServiceRequest, no Request Id", invalidReqID, true}, + {"valid UpdateDeviceServiceRequest, no Request Id", noReqId, false}, + {"invalid UpdateDeviceServiceRequest, no Request Id", invalidReqId, true}, {"invalid UpdateDeviceServiceRequest, no Id and Name", noIdAndName, true}, {"invalid UpdateDeviceServiceRequest, invalid OperatingState", invalidOperatingState, true}, {"invalid UpdateDeviceServiceRequest, invalid AdminState", invalidAdminState, true}, diff --git a/v2/dtos/requests/event.go b/v2/dtos/requests/event.go index 6a35af6e..888da60c 100644 --- a/v2/dtos/requests/event.go +++ b/v2/dtos/requests/event.go @@ -81,7 +81,7 @@ func AddEventReqToEventModels(addRequests []AddEventRequest) (events []models.Ev tags[tag] = value } - e.Id = a.Event.ID + e.Id = a.Event.Id e.DeviceName = a.Event.DeviceName e.Origin = a.Event.Origin e.Readings = readings diff --git a/v2/dtos/requests/event_test.go b/v2/dtos/requests/event_test.go index c3826bad..f5c5d045 100644 --- a/v2/dtos/requests/event_test.go +++ b/v2/dtos/requests/event_test.go @@ -20,10 +20,10 @@ import ( var testAddEvent = AddEventRequest{ BaseRequest: common.BaseRequest{ - RequestID: ExampleUUID, + RequestId: ExampleUUID, }, Event: dtos.Event{ - ID: ExampleUUID, + Id: ExampleUUID, DeviceName: TestDeviceName, Origin: TestOriginTime, Readings: []dtos.BaseReading{{ @@ -43,14 +43,14 @@ var testAddEvent = AddEventRequest{ func TestAddEventRequest_Validate(t *testing.T) { valid := testAddEvent - noReqID := testAddEvent - noReqID.RequestID = "" - invalidReqID := testAddEvent - invalidReqID.RequestID = "xxy" - noEventID := testAddEvent - noEventID.Event.ID = "" - invalidEventID := testAddEvent - invalidEventID.Event.ID = "gj93j2-v92hvi3h" + noReqId := testAddEvent + noReqId.RequestId = "" + invalidReqId := testAddEvent + invalidReqId.RequestId = "xxy" + noEventId := testAddEvent + noEventId.Event.Id = "" + invalidEventId := testAddEvent + invalidEventId.Event.Id = "gj93j2-v92hvi3h" noDeviceName := testAddEvent noDeviceName.Event.DeviceName = "" noOrigin := testAddEvent @@ -161,10 +161,10 @@ func TestAddEventRequest_Validate(t *testing.T) { expectError bool }{ {"valid AddEventRequest", valid, false}, - {"valid AddEventRequest, no Request Id", noReqID, false}, - {"invalid AddEventRequest, Request Id is not an uuid", invalidReqID, true}, - {"invalid AddEventRequest, no Event Id", noEventID, true}, - {"invalid AddEventRequest, Event Id is not an uuid", invalidEventID, true}, + {"valid AddEventRequest, no Request Id", noReqId, false}, + {"invalid AddEventRequest, Request Id is not an uuid", invalidReqId, true}, + {"invalid AddEventRequest, no Event Id", noEventId, true}, + {"invalid AddEventRequest, Event Id is not an uuid", invalidEventId, true}, {"invalid AddEventRequest, no DeviceName", noDeviceName, true}, {"invalid AddEventRequest, no Origin", noOrigin, true}, {"invalid AddEventRequest, no Reading", noReading, true}, diff --git a/v2/dtos/responses/device_test.go b/v2/dtos/responses/device_test.go index 70970313..984a6505 100644 --- a/v2/dtos/responses/device_test.go +++ b/v2/dtos/responses/device_test.go @@ -13,25 +13,25 @@ import ( ) func TestNewDeviceResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedDevice := dtos.Device{Name: "test device"} - actual := NewDeviceResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedDevice) + actual := NewDeviceResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedDevice) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedDevice, actual.Device) } func TestNewDeviceResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedDevice := dtos.Device{Name: "test device"} - actual := NewDeviceResponseNoMessage(expectedRequestID, expectedStatusCode, expectedDevice) + actual := NewDeviceResponseNoMessage(expectedRequestId, expectedStatusCode, expectedDevice) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedDevice, actual.Device) } diff --git a/v2/dtos/responses/deviceprofile_test.go b/v2/dtos/responses/deviceprofile_test.go index 562f7a1f..ce5534e9 100644 --- a/v2/dtos/responses/deviceprofile_test.go +++ b/v2/dtos/responses/deviceprofile_test.go @@ -13,25 +13,25 @@ import ( ) func TestNewDeviceProfileResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedDeviceProfile := dtos.DeviceProfile{Name: "test device profile"} - actual := NewDeviceProfileResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedDeviceProfile) + actual := NewDeviceProfileResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedDeviceProfile) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedDeviceProfile, actual.Profile) } func TestNewDeviceProfileResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedDeviceProfile := dtos.DeviceProfile{Name: "test device profile"} - actual := NewDeviceProfileResponseNoMessage(expectedRequestID, expectedStatusCode, expectedDeviceProfile) + actual := NewDeviceProfileResponseNoMessage(expectedRequestId, expectedStatusCode, expectedDeviceProfile) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedDeviceProfile, actual.Profile) } diff --git a/v2/dtos/responses/deviceservice_test.go b/v2/dtos/responses/deviceservice_test.go index 48a536b8..fefcd25d 100644 --- a/v2/dtos/responses/deviceservice_test.go +++ b/v2/dtos/responses/deviceservice_test.go @@ -13,25 +13,25 @@ import ( ) func TestNewDeviceServiceResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedDeviceService := dtos.DeviceService{Name: "test device service"} - actual := NewDeviceServiceResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedDeviceService) + actual := NewDeviceServiceResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedDeviceService) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedDeviceService, actual.Service) } func TestNewDeviceServiceResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedDeviceService := dtos.DeviceService{Name: "test device service"} - actual := NewDeviceServiceResponseNoMessage(expectedRequestID, expectedStatusCode, expectedDeviceService) + actual := NewDeviceServiceResponseNoMessage(expectedRequestId, expectedStatusCode, expectedDeviceService) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedDeviceService, actual.Service) } diff --git a/v2/dtos/responses/event.go b/v2/dtos/responses/event.go index d18dc7b3..93bb691d 100644 --- a/v2/dtos/responses/event.go +++ b/v2/dtos/responses/event.go @@ -16,7 +16,7 @@ import ( type EventCountResponse struct { common.BaseResponse `json:",inline"` Count uint32 - DeviceID string `json:"deviceId"` // ID uniquely identifies a device + DeviceId string `json:"deviceId"` // Id uniquely identifies a device } // EventResponse defines the Response Content for GET event DTOs. @@ -43,7 +43,7 @@ func NewEventCountResponse(requestId string, message string, statusCode int, cou return EventCountResponse{ BaseResponse: common.NewBaseResponse(requestId, message, statusCode), Count: count, - DeviceID: deviceId, + DeviceId: deviceId, } } diff --git a/v2/dtos/responses/event_test.go b/v2/dtos/responses/event_test.go index 8107bac1..bdd95426 100644 --- a/v2/dtos/responses/event_test.go +++ b/v2/dtos/responses/event_test.go @@ -14,77 +14,77 @@ import ( ) func TestNewEventCountResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedCount := uint32(1000) expectedDeviceId := "7a1707f0-166f-4c4b-bc9d-1d54c74e0137" - actual := NewEventCountResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedCount, expectedDeviceId) + actual := NewEventCountResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedCount, expectedDeviceId) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedCount, actual.Count) - assert.Equal(t, expectedDeviceId, actual.DeviceID) + assert.Equal(t, expectedDeviceId, actual.DeviceId) } func TestNewEventCountResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedCount := uint32(1000) expectedDeviceId := "7a1707f0-166f-4c4b-bc9d-1d54c74e0137" - actual := NewEventCountResponseNoMessage(expectedRequestID, expectedStatusCode, expectedCount, expectedDeviceId) + actual := NewEventCountResponseNoMessage(expectedRequestId, expectedStatusCode, expectedCount, expectedDeviceId) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedCount, actual.Count) - assert.Equal(t, expectedDeviceId, actual.DeviceID) + assert.Equal(t, expectedDeviceId, actual.DeviceId) } func TestNewEventResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" - expectedEvent := dtos.Event{ID: "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"} - actual := NewEventResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedEvent) + expectedEvent := dtos.Event{Id: "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"} + actual := NewEventResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedEvent) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedEvent, actual.Event) } func TestNewEventResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 - expectedEvent := dtos.Event{ID: "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"} - actual := NewEventResponseNoMessage(expectedRequestID, expectedStatusCode, expectedEvent) + expectedEvent := dtos.Event{Id: "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"} + actual := NewEventResponseNoMessage(expectedRequestId, expectedStatusCode, expectedEvent) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedEvent, actual.Event) } func TestNewUpdateEventPushedByChecksumResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedChecksum := "04698a6f20feecb8bbf7cd01e59d31ba1ce17b24ba14b71a8fb370065d951f57" - actual := NewUpdateEventPushedByChecksumResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedChecksum) + actual := NewUpdateEventPushedByChecksumResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedChecksum) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedChecksum, actual.Checksum) } func TestNewUpdateEventPushedByChecksumResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedChecksum := "04698a6f20feecb8bbf7cd01e59d31ba1ce17b24ba14b71a8fb370065d951f57" - actual := NewUpdateEventPushedByChecksumResponseNoMessage(expectedRequestID, expectedStatusCode, expectedChecksum) + actual := NewUpdateEventPushedByChecksumResponseNoMessage(expectedRequestId, expectedStatusCode, expectedChecksum) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedChecksum, actual.Checksum) } diff --git a/v2/dtos/responses/reading_test.go b/v2/dtos/responses/reading_test.go index a4fa048b..9d8df0e7 100644 --- a/v2/dtos/responses/reading_test.go +++ b/v2/dtos/responses/reading_test.go @@ -14,49 +14,49 @@ import ( ) func TestNewReadingCountResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedCount := uint32(1000) - actual := NewReadingCountResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedCount) + actual := NewReadingCountResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedCount) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedCount, actual.Count) } func TestNewReadingCountResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedCount := uint32(1000) - actual := NewReadingCountResponseNoMessage(expectedRequestID, expectedStatusCode, expectedCount) + actual := NewReadingCountResponseNoMessage(expectedRequestId, expectedStatusCode, expectedCount) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedCount, actual.Count) } func TestNewReadingResponse(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedMessage := "unit test message" expectedReading := dtos.BaseReading{Id: "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"} - actual := NewReadingResponse(expectedRequestID, expectedMessage, expectedStatusCode, expectedReading) + actual := NewReadingResponse(expectedRequestId, expectedMessage, expectedStatusCode, expectedReading) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedMessage, actual.Message) assert.Equal(t, expectedReading, actual.Reading) } func TestNewReadingResponseNoMessage(t *testing.T) { - expectedRequestID := "123456" + expectedRequestId := "123456" expectedStatusCode := 200 expectedReading := dtos.BaseReading{Id: "7a1707f0-166f-4c4b-bc9d-1d54c74e0137"} - actual := NewReadingResponseNoMessage(expectedRequestID, expectedStatusCode, expectedReading) + actual := NewReadingResponseNoMessage(expectedRequestId, expectedStatusCode, expectedReading) - assert.Equal(t, expectedRequestID, actual.RequestID) + assert.Equal(t, expectedRequestId, actual.RequestId) assert.Equal(t, expectedStatusCode, actual.StatusCode) assert.Equal(t, expectedReading, actual.Reading) } diff --git a/v2/models/device.go b/v2/models/device.go index 1fa3a3da..84afc56d 100644 --- a/v2/models/device.go +++ b/v2/models/device.go @@ -8,7 +8,7 @@ package models // Device represents a registered device participating within the EdgeX Foundry ecosystem type Device struct { Timestamps - Id string // ID uniquely identifies the device, a UUID for example + Id string // Id uniquely identifies the device, a UUID for example Name string // Unique name for identifying a device Description string // Description of the device AdminState AdminState // Admin state (locked/unlocked)