@@ -29,23 +29,23 @@ func (suite *OcppV2TestSuite) TestGetCompositeScheduleRequestValidation() {
2929
3030func (suite * OcppV2TestSuite ) TestGetCompositeScheduleConfirmationValidation () {
3131 t := suite .T ()
32- chargingSchedule := types .NewChargingSchedule (1 , types .ChargingRateUnitWatts , types .NewChargingSchedulePeriod (0 , 10.0 ))
33- chargingSchedule .Duration = newInt (600 )
34- chargingSchedule .MinChargingRate = newFloat (6.0 )
35- chargingSchedule .StartSchedule = types .NewDateTime (time .Now ())
32+ chargingSchedulePeriod := types .NewChargingSchedulePeriod (0 , 10.0 )
3633 compositeSchedule := smartcharging.CompositeSchedule {
37- StartDateTime : types .NewDateTime (time .Now ()),
38- ChargingSchedule : chargingSchedule ,
34+ EvseId : 1 ,
35+ Duration : 600 ,
36+ ScheduleStart : types .NewDateTime (time .Now ()),
37+ ChargingRateUnit : types .ChargingRateUnitWatts ,
38+ ChargingSchedulePeriod : []types.ChargingSchedulePeriod {chargingSchedulePeriod },
3939 }
4040 var confirmationTable = []GenericTestEntry {
4141 {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("reasoncode" , "" ), Schedule : & compositeSchedule }, true },
42- {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("reasoncode" , "" ), Schedule : & smartcharging.CompositeSchedule {}}, true },
4342 {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("reasoncode" , "" )}, true },
4443 {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted }, true },
4544 {smartcharging.GetCompositeScheduleResponse {}, false },
4645 {smartcharging.GetCompositeScheduleResponse {Status : "invalidGetCompositeScheduleStatus" }, false },
4746 {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("invalidreasoncodeasitslongerthan20" , "" )}, false },
48- {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("" , "" ), Schedule : & smartcharging.CompositeSchedule {StartDateTime : types .NewDateTime (time .Now ()), ChargingSchedule : types .NewChargingSchedule (1 , "invalidChargingRateUnit" )}}, false },
47+ {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("" , "" ), Schedule : & smartcharging.CompositeSchedule {EvseId : 1 , Duration : 600 , ScheduleStart : types .NewDateTime (time .Now ()), ChargingRateUnit : "invalidChargingRateUnit" , ChargingSchedulePeriod : []types.ChargingSchedulePeriod {chargingSchedulePeriod }}}, false },
48+ {smartcharging.GetCompositeScheduleResponse {Status : smartcharging .GetCompositeScheduleStatusAccepted , StatusInfo : types .NewStatusInfo ("" , "" ), Schedule : & smartcharging.CompositeSchedule {EvseId : 1 , Duration : 600 , ScheduleStart : types .NewDateTime (time .Now ()), ChargingRateUnit : types .ChargingRateUnitWatts , ChargingSchedulePeriod : []types.ChargingSchedulePeriod {}}}, false },
4949 }
5050 ExecuteGenericTestTable (t , confirmationTable )
5151}
@@ -62,17 +62,20 @@ func (suite *OcppV2TestSuite) TestGetCompositeScheduleE2EMocked() {
6262 scheduleStart := types .NewDateTime (time .Now ())
6363 chargingSchedulePeriod := types .NewChargingSchedulePeriod (0 , 10.0 )
6464 chargingSchedulePeriod .NumberPhases = newInt (3 )
65- chargingSchedule := types .NewChargingSchedule (1 , chargingRateUnit , chargingSchedulePeriod )
66- chargingSchedule .Duration = newInt (600 )
67- chargingSchedule .StartSchedule = types .NewDateTime (time .Now ())
68- chargingSchedule .MinChargingRate = newFloat (6.0 )
6965 statusInfo := types .NewStatusInfo ("reasonCode" , "" )
70- compositeSchedule := smartcharging.CompositeSchedule {StartDateTime : scheduleStart , ChargingSchedule : chargingSchedule }
66+ compositeSchedule := smartcharging.CompositeSchedule {
67+ EvseId : evseID ,
68+ Duration : duration ,
69+ ScheduleStart : scheduleStart ,
70+ ChargingRateUnit : chargingRateUnit ,
71+ ChargingSchedulePeriod : []types.ChargingSchedulePeriod {chargingSchedulePeriod },
72+ }
7173 requestJson := fmt .Sprintf (`[2,"%v","%v",{"duration":%v,"chargingRateUnit":"%v","evseId":%v}]` ,
7274 messageId , smartcharging .GetCompositeScheduleFeatureName , duration , chargingRateUnit , evseID )
73- responseJson := fmt .Sprintf (`[3,"%v",{"status":"%v","statusInfo":{"reasonCode":"%v"},"schedule":{"startDateTime":"%v","chargingSchedule":{"id": %v,"startSchedule ":"%v","duration":%v," chargingRateUnit":"%v","minChargingRate":%v," chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v,"numberPhases":%v}]} }}]` ,
74- messageId , status , statusInfo .ReasonCode , compositeSchedule . StartDateTime . FormatTimestamp (), chargingSchedule . ID , chargingSchedule . StartSchedule .FormatTimestamp (), * chargingSchedule . Duration , chargingSchedule . ChargingRateUnit , * chargingSchedule . MinChargingRate , chargingSchedulePeriod .StartPeriod , chargingSchedulePeriod .Limit , * chargingSchedulePeriod .NumberPhases )
75+ responseJson := fmt .Sprintf (`[3,"%v",{"status":"%v","statusInfo":{"reasonCode":"%v"},"schedule":{"evseId":%v,"duration": %v,"scheduleStart ":"%v","chargingRateUnit":"%v","chargingSchedulePeriod":[{"startPeriod":%v,"limit":%v,"numberPhases":%v}]}}]` ,
76+ messageId , status , statusInfo .ReasonCode , evseID , duration , compositeSchedule . ScheduleStart .FormatTimestamp (), chargingRateUnit , chargingSchedulePeriod .StartPeriod , chargingSchedulePeriod .Limit , * chargingSchedulePeriod .NumberPhases )
7577 getCompositeScheduleConfirmation := smartcharging .NewGetCompositeScheduleResponse (status )
78+ getCompositeScheduleConfirmation .StatusInfo = statusInfo
7679 getCompositeScheduleConfirmation .Schedule = & compositeSchedule
7780 channel := NewMockWebSocket (wsId )
7881
@@ -98,22 +101,16 @@ func (suite *OcppV2TestSuite) TestGetCompositeScheduleE2EMocked() {
98101 assert .Equal (t , status , confirmation .Status )
99102 assert .Equal (t , statusInfo .ReasonCode , confirmation .StatusInfo .ReasonCode )
100103 require .NotNil (t , confirmation .Schedule )
101- require .NotNil (t , confirmation .Schedule .StartDateTime )
102- assert .Equal (t , compositeSchedule .StartDateTime .FormatTimestamp (), confirmation .Schedule .StartDateTime .FormatTimestamp ())
103- require .NotNil (t , confirmation .Schedule .ChargingSchedule )
104- assert .Equal (t , chargingSchedule .ID , confirmation .Schedule .ChargingSchedule .ID )
105- assert .Equal (t , chargingSchedule .ChargingRateUnit , confirmation .Schedule .ChargingSchedule .ChargingRateUnit )
106- require .NotNil (t , confirmation .Schedule .ChargingSchedule .Duration )
107- assert .Equal (t , * chargingSchedule .Duration , * confirmation .Schedule .ChargingSchedule .Duration )
108- require .NotNil (t , confirmation .Schedule .ChargingSchedule .MinChargingRate )
109- assert .Equal (t , * chargingSchedule .MinChargingRate , * confirmation .Schedule .ChargingSchedule .MinChargingRate )
110- require .NotNil (t , confirmation .Schedule .ChargingSchedule .StartSchedule )
111- assert .Equal (t , chargingSchedule .StartSchedule .FormatTimestamp (), confirmation .Schedule .ChargingSchedule .StartSchedule .FormatTimestamp ())
112- require .Len (t , confirmation .Schedule .ChargingSchedule .ChargingSchedulePeriod , len (chargingSchedule .ChargingSchedulePeriod ))
113- assert .Equal (t , chargingSchedule .ChargingSchedulePeriod [0 ].Limit , confirmation .Schedule .ChargingSchedule .ChargingSchedulePeriod [0 ].Limit )
114- assert .Equal (t , chargingSchedule .ChargingSchedulePeriod [0 ].StartPeriod , confirmation .Schedule .ChargingSchedule .ChargingSchedulePeriod [0 ].StartPeriod )
115- require .NotNil (t , confirmation .Schedule .ChargingSchedule .ChargingSchedulePeriod [0 ].NumberPhases )
116- assert .Equal (t , * chargingSchedule .ChargingSchedulePeriod [0 ].NumberPhases , * confirmation .Schedule .ChargingSchedule .ChargingSchedulePeriod [0 ].NumberPhases )
104+ assert .Equal (t , evseID , confirmation .Schedule .EvseId )
105+ assert .Equal (t , duration , confirmation .Schedule .Duration )
106+ require .NotNil (t , confirmation .Schedule .ScheduleStart )
107+ assert .Equal (t , compositeSchedule .ScheduleStart .FormatTimestamp (), confirmation .Schedule .ScheduleStart .FormatTimestamp ())
108+ assert .Equal (t , chargingRateUnit , confirmation .Schedule .ChargingRateUnit )
109+ require .Len (t , confirmation .Schedule .ChargingSchedulePeriod , 1 )
110+ assert .Equal (t , chargingSchedulePeriod .Limit , confirmation .Schedule .ChargingSchedulePeriod [0 ].Limit )
111+ assert .Equal (t , chargingSchedulePeriod .StartPeriod , confirmation .Schedule .ChargingSchedulePeriod [0 ].StartPeriod )
112+ require .NotNil (t , confirmation .Schedule .ChargingSchedulePeriod [0 ].NumberPhases )
113+ assert .Equal (t , * chargingSchedulePeriod .NumberPhases , * confirmation .Schedule .ChargingSchedulePeriod [0 ].NumberPhases )
117114 resultChannel <- true
118115 }, duration , evseID , func (request * smartcharging.GetCompositeScheduleRequest ) {
119116 request .ChargingRateUnit = chargingRateUnit
0 commit comments