Skip to content

Commit

Permalink
feat: Remove created field from Event and Reading
Browse files Browse the repository at this point in the history
In March-18-2021 Core WG meeting, we decided to remove created field from Event and Reading

Close #553

Signed-off-by: weichou <weichou1229@gmail.com>
  • Loading branch information
weichou1229 committed Mar 25, 2021
1 parent f40a6c8 commit 9016fba
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 19 deletions.
1 change: 0 additions & 1 deletion v2/clients/http/deviceservicecommand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var testEventDTO = dtos.Event{
Id: TestUUID,
DeviceName: TestDeviceName,
ProfileName: TestDeviceProfileName,
Created: TestTimestamp,
Origin: TestTimestamp,
Tags: map[string]string{
"GatewayID": "Houston-0001",
Expand Down
2 changes: 0 additions & 2 deletions v2/dtos/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Event struct {
DeviceName string `json:"deviceName" validate:"required,edgex-dto-rfc3986-unreserved-chars"`
ProfileName string `json:"profileName" validate:"required,edgex-dto-rfc3986-unreserved-chars"`
SourceName string `json:"sourceName" validate:"required,edgex-dto-rfc3986-unreserved-chars"`
Created int64 `json:"created,omitempty"`
Origin int64 `json:"origin" validate:"required"`
Readings []BaseReading `json:"readings" validate:"gt=0,dive,required"`
Tags map[string]string `json:"tags,omitempty" xml:"-"` // Have to ignore since map not supported for XML
Expand Down Expand Up @@ -61,7 +60,6 @@ func FromEventModelToDTO(event models.Event) Event {
DeviceName: event.DeviceName,
ProfileName: event.ProfileName,
SourceName: event.SourceName,
Created: event.Created,
Origin: event.Origin,
Readings: readings,
Tags: tags,
Expand Down
7 changes: 1 addition & 6 deletions v2/dtos/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var valid = models.Event{
DeviceName: TestDeviceName,
ProfileName: TestDeviceProfileName,
SourceName: TestSourceName,
Created: TestTimestamp,
Origin: TestTimestamp,
Tags: map[string]string{
"GatewayID": "Houston-0001",
Expand All @@ -38,7 +37,6 @@ var expectedDTO = Event{
DeviceName: TestDeviceName,
ProfileName: TestDeviceProfileName,
SourceName: TestSourceName,
Created: TestTimestamp,
Origin: TestTimestamp,
Tags: map[string]string{
"GatewayID": "Houston-0001",
Expand All @@ -65,7 +63,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{
"<Event><ApiVersion>v2</ApiVersion><Id>7a1707f0-166f-4c4b-bc9d-1d54c74e0137</Id><DeviceName>TestDevice</DeviceName><ProfileName>TestDeviceProfileName</ProfileName><SourceName>TestSourceName</SourceName><Created>1594963842</Created><Origin>1594963842</Origin><Tags>",
"<Event><ApiVersion>v2</ApiVersion><Id>7a1707f0-166f-4c4b-bc9d-1d54c74e0137</Id><DeviceName>TestDevice</DeviceName><ProfileName>TestDeviceProfileName</ProfileName><SourceName>TestSourceName</SourceName><Origin>1594963842</Origin><Tags>",
"<GatewayID>Houston-0001</GatewayID>",
"<Latitude>29.630771</Latitude>",
"<Longitude>-95.377603</Longitude>",
Expand All @@ -91,7 +89,6 @@ func TestNewEvent(t *testing.T) {
assert.Equal(t, expectedProfileName, actual.ProfileName)
assert.Equal(t, expectedDeviceName, actual.DeviceName)
assert.Zero(t, len(actual.Readings))
assert.Zero(t, actual.Created)
assert.NotZero(t, actual.Origin)
}

Expand Down Expand Up @@ -126,7 +123,6 @@ func TestEvent_AddSimpleReading(t *testing.T) {
assert.Equal(t, expectedReadingDetails[index].resourceName, actual.ResourceName)
assert.Equal(t, expectedReadingDetails[index].valueType, actual.ValueType)
assert.Equal(t, expectedReadingDetails[index].value, actual.Value)
assert.Zero(t, actual.Created)
assert.NotZero(t, actual.Origin)
}
}
Expand All @@ -152,6 +148,5 @@ func TestEvent_AddBinaryReading(t *testing.T) {
assert.Equal(t, expectedResourceName, actual.ResourceName)
assert.Equal(t, expectedValueType, actual.ValueType)
assert.Equal(t, expectedValue, actual.BinaryValue)
assert.Zero(t, actual.Created)
assert.NotZero(t, actual.Origin)
}
3 changes: 0 additions & 3 deletions v2/dtos/reading.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
// https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/core-data/2.x#/BaseReading
type BaseReading struct {
Id string `json:"id,omitempty"`
Created int64 `json:"created,omitempty"`
Origin int64 `json:"origin" validate:"required"`
DeviceName string `json:"deviceName" validate:"required,edgex-dto-rfc3986-unreserved-chars"`
ResourceName string `json:"resourceName" validate:"required,edgex-dto-rfc3986-unreserved-chars"`
Expand Down Expand Up @@ -291,7 +290,6 @@ func FromReadingModelToDTO(reading models.Reading) BaseReading {
case models.BinaryReading:
baseReading = BaseReading{
Id: r.Id,
Created: r.Created,
Origin: r.Origin,
DeviceName: r.DeviceName,
ResourceName: r.ResourceName,
Expand All @@ -302,7 +300,6 @@ func FromReadingModelToDTO(reading models.Reading) BaseReading {
case models.SimpleReading:
baseReading = BaseReading{
Id: r.Id,
Created: r.Created,
Origin: r.Origin,
DeviceName: r.DeviceName,
ResourceName: r.ResourceName,
Expand Down
4 changes: 0 additions & 4 deletions v2/dtos/reading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestFromReadingModelToDTO(t *testing.T) {
valid := models.SimpleReading{
BaseReading: models.BaseReading{
Id: TestUUID,
Created: TestTimestamp,
Origin: TestTimestamp,
DeviceName: TestDeviceName,
ResourceName: TestReadingName,
Expand All @@ -68,7 +67,6 @@ func TestFromReadingModelToDTO(t *testing.T) {
}
expectedDTO := BaseReading{
Id: TestUUID,
Created: TestTimestamp,
Origin: TestTimestamp,
DeviceName: TestDeviceName,
ResourceName: TestReadingName,
Expand Down Expand Up @@ -141,7 +139,6 @@ func TestNewSimpleReading(t *testing.T) {
assert.Equal(t, expectedResourceName, actual.ResourceName)
assert.Equal(t, tt.expectedValueType, actual.ValueType)
assert.Equal(t, tt.expectedValue, actual.Value)
assert.Zero(t, actual.Created)
assert.NotZero(t, actual.Origin)
})
}
Expand Down Expand Up @@ -204,6 +201,5 @@ func TestNewBinaryReading(t *testing.T) {
assert.Equal(t, expectedResourceName, actual.ResourceName)
assert.Equal(t, expectedValueType, actual.ValueType)
assert.Equal(t, expectedBinaryValue, actual.BinaryValue)
assert.Zero(t, actual.Created)
assert.NotZero(t, actual.Origin)
}
1 change: 0 additions & 1 deletion v2/dtos/requests/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,5 @@ func TestNewAddEventRequest(t *testing.T) {
assert.Equal(t, expectedDeviceName, actual.Event.DeviceName)
assert.Equal(t, expectedSourceName, actual.Event.SourceName)
assert.NotZero(t, len(actual.Event.Readings))
assert.Zero(t, actual.Event.Created)
assert.NotZero(t, actual.Event.Origin)
}
1 change: 0 additions & 1 deletion v2/models/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Event struct {
DeviceName string
ProfileName string
SourceName string
Created int64
Origin int64
Readings []Reading
Tags map[string]string
Expand Down
1 change: 0 additions & 1 deletion v2/models/reading.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package models
// Model fields are same as the DTOs documented by this swagger. Exceptions, if any, are noted below.
type BaseReading struct {
Id string
Created int64
Origin int64
DeviceName string
ResourceName string
Expand Down

0 comments on commit 9016fba

Please sign in to comment.