-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from weichou1229/issue-528
fix: Check empty value when converting Model to UpdateDTO
- Loading branch information
Showing
8 changed files
with
171 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package dtos | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2" | ||
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2/models" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFromDeviceModelToUpdateDTO(t *testing.T) { | ||
model := models.Device{} | ||
dto := FromDeviceModelToUpdateDTO(model) | ||
assert.Equal(t, v2.ApiVersion, dto.ApiVersion) | ||
assert.Nil(t, dto.Id) | ||
assert.Nil(t, dto.Name) | ||
assert.Nil(t, dto.Description) | ||
assert.Nil(t, dto.AdminState) | ||
assert.Nil(t, dto.OperatingState) | ||
assert.Nil(t, dto.LastConnected) | ||
assert.Nil(t, dto.LastReported) | ||
assert.Nil(t, dto.ServiceName) | ||
assert.Nil(t, dto.ProfileName) | ||
assert.Nil(t, dto.Location) | ||
assert.Nil(t, dto.AutoEvents) | ||
assert.Nil(t, dto.Protocols) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package dtos | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2" | ||
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2/models" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFromDeviceServiceModelToUpdateDTO(t *testing.T) { | ||
model := models.DeviceService{} | ||
dto := FromDeviceServiceModelToUpdateDTO(model) | ||
assert.Equal(t, v2.ApiVersion, dto.ApiVersion) | ||
assert.Nil(t, dto.Id) | ||
assert.Nil(t, dto.Name) | ||
assert.Nil(t, dto.Labels) | ||
assert.Nil(t, dto.BaseAddress) | ||
assert.Nil(t, dto.AdminState) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Copyright (C) 2021 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package dtos | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2" | ||
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2/models" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFromProvisionWatcherModelToUpdateDTO(t *testing.T) { | ||
model := models.ProvisionWatcher{} | ||
dto := FromProvisionWatcherModelToUpdateDTO(model) | ||
assert.Equal(t, v2.ApiVersion, dto.ApiVersion) | ||
assert.Nil(t, dto.Id) | ||
assert.Nil(t, dto.Name) | ||
assert.Nil(t, dto.Labels) | ||
assert.Nil(t, dto.Identifiers) | ||
assert.Nil(t, dto.BlockingIdentifiers) | ||
assert.Nil(t, dto.ProfileName) | ||
assert.Nil(t, dto.ServiceName) | ||
assert.Nil(t, dto.AdminState) | ||
assert.Nil(t, dto.AutoEvents) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters