diff --git a/model/electricalconnection.go b/model/electricalconnection.go index 95be03e..4cb265b 100644 --- a/model/electricalconnection.go +++ b/model/electricalconnection.go @@ -4,7 +4,7 @@ type ElectricalConnectionIdType uint type ElectricalConnectionParameterIdType uint -type ElectricalConnectionCharaceteristicsIdType uint +type ElectricalConnectionCharaceteristicIdType uint type ElectricalConnectionMeasurandVariantType string @@ -211,7 +211,7 @@ type ElectricalConnectionDescriptionListDataSelectorsType struct { type ElectricalConnectionCharacteristicDataType struct { ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty" eebus:"key"` ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty" eebus:"key"` - CharacteristicId *ElectricalConnectionCharaceteristicsIdType `json:"characteristicId,omitempty" eebus:"key"` + CharacteristicId *ElectricalConnectionCharaceteristicIdType `json:"characteristicId,omitempty" eebus:"key"` CharacteristicContext *ElectricalConnectionCharacteristicContextType `json:"characteristicContext,omitempty"` CharacteristicType *ElectricalConnectionCharacteristicTypeType `json:"characteristicType,omitempty"` Value *ScaledNumberType `json:"value,omitempty"` @@ -235,7 +235,7 @@ type ElectricalConnectionCharacteristicListDataType struct { type ElectricalConnectionCharacteristicListDataSelectorsType struct { ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty"` ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty"` - CharacteristicId *ElectricalConnectionCharaceteristicsIdType `json:"characteristicId,omitempty"` + CharacteristicId *ElectricalConnectionCharaceteristicIdType `json:"characteristicId,omitempty"` CharacteristicContext *ElectricalConnectionCharacteristicContextType `json:"characteristicContext,omitempty"` CharacteristicType *ElectricalConnectionCharacteristicTypeType `json:"characteristicType,omitempty"` } diff --git a/model/electricalconnection_additions_test.go b/model/electricalconnection_additions_test.go index 667dc94..fa3ee61 100644 --- a/model/electricalconnection_additions_test.go +++ b/model/electricalconnection_additions_test.go @@ -1145,6 +1145,50 @@ func TestElectricalConnectionDescriptionListDataType_Update(t *testing.T) { assert.Equal(t, ElectricalConnectionVoltageTypeTypeDc, *item2.PowerSupplyType) } +func TestElectricalConnectionCharacteristicListDataType_Update(t *testing.T) { + sut := ElectricalConnectionCharacteristicListDataType{ + ElectricalConnectionCharacteristicListData: []ElectricalConnectionCharacteristicDataType{ + { + ElectricalConnectionId: util.Ptr(ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(ElectricalConnectionParameterIdType(0)), + CharacteristicId: util.Ptr(ElectricalConnectionCharaceteristicIdType(0)), + CharacteristicType: util.Ptr(ElectricalConnectionCharacteristicTypeTypeApparentPowerConsumptionNominalMax), + }, + { + ElectricalConnectionId: util.Ptr(ElectricalConnectionIdType(1)), + ParameterId: util.Ptr(ElectricalConnectionParameterIdType(0)), + CharacteristicId: util.Ptr(ElectricalConnectionCharaceteristicIdType(1)), + CharacteristicType: util.Ptr(ElectricalConnectionCharacteristicTypeTypePowerConsumptionMax), + }, + }, + } + + newData := ElectricalConnectionCharacteristicListDataType{ + ElectricalConnectionCharacteristicListData: []ElectricalConnectionCharacteristicDataType{ + { + ElectricalConnectionId: util.Ptr(ElectricalConnectionIdType(1)), + ParameterId: util.Ptr(ElectricalConnectionParameterIdType(0)), + CharacteristicId: util.Ptr(ElectricalConnectionCharaceteristicIdType(1)), + CharacteristicType: util.Ptr(ElectricalConnectionCharacteristicTypeTypeEnergyCapacityNominalMax), + }, + }, + } + + // Act + sut.UpdateList(&newData, NewFilterTypePartial(), nil) + + data := sut.ElectricalConnectionCharacteristicListData + // check the non changing items + assert.Equal(t, 2, len(data)) + item1 := data[0] + assert.Equal(t, 0, int(*item1.ElectricalConnectionId)) + assert.Equal(t, ElectricalConnectionCharacteristicTypeTypeApparentPowerConsumptionNominalMax, *item1.CharacteristicType) + // check properties of updated item + item2 := data[1] + assert.Equal(t, 1, int(*item2.ElectricalConnectionId)) + assert.Equal(t, ElectricalConnectionCharacteristicTypeTypeEnergyCapacityNominalMax, *item2.CharacteristicType) +} + func TestElectricalConnectionParameterDescriptionListDataType_Update(t *testing.T) { sut := ElectricalConnectionParameterDescriptionListDataType{ ElectricalConnectionParameterDescriptionData: []ElectricalConnectionParameterDescriptionDataType{ diff --git a/model/identification_additions_test.go b/model/identification_additions_test.go index e846b64..7f2f341 100644 --- a/model/identification_additions_test.go +++ b/model/identification_additions_test.go @@ -44,3 +44,88 @@ func TestIdentificationListDataType_Update(t *testing.T) { assert.Equal(t, 1, int(*item2.IdentificationId)) assert.Equal(t, IdentificationTypeTypeEui64, *item2.IdentificationType) } + +func TestSessionIdentificationListDataType_Update(t *testing.T) { + sut := SessionIdentificationListDataType{ + SessionIdentificationData: []SessionIdentificationDataType{ + { + IdentificationId: util.Ptr(IdentificationIdType(0)), + SessionId: util.Ptr(SessionIdType(1)), + IsLatestSession: util.Ptr(false), + }, + { + IdentificationId: util.Ptr(IdentificationIdType(1)), + SessionId: util.Ptr(SessionIdType(2)), + IsLatestSession: util.Ptr(true), + }, + }, + } + + newData := SessionIdentificationListDataType{ + SessionIdentificationData: []SessionIdentificationDataType{ + { + IdentificationId: util.Ptr(IdentificationIdType(1)), + SessionId: util.Ptr(SessionIdType(2)), + IsLatestSession: util.Ptr(false), + }, + }, + } + + // Act + sut.UpdateList(&newData, NewFilterTypePartial(), nil) + + data := sut.SessionIdentificationData + // check the non changing items + assert.Equal(t, 2, len(data)) + item1 := data[0] + assert.Equal(t, 0, int(*item1.IdentificationId)) + assert.Equal(t, false, *item1.IsLatestSession) + // check properties of updated item + item2 := data[1] + assert.Equal(t, 1, int(*item2.IdentificationId)) + assert.Equal(t, false, *item2.IsLatestSession) +} + +func TestSessionMeasurementRelationListDataType_Update(t *testing.T) { + sut := SessionMeasurementRelationListDataType{ + SessionMeasurementRelationData: []SessionMeasurementRelationDataType{ + { + SessionId: util.Ptr(SessionIdType(0)), + MeasurementId: []MeasurementIdType{ + 0, 1, + }, + }, + { + SessionId: util.Ptr(SessionIdType(1)), + MeasurementId: []MeasurementIdType{ + 2, 3, + }, + }, + }, + } + + newData := SessionMeasurementRelationListDataType{ + SessionMeasurementRelationData: []SessionMeasurementRelationDataType{ + { + SessionId: util.Ptr(SessionIdType(1)), + MeasurementId: []MeasurementIdType{ + 2, 3, 4, + }, + }, + }, + } + + // Act + sut.UpdateList(&newData, NewFilterTypePartial(), nil) + + data := sut.SessionMeasurementRelationData + // check the non changing items + assert.Equal(t, 2, len(data)) + item1 := data[0] + assert.Equal(t, 0, int(*item1.SessionId)) + assert.Equal(t, []MeasurementIdType{0, 1}, item1.MeasurementId) + // check properties of updated item + item2 := data[1] + assert.Equal(t, 1, int(*item2.SessionId)) + assert.Equal(t, []MeasurementIdType{2, 3, 4}, item2.MeasurementId) +} diff --git a/model/measurement.go b/model/measurement.go index c41e57e..f018a7e 100644 --- a/model/measurement.go +++ b/model/measurement.go @@ -54,8 +54,8 @@ type MeasurementValueTypeType string const ( MeasurementValueTypeTypeValue MeasurementValueTypeType = "value" MeasurementValueTypeTypeAverageValue MeasurementValueTypeType = "averageValue" - MeasurementValueTypeTypeMinvValue MeasurementValueTypeType = "minValue" - MeasurementValueTypeTypeMaxvVlue MeasurementValueTypeType = "maxValue" + MeasurementValueTypeTypeMinValue MeasurementValueTypeType = "minValue" + MeasurementValueTypeTypeMaxValue MeasurementValueTypeType = "maxValue" MeasurementValueTypeTypeStandardDeviation MeasurementValueTypeType = "standardDeviation" ) diff --git a/model/measurement_additions_test.go b/model/measurement_additions_test.go index 32ba2df..1d33b92 100644 --- a/model/measurement_additions_test.go +++ b/model/measurement_additions_test.go @@ -92,6 +92,47 @@ func TestMeasurementListDataType_Update_Replace(t *testing.T) { assert.Equal(t, 10.0, item2.Value.GetValue()) } +func TestMeasurementSeriesListDataType_Update(t *testing.T) { + sut := MeasurementSeriesListDataType{ + MeasurementSeriesData: []MeasurementSeriesDataType{ + { + MeasurementId: util.Ptr(MeasurementIdType(0)), + ValueType: util.Ptr(MeasurementValueTypeTypeMinValue), + Value: NewScaledNumberType(1), + }, + { + MeasurementId: util.Ptr(MeasurementIdType(1)), + ValueType: util.Ptr(MeasurementValueTypeTypeMaxValue), + Value: NewScaledNumberType(10), + }, + }, + } + + newData := MeasurementSeriesListDataType{ + MeasurementSeriesData: []MeasurementSeriesDataType{ + { + MeasurementId: util.Ptr(MeasurementIdType(1)), + ValueType: util.Ptr(MeasurementValueTypeTypeMaxValue), + Value: NewScaledNumberType(100), + }, + }, + } + + // Act + sut.UpdateList(&newData, NewFilterTypePartial(), nil) + + data := sut.MeasurementSeriesData + // check the non changing items + assert.Equal(t, 2, len(data)) + item1 := data[0] + assert.Equal(t, 0, int(*item1.MeasurementId)) + assert.Equal(t, 1.0, item1.Value.GetValue()) + // check properties of updated item + item2 := data[1] + assert.Equal(t, 1, int(*item2.MeasurementId)) + assert.Equal(t, 100.0, item2.Value.GetValue()) +} + func TestMeasurementConstraintsListDataType_Update(t *testing.T) { sut := MeasurementConstraintsListDataType{ MeasurementConstraintsData: []MeasurementConstraintsDataType{ diff --git a/model/sensing_additions.go b/model/sensing_additions.go deleted file mode 100644 index b79094d..0000000 --- a/model/sensing_additions.go +++ /dev/null @@ -1,14 +0,0 @@ -package model - -// SensingListDataType - -var _ Updater = (*SensingListDataType)(nil) - -func (r *SensingListDataType) UpdateList(newList any, filterPartial, filterDelete *FilterType) { - var newData []SensingDataType - if newList != nil { - newData = newList.(*SensingListDataType).SensingData - } - - r.SensingData = UpdateList(r.SensingData, newData, filterPartial, filterDelete) -} diff --git a/model/stateinformation_additions_test.go b/model/stateinformation_additions_test.go new file mode 100644 index 0000000..335c5d8 --- /dev/null +++ b/model/stateinformation_additions_test.go @@ -0,0 +1,46 @@ +package model + +import ( + "testing" + + "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" +) + +func TestStateInformationListDataType_Update(t *testing.T) { + sut := StateInformationListDataType{ + StateInformationData: []StateInformationDataType{ + { + StateInformationId: util.Ptr(StateInformationIdType(0)), + IsActive: util.Ptr(true), + }, + { + StateInformationId: util.Ptr(StateInformationIdType(1)), + IsActive: util.Ptr(false), + }, + }, + } + + newData := StateInformationListDataType{ + StateInformationData: []StateInformationDataType{ + { + StateInformationId: util.Ptr(StateInformationIdType(1)), + IsActive: util.Ptr(true), + }, + }, + } + + // Act + sut.UpdateList(&newData, NewFilterTypePartial(), nil) + + data := sut.StateInformationData + // check the non changing items + assert.Equal(t, 2, len(data)) + item1 := data[0] + assert.Equal(t, 0, int(*item1.StateInformationId)) + assert.Equal(t, true, *item1.IsActive) + // check properties of updated item + item2 := data[1] + assert.Equal(t, 1, int(*item2.StateInformationId)) + assert.Equal(t, true, *item2.IsActive) +}