Skip to content

Commit

Permalink
adjusting the unit test to make up for lost coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedMagdyCoretech committed Nov 26, 2024
1 parent b3f9e2c commit c083afa
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 2 deletions.
75 changes: 74 additions & 1 deletion usecases/cem/opev/public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,58 @@ func (s *CemOPEVSuite) Test_Public() {
_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

lc := s.evEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer)
assert.NotNil(s.T(), lc)

meas := s.evEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeMeasurement, model.RoleTypeServer)
assert.NotNil(s.T(), meas)

lData := &model.LoadControlLimitDescriptionListDataType{
LoadControlLimitDescriptionData: []model.LoadControlLimitDescriptionDataType{
{
LimitId: util.Ptr(model.LoadControlLimitIdType(0)),
LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation),
LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeOverloadProtection),
MeasurementId: util.Ptr(model.MeasurementIdType(0)),
},
},
}

_,errT := lc.UpdateData(true, model.FunctionTypeLoadControlLimitDescriptionListData, lData, nil, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

lData = &model.LoadControlLimitDescriptionListDataType{
LoadControlLimitDescriptionData: []model.LoadControlLimitDescriptionDataType{
{
LimitId: util.Ptr(model.LoadControlLimitIdType(1)),
LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation),
LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeOverloadProtection),
MeasurementId: util.Ptr(model.MeasurementIdType(1)),
},
{
LimitId: util.Ptr(model.LoadControlLimitIdType(2)),
LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation),
LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeOverloadProtection),
MeasurementId: util.Ptr(model.MeasurementIdType(2)),
},
},
}

_,errT = lc.UpdateData(true, model.FunctionTypeLoadControlLimitDescriptionListData, lData, &model.FilterType{}, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

mData := &model.MeasurementDescriptionListDataType{
MeasurementDescriptionData: []model.MeasurementDescriptionDataType{
{
Expand All @@ -30,7 +79,31 @@ func (s *CemOPEVSuite) Test_Public() {
},
},
}
_, errT := meas.UpdateData(true, model.FunctionTypeMeasurementDescriptionListData, mData, nil, nil)
_, errT = meas.UpdateData(true, model.FunctionTypeMeasurementDescriptionListData, mData, nil, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

mData = &model.MeasurementDescriptionListDataType{
MeasurementDescriptionData: []model.MeasurementDescriptionDataType{
{
MeasurementId: util.Ptr(model.MeasurementIdType(1)),
MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent),
CommodityType: util.Ptr(model.CommodityTypeTypeElectricity),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent),
},
{
MeasurementId: util.Ptr(model.MeasurementIdType(2)),
MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent),
CommodityType: util.Ptr(model.CommodityTypeTypeElectricity),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent),
},
},
}
_, errT = meas.UpdateData(true, model.FunctionTypeMeasurementDescriptionListData, mData, &model.FilterType{}, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
Expand Down
75 changes: 74 additions & 1 deletion usecases/cem/oscev/public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,58 @@ func (s *CemOSCEVSuite) Test_Public() {
_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

lc := s.evEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer)
assert.NotNil(s.T(), lc)

meas := s.evEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeMeasurement, model.RoleTypeServer)
assert.NotNil(s.T(), meas)

lData := &model.LoadControlLimitDescriptionListDataType{
LoadControlLimitDescriptionData: []model.LoadControlLimitDescriptionDataType{
{
LimitId: util.Ptr(model.LoadControlLimitIdType(0)),
LimitCategory: util.Ptr(model.LoadControlCategoryTypeRecommendation),
LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeSelfConsumption),
MeasurementId: util.Ptr(model.MeasurementIdType(0)),
},
},
}

_,errT := lc.UpdateData(true, model.FunctionTypeLoadControlLimitDescriptionListData, lData, nil, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

lData = &model.LoadControlLimitDescriptionListDataType{
LoadControlLimitDescriptionData: []model.LoadControlLimitDescriptionDataType{
{
LimitId: util.Ptr(model.LoadControlLimitIdType(1)),
LimitCategory: util.Ptr(model.LoadControlCategoryTypeRecommendation),
LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeSelfConsumption),
MeasurementId: util.Ptr(model.MeasurementIdType(1)),
},
{
LimitId: util.Ptr(model.LoadControlLimitIdType(2)),
LimitCategory: util.Ptr(model.LoadControlCategoryTypeRecommendation),
LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeSelfConsumption),
MeasurementId: util.Ptr(model.MeasurementIdType(2)),
},
},
}

_,errT = lc.UpdateData(true, model.FunctionTypeLoadControlLimitDescriptionListData, lData, &model.FilterType{}, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

mData := &model.MeasurementDescriptionListDataType{
MeasurementDescriptionData: []model.MeasurementDescriptionDataType{
{
Expand All @@ -30,7 +79,31 @@ func (s *CemOSCEVSuite) Test_Public() {
},
},
}
_, errT := meas.UpdateData(true, model.FunctionTypeMeasurementDescriptionListData, mData, nil, nil)
_, errT = meas.UpdateData(true, model.FunctionTypeMeasurementDescriptionListData, mData, nil, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
assert.NotNil(s.T(), err)

mData = &model.MeasurementDescriptionListDataType{
MeasurementDescriptionData: []model.MeasurementDescriptionDataType{
{
MeasurementId: util.Ptr(model.MeasurementIdType(1)),
MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent),
CommodityType: util.Ptr(model.CommodityTypeTypeElectricity),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent),
},
{
MeasurementId: util.Ptr(model.MeasurementIdType(2)),
MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent),
CommodityType: util.Ptr(model.CommodityTypeTypeElectricity),
Unit: util.Ptr(model.UnitOfMeasurementTypeA),
ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent),
},
},
}
_, errT = meas.UpdateData(true, model.FunctionTypeMeasurementDescriptionListData, mData, &model.FilterType{}, nil)
assert.Nil(s.T(), errT)

_, _, _, err = s.sut.CurrentLimits(s.evEntity)
Expand Down

0 comments on commit c083afa

Please sign in to comment.