From b6672042ff04832305bfe57ab7089e2014c5c3a7 Mon Sep 17 00:00:00 2001 From: Lindsey Cheng Date: Wed, 15 Nov 2023 18:06:52 +0800 Subject: [PATCH] Update ConvertToDTO method to public to fix linter errors Signed-off-by: Lindsey Cheng --- central/xlsx/device.go | 4 ++-- central/xlsx/device_test.go | 2 +- central/xlsx/deviceprofile.go | 4 ++-- central/xlsx/deviceprofile_test.go | 4 ++-- central/xlsx/interface.go | 2 +- central/xlsx/transform.go | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/central/xlsx/device.go b/central/xlsx/device.go index 7e16bc2a..c29f1fcd 100644 --- a/central/xlsx/device.go +++ b/central/xlsx/device.go @@ -53,8 +53,8 @@ func newDeviceXlsx(file io.Reader) (Converter[[]*dtos.Device], error) { }, nil } -// convertToDTO parses the Devices sheet and convert the rows to Device DTOs -func (deviceXlsx *deviceXlsx) convertToDTO() error { +// ConvertToDTO parses the Devices sheet and convert the rows to Device DTOs +func (deviceXlsx *deviceXlsx) ConvertToDTO() error { allSheetNames := deviceXlsx.xlsFile.GetSheetList() err := checkRequiredSheets(allSheetNames, requiredSheets) diff --git a/central/xlsx/device_test.go b/central/xlsx/device_test.go index 8fde81a4..09302e39 100644 --- a/central/xlsx/device_test.go +++ b/central/xlsx/device_test.go @@ -146,7 +146,7 @@ func Test_convertToDTO(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, deviceX) - err = deviceX.convertToDTO() + err = deviceX.ConvertToDTO() require.NoError(t, err) devices := deviceX.GetDTOs() diff --git a/central/xlsx/deviceprofile.go b/central/xlsx/deviceprofile.go index c68bfa3e..3fcc33de 100644 --- a/central/xlsx/deviceprofile.go +++ b/central/xlsx/deviceprofile.go @@ -51,8 +51,8 @@ func newDeviceProfileXlsx(file io.Reader) (Converter[*dtos.DeviceProfile], error }, nil } -// convertToDTO parses the Devices sheet and convert the rows to Device DTOs -func (dpXlsx *deviceProfileXlsx) convertToDTO() error { +// ConvertToDTO parses the DeviceInfo/DeviceResource/DeviceCommand sheets and convert the rows to DeviceProfile DTO +func (dpXlsx *deviceProfileXlsx) ConvertToDTO() error { allSheetNames := dpXlsx.xlsFile.GetSheetList() err := checkRequiredSheets(allSheetNames, requiredProfileSheets) diff --git a/central/xlsx/deviceprofile_test.go b/central/xlsx/deviceprofile_test.go index 3dac9387..1871934d 100644 --- a/central/xlsx/deviceprofile_test.go +++ b/central/xlsx/deviceprofile_test.go @@ -123,7 +123,7 @@ func Test_DeviceProfile_convertToDTO_InvalidSheets(t *testing.T) { require.NoError(t, err) defer dpX.(*deviceProfileXlsx).xlsFile.Close() - err = dpX.convertToDTO() + err = dpX.ConvertToDTO() require.Error(t, err, "Expected required worksheet not defined error not occurred") } @@ -153,7 +153,7 @@ func Test_deviceProfileXlsx_convertToDTO(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, dpX) - err = dpX.convertToDTO() + err = dpX.ConvertToDTO() require.NoError(t, err) deviceProfile := dpX.GetDTOs() diff --git a/central/xlsx/interface.go b/central/xlsx/interface.go index 728b4582..c3f6eb95 100644 --- a/central/xlsx/interface.go +++ b/central/xlsx/interface.go @@ -13,7 +13,7 @@ type AllowedDTOTypes interface { type Converter[T AllowedDTOTypes] interface { // ConvertToDTO parses the xlsx file content to DTOs - convertToDTO() error + ConvertToDTO() error // GetDTOs returns the coverted DTOs GetDTOs() T // GetValidateErrors returns the deviceName-validationError key-value map while parsing the excel data rows to DTOs diff --git a/central/xlsx/transform.go b/central/xlsx/transform.go index 54237e2c..971c447c 100644 --- a/central/xlsx/transform.go +++ b/central/xlsx/transform.go @@ -22,7 +22,7 @@ func ConvertDeviceXlsx(file io.Reader) (Converter[[]*dtos.Device], error) { return nil, fmt.Errorf("failed to create deviceXlsx instance: %w", err) } - err = deviceX.convertToDTO() + err = deviceX.ConvertToDTO() if err != nil { return nil, err } @@ -36,7 +36,7 @@ func ConvertDeviceProfileXlsx(file io.Reader) (Converter[*dtos.DeviceProfile], e return nil, fmt.Errorf("failed to create deviceProfileXlsx instance: %w", err) } - err = deviceProfileX.convertToDTO() + err = deviceProfileX.ConvertToDTO() if err != nil { return nil, err }