diff --git a/go.mod b/go.mod index e09ef029..23192bf9 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/leodido/go-urn v1.1.0 // indirect github.com/relvacode/iso8601 v1.6.0 github.com/sirupsen/logrus v1.4.2 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.10.0 golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect diff --git a/go.sum b/go.sum index 526046d2..c09ba9c7 100644 --- a/go.sum +++ b/go.sum @@ -30,12 +30,16 @@ github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 h1:9vYwv7OjYaky/tlAeD7C4oC9EsPTlaFl1H2jS++V+ME= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go b/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go index a0bfeaa9..363c4fde 100644 --- a/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_core_central_system_handler.go b/ocpp1.6_test/mocks/mock_core_central_system_handler.go index 2f200d07..6aa1d683 100644 --- a/ocpp1.6_test/mocks/mock_core_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_core_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_core_charge_point_handler.go b/ocpp1.6_test/mocks/mock_core_charge_point_handler.go index 2ebb07dd..492865ef 100644 --- a/ocpp1.6_test/mocks/mock_core_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_core_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_extended_trigger_message_charge_point_handler.go b/ocpp1.6_test/mocks/mock_extended_trigger_message_charge_point_handler.go index f2dba253..606a3412 100644 --- a/ocpp1.6_test/mocks/mock_extended_trigger_message_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_extended_trigger_message_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go b/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go index 96e0c872..46583764 100644 --- a/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go b/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go index 24041b80..13f874ee 100644 --- a/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_local_auth_list_central_system_handler.go b/ocpp1.6_test/mocks/mock_local_auth_list_central_system_handler.go index e3e7d459..6da113c5 100644 --- a/ocpp1.6_test/mocks/mock_local_auth_list_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_local_auth_list_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_local_auth_list_charge_point_handler.go b/ocpp1.6_test/mocks/mock_local_auth_list_charge_point_handler.go index 0209f9bf..b7a552d6 100644 --- a/ocpp1.6_test/mocks/mock_local_auth_list_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_local_auth_list_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_logging_central_system_handler.go b/ocpp1.6_test/mocks/mock_logging_central_system_handler.go index a3a8397f..f8b0ed68 100644 --- a/ocpp1.6_test/mocks/mock_logging_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_logging_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go b/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go index ca649fa2..f26f5227 100644 --- a/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_ocpp16.go b/ocpp1.6_test/mocks/mock_ocpp16.go index 1be648d5..330eecee 100644 --- a/ocpp1.6_test/mocks/mock_ocpp16.go +++ b/ocpp1.6_test/mocks/mock_ocpp16.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks @@ -49,7 +49,7 @@ func (_c *MockChargePointConnectionHandler_Execute_Call) Return() *MockChargePoi } func (_c *MockChargePointConnectionHandler_Execute_Call) RunAndReturn(run func(ocpp16.ChargePointConnection)) *MockChargePointConnectionHandler_Execute_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/ocpp1.6_test/mocks/mock_remote_trigger_central_system_handler.go b/ocpp1.6_test/mocks/mock_remote_trigger_central_system_handler.go index 9bb64c22..1d95ec5e 100644 --- a/ocpp1.6_test/mocks/mock_remote_trigger_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_remote_trigger_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_remote_trigger_charge_point_handler.go b/ocpp1.6_test/mocks/mock_remote_trigger_charge_point_handler.go index 5c49ed07..ae0d35d1 100644 --- a/ocpp1.6_test/mocks/mock_remote_trigger_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_remote_trigger_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go b/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go index 542945b3..7ce97b06 100644 --- a/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go b/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go index 7067a0f5..2800b719 100644 --- a/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go b/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go index ae01d1d8..a8540226 100644 --- a/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go +++ b/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go b/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go index ef07f7c1..fbede0a3 100644 --- a/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go +++ b/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_security_central_system_handler.go b/ocpp1.6_test/mocks/mock_security_central_system_handler.go index 9d07b0c0..3728fadc 100644 --- a/ocpp1.6_test/mocks/mock_security_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_security_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_security_charge_point_handler.go b/ocpp1.6_test/mocks/mock_security_charge_point_handler.go index ec7cf4b6..012adec9 100644 --- a/ocpp1.6_test/mocks/mock_security_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_security_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_smart_charging_central_system_handler.go b/ocpp1.6_test/mocks/mock_smart_charging_central_system_handler.go index b629878a..1a5ebb75 100644 --- a/ocpp1.6_test/mocks/mock_smart_charging_central_system_handler.go +++ b/ocpp1.6_test/mocks/mock_smart_charging_central_system_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocpp1.6_test/mocks/mock_smart_charging_charge_point_handler.go b/ocpp1.6_test/mocks/mock_smart_charging_charge_point_handler.go index 1372d231..61ee69cd 100644 --- a/ocpp1.6_test/mocks/mock_smart_charging_charge_point_handler.go +++ b/ocpp1.6_test/mocks/mock_smart_charging_charge_point_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks diff --git a/ocppj/mocks/mock_CanceledRequestHandler.go b/ocppj/mocks/mock_CanceledRequestHandler.go new file mode 100644 index 00000000..be1be073 --- /dev/null +++ b/ocppj/mocks/mock_CanceledRequestHandler.go @@ -0,0 +1,71 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" +) + +// MockCanceledRequestHandler is an autogenerated mock type for the CanceledRequestHandler type +type MockCanceledRequestHandler struct { + mock.Mock +} + +type MockCanceledRequestHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockCanceledRequestHandler) EXPECT() *MockCanceledRequestHandler_Expecter { + return &MockCanceledRequestHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: clientID, requestID, request, err +func (_m *MockCanceledRequestHandler) Execute(clientID string, requestID string, request ocpp.Request, err *ocpp.Error) { + _m.Called(clientID, requestID, request, err) +} + +// MockCanceledRequestHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockCanceledRequestHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - clientID string +// - requestID string +// - request ocpp.Request +// - err *ocpp.Error +func (_e *MockCanceledRequestHandler_Expecter) Execute(clientID interface{}, requestID interface{}, request interface{}, err interface{}) *MockCanceledRequestHandler_Execute_Call { + return &MockCanceledRequestHandler_Execute_Call{Call: _e.mock.On("Execute", clientID, requestID, request, err)} +} + +func (_c *MockCanceledRequestHandler_Execute_Call) Run(run func(clientID string, requestID string, request ocpp.Request, err *ocpp.Error)) *MockCanceledRequestHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string), args[2].(ocpp.Request), args[3].(*ocpp.Error)) + }) + return _c +} + +func (_c *MockCanceledRequestHandler_Execute_Call) Return() *MockCanceledRequestHandler_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *MockCanceledRequestHandler_Execute_Call) RunAndReturn(run func(string, string, ocpp.Request, *ocpp.Error)) *MockCanceledRequestHandler_Execute_Call { + _c.Run(run) + return _c +} + +// NewMockCanceledRequestHandler creates a new instance of MockCanceledRequestHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockCanceledRequestHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockCanceledRequestHandler { + mock := &MockCanceledRequestHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_ClientDispatcher.go b/ocppj/mocks/mock_ClientDispatcher.go new file mode 100644 index 00000000..afa36f5c --- /dev/null +++ b/ocppj/mocks/mock_ClientDispatcher.go @@ -0,0 +1,470 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" + + ocppj "github.com/lorenzodonini/ocpp-go/ocppj" + + time "time" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockClientDispatcher is an autogenerated mock type for the ClientDispatcher type +type MockClientDispatcher struct { + mock.Mock +} + +type MockClientDispatcher_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClientDispatcher) EXPECT() *MockClientDispatcher_Expecter { + return &MockClientDispatcher_Expecter{mock: &_m.Mock} +} + +// CompleteRequest provides a mock function with given fields: requestID +func (_m *MockClientDispatcher) CompleteRequest(requestID string) { + _m.Called(requestID) +} + +// MockClientDispatcher_CompleteRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CompleteRequest' +type MockClientDispatcher_CompleteRequest_Call struct { + *mock.Call +} + +// CompleteRequest is a helper method to define mock.On call +// - requestID string +func (_e *MockClientDispatcher_Expecter) CompleteRequest(requestID interface{}) *MockClientDispatcher_CompleteRequest_Call { + return &MockClientDispatcher_CompleteRequest_Call{Call: _e.mock.On("CompleteRequest", requestID)} +} + +func (_c *MockClientDispatcher_CompleteRequest_Call) Run(run func(requestID string)) *MockClientDispatcher_CompleteRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockClientDispatcher_CompleteRequest_Call) Return() *MockClientDispatcher_CompleteRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_CompleteRequest_Call) RunAndReturn(run func(string)) *MockClientDispatcher_CompleteRequest_Call { + _c.Run(run) + return _c +} + +// IsPaused provides a mock function with no fields +func (_m *MockClientDispatcher) IsPaused() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsPaused") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockClientDispatcher_IsPaused_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsPaused' +type MockClientDispatcher_IsPaused_Call struct { + *mock.Call +} + +// IsPaused is a helper method to define mock.On call +func (_e *MockClientDispatcher_Expecter) IsPaused() *MockClientDispatcher_IsPaused_Call { + return &MockClientDispatcher_IsPaused_Call{Call: _e.mock.On("IsPaused")} +} + +func (_c *MockClientDispatcher_IsPaused_Call) Run(run func()) *MockClientDispatcher_IsPaused_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientDispatcher_IsPaused_Call) Return(_a0 bool) *MockClientDispatcher_IsPaused_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClientDispatcher_IsPaused_Call) RunAndReturn(run func() bool) *MockClientDispatcher_IsPaused_Call { + _c.Call.Return(run) + return _c +} + +// IsRunning provides a mock function with no fields +func (_m *MockClientDispatcher) IsRunning() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockClientDispatcher_IsRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRunning' +type MockClientDispatcher_IsRunning_Call struct { + *mock.Call +} + +// IsRunning is a helper method to define mock.On call +func (_e *MockClientDispatcher_Expecter) IsRunning() *MockClientDispatcher_IsRunning_Call { + return &MockClientDispatcher_IsRunning_Call{Call: _e.mock.On("IsRunning")} +} + +func (_c *MockClientDispatcher_IsRunning_Call) Run(run func()) *MockClientDispatcher_IsRunning_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientDispatcher_IsRunning_Call) Return(_a0 bool) *MockClientDispatcher_IsRunning_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClientDispatcher_IsRunning_Call) RunAndReturn(run func() bool) *MockClientDispatcher_IsRunning_Call { + _c.Call.Return(run) + return _c +} + +// Pause provides a mock function with no fields +func (_m *MockClientDispatcher) Pause() { + _m.Called() +} + +// MockClientDispatcher_Pause_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Pause' +type MockClientDispatcher_Pause_Call struct { + *mock.Call +} + +// Pause is a helper method to define mock.On call +func (_e *MockClientDispatcher_Expecter) Pause() *MockClientDispatcher_Pause_Call { + return &MockClientDispatcher_Pause_Call{Call: _e.mock.On("Pause")} +} + +func (_c *MockClientDispatcher_Pause_Call) Run(run func()) *MockClientDispatcher_Pause_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientDispatcher_Pause_Call) Return() *MockClientDispatcher_Pause_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_Pause_Call) RunAndReturn(run func()) *MockClientDispatcher_Pause_Call { + _c.Run(run) + return _c +} + +// Resume provides a mock function with no fields +func (_m *MockClientDispatcher) Resume() { + _m.Called() +} + +// MockClientDispatcher_Resume_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Resume' +type MockClientDispatcher_Resume_Call struct { + *mock.Call +} + +// Resume is a helper method to define mock.On call +func (_e *MockClientDispatcher_Expecter) Resume() *MockClientDispatcher_Resume_Call { + return &MockClientDispatcher_Resume_Call{Call: _e.mock.On("Resume")} +} + +func (_c *MockClientDispatcher_Resume_Call) Run(run func()) *MockClientDispatcher_Resume_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientDispatcher_Resume_Call) Return() *MockClientDispatcher_Resume_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_Resume_Call) RunAndReturn(run func()) *MockClientDispatcher_Resume_Call { + _c.Run(run) + return _c +} + +// SendRequest provides a mock function with given fields: req +func (_m *MockClientDispatcher) SendRequest(req ocppj.RequestBundle) error { + ret := _m.Called(req) + + if len(ret) == 0 { + panic("no return value specified for SendRequest") + } + + var r0 error + if rf, ok := ret.Get(0).(func(ocppj.RequestBundle) error); ok { + r0 = rf(req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClientDispatcher_SendRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendRequest' +type MockClientDispatcher_SendRequest_Call struct { + *mock.Call +} + +// SendRequest is a helper method to define mock.On call +// - req ocppj.RequestBundle +func (_e *MockClientDispatcher_Expecter) SendRequest(req interface{}) *MockClientDispatcher_SendRequest_Call { + return &MockClientDispatcher_SendRequest_Call{Call: _e.mock.On("SendRequest", req)} +} + +func (_c *MockClientDispatcher_SendRequest_Call) Run(run func(req ocppj.RequestBundle)) *MockClientDispatcher_SendRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ocppj.RequestBundle)) + }) + return _c +} + +func (_c *MockClientDispatcher_SendRequest_Call) Return(_a0 error) *MockClientDispatcher_SendRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClientDispatcher_SendRequest_Call) RunAndReturn(run func(ocppj.RequestBundle) error) *MockClientDispatcher_SendRequest_Call { + _c.Call.Return(run) + return _c +} + +// SetNetworkClient provides a mock function with given fields: client +func (_m *MockClientDispatcher) SetNetworkClient(client ws.WsClient) { + _m.Called(client) +} + +// MockClientDispatcher_SetNetworkClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetNetworkClient' +type MockClientDispatcher_SetNetworkClient_Call struct { + *mock.Call +} + +// SetNetworkClient is a helper method to define mock.On call +// - client ws.WsClient +func (_e *MockClientDispatcher_Expecter) SetNetworkClient(client interface{}) *MockClientDispatcher_SetNetworkClient_Call { + return &MockClientDispatcher_SetNetworkClient_Call{Call: _e.mock.On("SetNetworkClient", client)} +} + +func (_c *MockClientDispatcher_SetNetworkClient_Call) Run(run func(client ws.WsClient)) *MockClientDispatcher_SetNetworkClient_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.WsClient)) + }) + return _c +} + +func (_c *MockClientDispatcher_SetNetworkClient_Call) Return() *MockClientDispatcher_SetNetworkClient_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_SetNetworkClient_Call) RunAndReturn(run func(ws.WsClient)) *MockClientDispatcher_SetNetworkClient_Call { + _c.Run(run) + return _c +} + +// SetOnRequestCanceled provides a mock function with given fields: cb +func (_m *MockClientDispatcher) SetOnRequestCanceled(cb func(string, ocpp.Request, *ocpp.Error)) { + _m.Called(cb) +} + +// MockClientDispatcher_SetOnRequestCanceled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOnRequestCanceled' +type MockClientDispatcher_SetOnRequestCanceled_Call struct { + *mock.Call +} + +// SetOnRequestCanceled is a helper method to define mock.On call +// - cb func(string , ocpp.Request , *ocpp.Error) +func (_e *MockClientDispatcher_Expecter) SetOnRequestCanceled(cb interface{}) *MockClientDispatcher_SetOnRequestCanceled_Call { + return &MockClientDispatcher_SetOnRequestCanceled_Call{Call: _e.mock.On("SetOnRequestCanceled", cb)} +} + +func (_c *MockClientDispatcher_SetOnRequestCanceled_Call) Run(run func(cb func(string, ocpp.Request, *ocpp.Error))) *MockClientDispatcher_SetOnRequestCanceled_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(string, ocpp.Request, *ocpp.Error))) + }) + return _c +} + +func (_c *MockClientDispatcher_SetOnRequestCanceled_Call) Return() *MockClientDispatcher_SetOnRequestCanceled_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_SetOnRequestCanceled_Call) RunAndReturn(run func(func(string, ocpp.Request, *ocpp.Error))) *MockClientDispatcher_SetOnRequestCanceled_Call { + _c.Run(run) + return _c +} + +// SetPendingRequestState provides a mock function with given fields: stateHandler +func (_m *MockClientDispatcher) SetPendingRequestState(stateHandler ocppj.ClientState) { + _m.Called(stateHandler) +} + +// MockClientDispatcher_SetPendingRequestState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPendingRequestState' +type MockClientDispatcher_SetPendingRequestState_Call struct { + *mock.Call +} + +// SetPendingRequestState is a helper method to define mock.On call +// - stateHandler ocppj.ClientState +func (_e *MockClientDispatcher_Expecter) SetPendingRequestState(stateHandler interface{}) *MockClientDispatcher_SetPendingRequestState_Call { + return &MockClientDispatcher_SetPendingRequestState_Call{Call: _e.mock.On("SetPendingRequestState", stateHandler)} +} + +func (_c *MockClientDispatcher_SetPendingRequestState_Call) Run(run func(stateHandler ocppj.ClientState)) *MockClientDispatcher_SetPendingRequestState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ocppj.ClientState)) + }) + return _c +} + +func (_c *MockClientDispatcher_SetPendingRequestState_Call) Return() *MockClientDispatcher_SetPendingRequestState_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_SetPendingRequestState_Call) RunAndReturn(run func(ocppj.ClientState)) *MockClientDispatcher_SetPendingRequestState_Call { + _c.Run(run) + return _c +} + +// SetTimeout provides a mock function with given fields: timeout +func (_m *MockClientDispatcher) SetTimeout(timeout time.Duration) { + _m.Called(timeout) +} + +// MockClientDispatcher_SetTimeout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTimeout' +type MockClientDispatcher_SetTimeout_Call struct { + *mock.Call +} + +// SetTimeout is a helper method to define mock.On call +// - timeout time.Duration +func (_e *MockClientDispatcher_Expecter) SetTimeout(timeout interface{}) *MockClientDispatcher_SetTimeout_Call { + return &MockClientDispatcher_SetTimeout_Call{Call: _e.mock.On("SetTimeout", timeout)} +} + +func (_c *MockClientDispatcher_SetTimeout_Call) Run(run func(timeout time.Duration)) *MockClientDispatcher_SetTimeout_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration)) + }) + return _c +} + +func (_c *MockClientDispatcher_SetTimeout_Call) Return() *MockClientDispatcher_SetTimeout_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_SetTimeout_Call) RunAndReturn(run func(time.Duration)) *MockClientDispatcher_SetTimeout_Call { + _c.Run(run) + return _c +} + +// Start provides a mock function with no fields +func (_m *MockClientDispatcher) Start() { + _m.Called() +} + +// MockClientDispatcher_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type MockClientDispatcher_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +func (_e *MockClientDispatcher_Expecter) Start() *MockClientDispatcher_Start_Call { + return &MockClientDispatcher_Start_Call{Call: _e.mock.On("Start")} +} + +func (_c *MockClientDispatcher_Start_Call) Run(run func()) *MockClientDispatcher_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientDispatcher_Start_Call) Return() *MockClientDispatcher_Start_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_Start_Call) RunAndReturn(run func()) *MockClientDispatcher_Start_Call { + _c.Run(run) + return _c +} + +// Stop provides a mock function with no fields +func (_m *MockClientDispatcher) Stop() { + _m.Called() +} + +// MockClientDispatcher_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type MockClientDispatcher_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *MockClientDispatcher_Expecter) Stop() *MockClientDispatcher_Stop_Call { + return &MockClientDispatcher_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *MockClientDispatcher_Stop_Call) Run(run func()) *MockClientDispatcher_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientDispatcher_Stop_Call) Return() *MockClientDispatcher_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientDispatcher_Stop_Call) RunAndReturn(run func()) *MockClientDispatcher_Stop_Call { + _c.Run(run) + return _c +} + +// NewMockClientDispatcher creates a new instance of MockClientDispatcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClientDispatcher(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClientDispatcher { + mock := &MockClientDispatcher{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_ClientHandler.go b/ocppj/mocks/mock_ClientHandler.go new file mode 100644 index 00000000..f08a868f --- /dev/null +++ b/ocppj/mocks/mock_ClientHandler.go @@ -0,0 +1,69 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockClientHandler is an autogenerated mock type for the ClientHandler type +type MockClientHandler struct { + mock.Mock +} + +type MockClientHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClientHandler) EXPECT() *MockClientHandler_Expecter { + return &MockClientHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: client +func (_m *MockClientHandler) Execute(client ws.Channel) { + _m.Called(client) +} + +// MockClientHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockClientHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - client ws.Channel +func (_e *MockClientHandler_Expecter) Execute(client interface{}) *MockClientHandler_Execute_Call { + return &MockClientHandler_Execute_Call{Call: _e.mock.On("Execute", client)} +} + +func (_c *MockClientHandler_Execute_Call) Run(run func(client ws.Channel)) *MockClientHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.Channel)) + }) + return _c +} + +func (_c *MockClientHandler_Execute_Call) Return() *MockClientHandler_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientHandler_Execute_Call) RunAndReturn(run func(ws.Channel)) *MockClientHandler_Execute_Call { + _c.Run(run) + return _c +} + +// NewMockClientHandler creates a new instance of MockClientHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClientHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClientHandler { + mock := &MockClientHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_ClientState.go b/ocppj/mocks/mock_ClientState.go new file mode 100644 index 00000000..d07d228c --- /dev/null +++ b/ocppj/mocks/mock_ClientState.go @@ -0,0 +1,237 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" +) + +// MockClientState is an autogenerated mock type for the ClientState type +type MockClientState struct { + mock.Mock +} + +type MockClientState_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClientState) EXPECT() *MockClientState_Expecter { + return &MockClientState_Expecter{mock: &_m.Mock} +} + +// AddPendingRequest provides a mock function with given fields: requestID, req +func (_m *MockClientState) AddPendingRequest(requestID string, req ocpp.Request) { + _m.Called(requestID, req) +} + +// MockClientState_AddPendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddPendingRequest' +type MockClientState_AddPendingRequest_Call struct { + *mock.Call +} + +// AddPendingRequest is a helper method to define mock.On call +// - requestID string +// - req ocpp.Request +func (_e *MockClientState_Expecter) AddPendingRequest(requestID interface{}, req interface{}) *MockClientState_AddPendingRequest_Call { + return &MockClientState_AddPendingRequest_Call{Call: _e.mock.On("AddPendingRequest", requestID, req)} +} + +func (_c *MockClientState_AddPendingRequest_Call) Run(run func(requestID string, req ocpp.Request)) *MockClientState_AddPendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(ocpp.Request)) + }) + return _c +} + +func (_c *MockClientState_AddPendingRequest_Call) Return() *MockClientState_AddPendingRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientState_AddPendingRequest_Call) RunAndReturn(run func(string, ocpp.Request)) *MockClientState_AddPendingRequest_Call { + _c.Run(run) + return _c +} + +// ClearPendingRequests provides a mock function with no fields +func (_m *MockClientState) ClearPendingRequests() { + _m.Called() +} + +// MockClientState_ClearPendingRequests_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearPendingRequests' +type MockClientState_ClearPendingRequests_Call struct { + *mock.Call +} + +// ClearPendingRequests is a helper method to define mock.On call +func (_e *MockClientState_Expecter) ClearPendingRequests() *MockClientState_ClearPendingRequests_Call { + return &MockClientState_ClearPendingRequests_Call{Call: _e.mock.On("ClearPendingRequests")} +} + +func (_c *MockClientState_ClearPendingRequests_Call) Run(run func()) *MockClientState_ClearPendingRequests_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientState_ClearPendingRequests_Call) Return() *MockClientState_ClearPendingRequests_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientState_ClearPendingRequests_Call) RunAndReturn(run func()) *MockClientState_ClearPendingRequests_Call { + _c.Run(run) + return _c +} + +// DeletePendingRequest provides a mock function with given fields: requestID +func (_m *MockClientState) DeletePendingRequest(requestID string) { + _m.Called(requestID) +} + +// MockClientState_DeletePendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeletePendingRequest' +type MockClientState_DeletePendingRequest_Call struct { + *mock.Call +} + +// DeletePendingRequest is a helper method to define mock.On call +// - requestID string +func (_e *MockClientState_Expecter) DeletePendingRequest(requestID interface{}) *MockClientState_DeletePendingRequest_Call { + return &MockClientState_DeletePendingRequest_Call{Call: _e.mock.On("DeletePendingRequest", requestID)} +} + +func (_c *MockClientState_DeletePendingRequest_Call) Run(run func(requestID string)) *MockClientState_DeletePendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockClientState_DeletePendingRequest_Call) Return() *MockClientState_DeletePendingRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockClientState_DeletePendingRequest_Call) RunAndReturn(run func(string)) *MockClientState_DeletePendingRequest_Call { + _c.Run(run) + return _c +} + +// GetPendingRequest provides a mock function with given fields: requestID +func (_m *MockClientState) GetPendingRequest(requestID string) (ocpp.Request, bool) { + ret := _m.Called(requestID) + + if len(ret) == 0 { + panic("no return value specified for GetPendingRequest") + } + + var r0 ocpp.Request + var r1 bool + if rf, ok := ret.Get(0).(func(string) (ocpp.Request, bool)); ok { + return rf(requestID) + } + if rf, ok := ret.Get(0).(func(string) ocpp.Request); ok { + r0 = rf(requestID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(ocpp.Request) + } + } + + if rf, ok := ret.Get(1).(func(string) bool); ok { + r1 = rf(requestID) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// MockClientState_GetPendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPendingRequest' +type MockClientState_GetPendingRequest_Call struct { + *mock.Call +} + +// GetPendingRequest is a helper method to define mock.On call +// - requestID string +func (_e *MockClientState_Expecter) GetPendingRequest(requestID interface{}) *MockClientState_GetPendingRequest_Call { + return &MockClientState_GetPendingRequest_Call{Call: _e.mock.On("GetPendingRequest", requestID)} +} + +func (_c *MockClientState_GetPendingRequest_Call) Run(run func(requestID string)) *MockClientState_GetPendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockClientState_GetPendingRequest_Call) Return(_a0 ocpp.Request, _a1 bool) *MockClientState_GetPendingRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientState_GetPendingRequest_Call) RunAndReturn(run func(string) (ocpp.Request, bool)) *MockClientState_GetPendingRequest_Call { + _c.Call.Return(run) + return _c +} + +// HasPendingRequest provides a mock function with no fields +func (_m *MockClientState) HasPendingRequest() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HasPendingRequest") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockClientState_HasPendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasPendingRequest' +type MockClientState_HasPendingRequest_Call struct { + *mock.Call +} + +// HasPendingRequest is a helper method to define mock.On call +func (_e *MockClientState_Expecter) HasPendingRequest() *MockClientState_HasPendingRequest_Call { + return &MockClientState_HasPendingRequest_Call{Call: _e.mock.On("HasPendingRequest")} +} + +func (_c *MockClientState_HasPendingRequest_Call) Run(run func()) *MockClientState_HasPendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockClientState_HasPendingRequest_Call) Return(_a0 bool) *MockClientState_HasPendingRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockClientState_HasPendingRequest_Call) RunAndReturn(run func() bool) *MockClientState_HasPendingRequest_Call { + _c.Call.Return(run) + return _c +} + +// NewMockClientState creates a new instance of MockClientState. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClientState(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClientState { + mock := &MockClientState{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_ErrorHandler.go b/ocppj/mocks/mock_ErrorHandler.go new file mode 100644 index 00000000..3d956910 --- /dev/null +++ b/ocppj/mocks/mock_ErrorHandler.go @@ -0,0 +1,72 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockErrorHandler is an autogenerated mock type for the ErrorHandler type +type MockErrorHandler struct { + mock.Mock +} + +type MockErrorHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockErrorHandler) EXPECT() *MockErrorHandler_Expecter { + return &MockErrorHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: client, err, details +func (_m *MockErrorHandler) Execute(client ws.Channel, err *ocpp.Error, details interface{}) { + _m.Called(client, err, details) +} + +// MockErrorHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockErrorHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - client ws.Channel +// - err *ocpp.Error +// - details interface{} +func (_e *MockErrorHandler_Expecter) Execute(client interface{}, err interface{}, details interface{}) *MockErrorHandler_Execute_Call { + return &MockErrorHandler_Execute_Call{Call: _e.mock.On("Execute", client, err, details)} +} + +func (_c *MockErrorHandler_Execute_Call) Run(run func(client ws.Channel, err *ocpp.Error, details interface{})) *MockErrorHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.Channel), args[1].(*ocpp.Error), args[2].(interface{})) + }) + return _c +} + +func (_c *MockErrorHandler_Execute_Call) Return() *MockErrorHandler_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *MockErrorHandler_Execute_Call) RunAndReturn(run func(ws.Channel, *ocpp.Error, interface{})) *MockErrorHandler_Execute_Call { + _c.Run(run) + return _c +} + +// NewMockErrorHandler creates a new instance of MockErrorHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockErrorHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockErrorHandler { + mock := &MockErrorHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_InvalidMessageHook.go b/ocppj/mocks/mock_InvalidMessageHook.go new file mode 100644 index 00000000..1e82f54e --- /dev/null +++ b/ocppj/mocks/mock_InvalidMessageHook.go @@ -0,0 +1,88 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockInvalidMessageHook is an autogenerated mock type for the InvalidMessageHook type +type MockInvalidMessageHook struct { + mock.Mock +} + +type MockInvalidMessageHook_Expecter struct { + mock *mock.Mock +} + +func (_m *MockInvalidMessageHook) EXPECT() *MockInvalidMessageHook_Expecter { + return &MockInvalidMessageHook_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: client, err, rawJson, parsedFields +func (_m *MockInvalidMessageHook) Execute(client ws.Channel, err *ocpp.Error, rawJson string, parsedFields []interface{}) *ocpp.Error { + ret := _m.Called(client, err, rawJson, parsedFields) + + if len(ret) == 0 { + panic("no return value specified for Execute") + } + + var r0 *ocpp.Error + if rf, ok := ret.Get(0).(func(ws.Channel, *ocpp.Error, string, []interface{}) *ocpp.Error); ok { + r0 = rf(client, err, rawJson, parsedFields) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ocpp.Error) + } + } + + return r0 +} + +// MockInvalidMessageHook_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockInvalidMessageHook_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - client ws.Channel +// - err *ocpp.Error +// - rawJson string +// - parsedFields []interface{} +func (_e *MockInvalidMessageHook_Expecter) Execute(client interface{}, err interface{}, rawJson interface{}, parsedFields interface{}) *MockInvalidMessageHook_Execute_Call { + return &MockInvalidMessageHook_Execute_Call{Call: _e.mock.On("Execute", client, err, rawJson, parsedFields)} +} + +func (_c *MockInvalidMessageHook_Execute_Call) Run(run func(client ws.Channel, err *ocpp.Error, rawJson string, parsedFields []interface{})) *MockInvalidMessageHook_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.Channel), args[1].(*ocpp.Error), args[2].(string), args[3].([]interface{})) + }) + return _c +} + +func (_c *MockInvalidMessageHook_Execute_Call) Return(_a0 *ocpp.Error) *MockInvalidMessageHook_Execute_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockInvalidMessageHook_Execute_Call) RunAndReturn(run func(ws.Channel, *ocpp.Error, string, []interface{}) *ocpp.Error) *MockInvalidMessageHook_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewMockInvalidMessageHook creates a new instance of MockInvalidMessageHook. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockInvalidMessageHook(t interface { + mock.TestingT + Cleanup(func()) +}) *MockInvalidMessageHook { + mock := &MockInvalidMessageHook{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_Message.go b/ocppj/mocks/mock_Message.go new file mode 100644 index 00000000..d741881a --- /dev/null +++ b/ocppj/mocks/mock_Message.go @@ -0,0 +1,182 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocppj "github.com/lorenzodonini/ocpp-go/ocppj" + mock "github.com/stretchr/testify/mock" +) + +// MockMessage is an autogenerated mock type for the Message type +type MockMessage struct { + mock.Mock +} + +type MockMessage_Expecter struct { + mock *mock.Mock +} + +func (_m *MockMessage) EXPECT() *MockMessage_Expecter { + return &MockMessage_Expecter{mock: &_m.Mock} +} + +// GetMessageTypeId provides a mock function with no fields +func (_m *MockMessage) GetMessageTypeId() ocppj.MessageType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetMessageTypeId") + } + + var r0 ocppj.MessageType + if rf, ok := ret.Get(0).(func() ocppj.MessageType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(ocppj.MessageType) + } + + return r0 +} + +// MockMessage_GetMessageTypeId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessageTypeId' +type MockMessage_GetMessageTypeId_Call struct { + *mock.Call +} + +// GetMessageTypeId is a helper method to define mock.On call +func (_e *MockMessage_Expecter) GetMessageTypeId() *MockMessage_GetMessageTypeId_Call { + return &MockMessage_GetMessageTypeId_Call{Call: _e.mock.On("GetMessageTypeId")} +} + +func (_c *MockMessage_GetMessageTypeId_Call) Run(run func()) *MockMessage_GetMessageTypeId_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockMessage_GetMessageTypeId_Call) Return(_a0 ocppj.MessageType) *MockMessage_GetMessageTypeId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockMessage_GetMessageTypeId_Call) RunAndReturn(run func() ocppj.MessageType) *MockMessage_GetMessageTypeId_Call { + _c.Call.Return(run) + return _c +} + +// GetUniqueId provides a mock function with no fields +func (_m *MockMessage) GetUniqueId() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetUniqueId") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockMessage_GetUniqueId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUniqueId' +type MockMessage_GetUniqueId_Call struct { + *mock.Call +} + +// GetUniqueId is a helper method to define mock.On call +func (_e *MockMessage_Expecter) GetUniqueId() *MockMessage_GetUniqueId_Call { + return &MockMessage_GetUniqueId_Call{Call: _e.mock.On("GetUniqueId")} +} + +func (_c *MockMessage_GetUniqueId_Call) Run(run func()) *MockMessage_GetUniqueId_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockMessage_GetUniqueId_Call) Return(_a0 string) *MockMessage_GetUniqueId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockMessage_GetUniqueId_Call) RunAndReturn(run func() string) *MockMessage_GetUniqueId_Call { + _c.Call.Return(run) + return _c +} + +// MarshalJSON provides a mock function with no fields +func (_m *MockMessage) MarshalJSON() ([]byte, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for MarshalJSON") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []byte); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockMessage_MarshalJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MarshalJSON' +type MockMessage_MarshalJSON_Call struct { + *mock.Call +} + +// MarshalJSON is a helper method to define mock.On call +func (_e *MockMessage_Expecter) MarshalJSON() *MockMessage_MarshalJSON_Call { + return &MockMessage_MarshalJSON_Call{Call: _e.mock.On("MarshalJSON")} +} + +func (_c *MockMessage_MarshalJSON_Call) Run(run func()) *MockMessage_MarshalJSON_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockMessage_MarshalJSON_Call) Return(_a0 []byte, _a1 error) *MockMessage_MarshalJSON_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockMessage_MarshalJSON_Call) RunAndReturn(run func() ([]byte, error)) *MockMessage_MarshalJSON_Call { + _c.Call.Return(run) + return _c +} + +// NewMockMessage creates a new instance of MockMessage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockMessage(t interface { + mock.TestingT + Cleanup(func()) +}) *MockMessage { + mock := &MockMessage{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_RequestHandler.go b/ocppj/mocks/mock_RequestHandler.go new file mode 100644 index 00000000..5753bfe8 --- /dev/null +++ b/ocppj/mocks/mock_RequestHandler.go @@ -0,0 +1,73 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockRequestHandler is an autogenerated mock type for the RequestHandler type +type MockRequestHandler struct { + mock.Mock +} + +type MockRequestHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockRequestHandler) EXPECT() *MockRequestHandler_Expecter { + return &MockRequestHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: client, request, requestId, action +func (_m *MockRequestHandler) Execute(client ws.Channel, request ocpp.Request, requestId string, action string) { + _m.Called(client, request, requestId, action) +} + +// MockRequestHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockRequestHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - client ws.Channel +// - request ocpp.Request +// - requestId string +// - action string +func (_e *MockRequestHandler_Expecter) Execute(client interface{}, request interface{}, requestId interface{}, action interface{}) *MockRequestHandler_Execute_Call { + return &MockRequestHandler_Execute_Call{Call: _e.mock.On("Execute", client, request, requestId, action)} +} + +func (_c *MockRequestHandler_Execute_Call) Run(run func(client ws.Channel, request ocpp.Request, requestId string, action string)) *MockRequestHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.Channel), args[1].(ocpp.Request), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockRequestHandler_Execute_Call) Return() *MockRequestHandler_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *MockRequestHandler_Execute_Call) RunAndReturn(run func(ws.Channel, ocpp.Request, string, string)) *MockRequestHandler_Execute_Call { + _c.Run(run) + return _c +} + +// NewMockRequestHandler creates a new instance of MockRequestHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockRequestHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockRequestHandler { + mock := &MockRequestHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_RequestQueue.go b/ocppj/mocks/mock_RequestQueue.go index 1a4f9264..298a42de 100644 --- a/ocppj/mocks/mock_RequestQueue.go +++ b/ocppj/mocks/mock_RequestQueue.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks @@ -17,7 +17,7 @@ func (_m *MockRequestQueue) EXPECT() *MockRequestQueue_Expecter { return &MockRequestQueue_Expecter{mock: &_m.Mock} } -// Init provides a mock function with given fields: +// Init provides a mock function with no fields func (_m *MockRequestQueue) Init() { _m.Called() } @@ -45,11 +45,11 @@ func (_c *MockRequestQueue_Init_Call) Return() *MockRequestQueue_Init_Call { } func (_c *MockRequestQueue_Init_Call) RunAndReturn(run func()) *MockRequestQueue_Init_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// IsEmpty provides a mock function with given fields: +// IsEmpty provides a mock function with no fields func (_m *MockRequestQueue) IsEmpty() bool { ret := _m.Called() @@ -94,7 +94,7 @@ func (_c *MockRequestQueue_IsEmpty_Call) RunAndReturn(run func() bool) *MockRequ return _c } -// IsFull provides a mock function with given fields: +// IsFull provides a mock function with no fields func (_m *MockRequestQueue) IsFull() bool { ret := _m.Called() @@ -139,7 +139,7 @@ func (_c *MockRequestQueue_IsFull_Call) RunAndReturn(run func() bool) *MockReque return _c } -// Peek provides a mock function with given fields: +// Peek provides a mock function with no fields func (_m *MockRequestQueue) Peek() interface{} { ret := _m.Called() @@ -186,7 +186,7 @@ func (_c *MockRequestQueue_Peek_Call) RunAndReturn(run func() interface{}) *Mock return _c } -// Pop provides a mock function with given fields: +// Pop provides a mock function with no fields func (_m *MockRequestQueue) Pop() interface{} { ret := _m.Called() @@ -279,7 +279,7 @@ func (_c *MockRequestQueue_Push_Call) RunAndReturn(run func(interface{}) error) return _c } -// Size provides a mock function with given fields: +// Size provides a mock function with no fields func (_m *MockRequestQueue) Size() int { ret := _m.Called() diff --git a/ocppj/mocks/mock_ResponseHandler.go b/ocppj/mocks/mock_ResponseHandler.go new file mode 100644 index 00000000..038f3a96 --- /dev/null +++ b/ocppj/mocks/mock_ResponseHandler.go @@ -0,0 +1,72 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockResponseHandler is an autogenerated mock type for the ResponseHandler type +type MockResponseHandler struct { + mock.Mock +} + +type MockResponseHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockResponseHandler) EXPECT() *MockResponseHandler_Expecter { + return &MockResponseHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: client, response, requestId +func (_m *MockResponseHandler) Execute(client ws.Channel, response ocpp.Response, requestId string) { + _m.Called(client, response, requestId) +} + +// MockResponseHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockResponseHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - client ws.Channel +// - response ocpp.Response +// - requestId string +func (_e *MockResponseHandler_Expecter) Execute(client interface{}, response interface{}, requestId interface{}) *MockResponseHandler_Execute_Call { + return &MockResponseHandler_Execute_Call{Call: _e.mock.On("Execute", client, response, requestId)} +} + +func (_c *MockResponseHandler_Execute_Call) Run(run func(client ws.Channel, response ocpp.Response, requestId string)) *MockResponseHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.Channel), args[1].(ocpp.Response), args[2].(string)) + }) + return _c +} + +func (_c *MockResponseHandler_Execute_Call) Return() *MockResponseHandler_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *MockResponseHandler_Execute_Call) RunAndReturn(run func(ws.Channel, ocpp.Response, string)) *MockResponseHandler_Execute_Call { + _c.Run(run) + return _c +} + +// NewMockResponseHandler creates a new instance of MockResponseHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockResponseHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockResponseHandler { + mock := &MockResponseHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_ServerDispatcher.go b/ocppj/mocks/mock_ServerDispatcher.go new file mode 100644 index 00000000..6ea739c4 --- /dev/null +++ b/ocppj/mocks/mock_ServerDispatcher.go @@ -0,0 +1,427 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocppj "github.com/lorenzodonini/ocpp-go/ocppj" + mock "github.com/stretchr/testify/mock" + + time "time" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockServerDispatcher is an autogenerated mock type for the ServerDispatcher type +type MockServerDispatcher struct { + mock.Mock +} + +type MockServerDispatcher_Expecter struct { + mock *mock.Mock +} + +func (_m *MockServerDispatcher) EXPECT() *MockServerDispatcher_Expecter { + return &MockServerDispatcher_Expecter{mock: &_m.Mock} +} + +// CompleteRequest provides a mock function with given fields: clientID, requestID +func (_m *MockServerDispatcher) CompleteRequest(clientID string, requestID string) { + _m.Called(clientID, requestID) +} + +// MockServerDispatcher_CompleteRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CompleteRequest' +type MockServerDispatcher_CompleteRequest_Call struct { + *mock.Call +} + +// CompleteRequest is a helper method to define mock.On call +// - clientID string +// - requestID string +func (_e *MockServerDispatcher_Expecter) CompleteRequest(clientID interface{}, requestID interface{}) *MockServerDispatcher_CompleteRequest_Call { + return &MockServerDispatcher_CompleteRequest_Call{Call: _e.mock.On("CompleteRequest", clientID, requestID)} +} + +func (_c *MockServerDispatcher_CompleteRequest_Call) Run(run func(clientID string, requestID string)) *MockServerDispatcher_CompleteRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *MockServerDispatcher_CompleteRequest_Call) Return() *MockServerDispatcher_CompleteRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_CompleteRequest_Call) RunAndReturn(run func(string, string)) *MockServerDispatcher_CompleteRequest_Call { + _c.Run(run) + return _c +} + +// CreateClient provides a mock function with given fields: clientID +func (_m *MockServerDispatcher) CreateClient(clientID string) { + _m.Called(clientID) +} + +// MockServerDispatcher_CreateClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateClient' +type MockServerDispatcher_CreateClient_Call struct { + *mock.Call +} + +// CreateClient is a helper method to define mock.On call +// - clientID string +func (_e *MockServerDispatcher_Expecter) CreateClient(clientID interface{}) *MockServerDispatcher_CreateClient_Call { + return &MockServerDispatcher_CreateClient_Call{Call: _e.mock.On("CreateClient", clientID)} +} + +func (_c *MockServerDispatcher_CreateClient_Call) Run(run func(clientID string)) *MockServerDispatcher_CreateClient_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerDispatcher_CreateClient_Call) Return() *MockServerDispatcher_CreateClient_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_CreateClient_Call) RunAndReturn(run func(string)) *MockServerDispatcher_CreateClient_Call { + _c.Run(run) + return _c +} + +// DeleteClient provides a mock function with given fields: clientID +func (_m *MockServerDispatcher) DeleteClient(clientID string) { + _m.Called(clientID) +} + +// MockServerDispatcher_DeleteClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteClient' +type MockServerDispatcher_DeleteClient_Call struct { + *mock.Call +} + +// DeleteClient is a helper method to define mock.On call +// - clientID string +func (_e *MockServerDispatcher_Expecter) DeleteClient(clientID interface{}) *MockServerDispatcher_DeleteClient_Call { + return &MockServerDispatcher_DeleteClient_Call{Call: _e.mock.On("DeleteClient", clientID)} +} + +func (_c *MockServerDispatcher_DeleteClient_Call) Run(run func(clientID string)) *MockServerDispatcher_DeleteClient_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerDispatcher_DeleteClient_Call) Return() *MockServerDispatcher_DeleteClient_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_DeleteClient_Call) RunAndReturn(run func(string)) *MockServerDispatcher_DeleteClient_Call { + _c.Run(run) + return _c +} + +// IsRunning provides a mock function with no fields +func (_m *MockServerDispatcher) IsRunning() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockServerDispatcher_IsRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRunning' +type MockServerDispatcher_IsRunning_Call struct { + *mock.Call +} + +// IsRunning is a helper method to define mock.On call +func (_e *MockServerDispatcher_Expecter) IsRunning() *MockServerDispatcher_IsRunning_Call { + return &MockServerDispatcher_IsRunning_Call{Call: _e.mock.On("IsRunning")} +} + +func (_c *MockServerDispatcher_IsRunning_Call) Run(run func()) *MockServerDispatcher_IsRunning_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockServerDispatcher_IsRunning_Call) Return(_a0 bool) *MockServerDispatcher_IsRunning_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockServerDispatcher_IsRunning_Call) RunAndReturn(run func() bool) *MockServerDispatcher_IsRunning_Call { + _c.Call.Return(run) + return _c +} + +// SendRequest provides a mock function with given fields: clientID, req +func (_m *MockServerDispatcher) SendRequest(clientID string, req ocppj.RequestBundle) error { + ret := _m.Called(clientID, req) + + if len(ret) == 0 { + panic("no return value specified for SendRequest") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, ocppj.RequestBundle) error); ok { + r0 = rf(clientID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockServerDispatcher_SendRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendRequest' +type MockServerDispatcher_SendRequest_Call struct { + *mock.Call +} + +// SendRequest is a helper method to define mock.On call +// - clientID string +// - req ocppj.RequestBundle +func (_e *MockServerDispatcher_Expecter) SendRequest(clientID interface{}, req interface{}) *MockServerDispatcher_SendRequest_Call { + return &MockServerDispatcher_SendRequest_Call{Call: _e.mock.On("SendRequest", clientID, req)} +} + +func (_c *MockServerDispatcher_SendRequest_Call) Run(run func(clientID string, req ocppj.RequestBundle)) *MockServerDispatcher_SendRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(ocppj.RequestBundle)) + }) + return _c +} + +func (_c *MockServerDispatcher_SendRequest_Call) Return(_a0 error) *MockServerDispatcher_SendRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockServerDispatcher_SendRequest_Call) RunAndReturn(run func(string, ocppj.RequestBundle) error) *MockServerDispatcher_SendRequest_Call { + _c.Call.Return(run) + return _c +} + +// SetNetworkServer provides a mock function with given fields: server +func (_m *MockServerDispatcher) SetNetworkServer(server ws.WsServer) { + _m.Called(server) +} + +// MockServerDispatcher_SetNetworkServer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetNetworkServer' +type MockServerDispatcher_SetNetworkServer_Call struct { + *mock.Call +} + +// SetNetworkServer is a helper method to define mock.On call +// - server ws.WsServer +func (_e *MockServerDispatcher_Expecter) SetNetworkServer(server interface{}) *MockServerDispatcher_SetNetworkServer_Call { + return &MockServerDispatcher_SetNetworkServer_Call{Call: _e.mock.On("SetNetworkServer", server)} +} + +func (_c *MockServerDispatcher_SetNetworkServer_Call) Run(run func(server ws.WsServer)) *MockServerDispatcher_SetNetworkServer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.WsServer)) + }) + return _c +} + +func (_c *MockServerDispatcher_SetNetworkServer_Call) Return() *MockServerDispatcher_SetNetworkServer_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_SetNetworkServer_Call) RunAndReturn(run func(ws.WsServer)) *MockServerDispatcher_SetNetworkServer_Call { + _c.Run(run) + return _c +} + +// SetOnRequestCanceled provides a mock function with given fields: cb +func (_m *MockServerDispatcher) SetOnRequestCanceled(cb ocppj.CanceledRequestHandler) { + _m.Called(cb) +} + +// MockServerDispatcher_SetOnRequestCanceled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOnRequestCanceled' +type MockServerDispatcher_SetOnRequestCanceled_Call struct { + *mock.Call +} + +// SetOnRequestCanceled is a helper method to define mock.On call +// - cb ocppj.CanceledRequestHandler +func (_e *MockServerDispatcher_Expecter) SetOnRequestCanceled(cb interface{}) *MockServerDispatcher_SetOnRequestCanceled_Call { + return &MockServerDispatcher_SetOnRequestCanceled_Call{Call: _e.mock.On("SetOnRequestCanceled", cb)} +} + +func (_c *MockServerDispatcher_SetOnRequestCanceled_Call) Run(run func(cb ocppj.CanceledRequestHandler)) *MockServerDispatcher_SetOnRequestCanceled_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ocppj.CanceledRequestHandler)) + }) + return _c +} + +func (_c *MockServerDispatcher_SetOnRequestCanceled_Call) Return() *MockServerDispatcher_SetOnRequestCanceled_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_SetOnRequestCanceled_Call) RunAndReturn(run func(ocppj.CanceledRequestHandler)) *MockServerDispatcher_SetOnRequestCanceled_Call { + _c.Run(run) + return _c +} + +// SetPendingRequestState provides a mock function with given fields: stateHandler +func (_m *MockServerDispatcher) SetPendingRequestState(stateHandler ocppj.ServerState) { + _m.Called(stateHandler) +} + +// MockServerDispatcher_SetPendingRequestState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPendingRequestState' +type MockServerDispatcher_SetPendingRequestState_Call struct { + *mock.Call +} + +// SetPendingRequestState is a helper method to define mock.On call +// - stateHandler ocppj.ServerState +func (_e *MockServerDispatcher_Expecter) SetPendingRequestState(stateHandler interface{}) *MockServerDispatcher_SetPendingRequestState_Call { + return &MockServerDispatcher_SetPendingRequestState_Call{Call: _e.mock.On("SetPendingRequestState", stateHandler)} +} + +func (_c *MockServerDispatcher_SetPendingRequestState_Call) Run(run func(stateHandler ocppj.ServerState)) *MockServerDispatcher_SetPendingRequestState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ocppj.ServerState)) + }) + return _c +} + +func (_c *MockServerDispatcher_SetPendingRequestState_Call) Return() *MockServerDispatcher_SetPendingRequestState_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_SetPendingRequestState_Call) RunAndReturn(run func(ocppj.ServerState)) *MockServerDispatcher_SetPendingRequestState_Call { + _c.Run(run) + return _c +} + +// SetTimeout provides a mock function with given fields: timeout +func (_m *MockServerDispatcher) SetTimeout(timeout time.Duration) { + _m.Called(timeout) +} + +// MockServerDispatcher_SetTimeout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTimeout' +type MockServerDispatcher_SetTimeout_Call struct { + *mock.Call +} + +// SetTimeout is a helper method to define mock.On call +// - timeout time.Duration +func (_e *MockServerDispatcher_Expecter) SetTimeout(timeout interface{}) *MockServerDispatcher_SetTimeout_Call { + return &MockServerDispatcher_SetTimeout_Call{Call: _e.mock.On("SetTimeout", timeout)} +} + +func (_c *MockServerDispatcher_SetTimeout_Call) Run(run func(timeout time.Duration)) *MockServerDispatcher_SetTimeout_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration)) + }) + return _c +} + +func (_c *MockServerDispatcher_SetTimeout_Call) Return() *MockServerDispatcher_SetTimeout_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_SetTimeout_Call) RunAndReturn(run func(time.Duration)) *MockServerDispatcher_SetTimeout_Call { + _c.Run(run) + return _c +} + +// Start provides a mock function with no fields +func (_m *MockServerDispatcher) Start() { + _m.Called() +} + +// MockServerDispatcher_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type MockServerDispatcher_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +func (_e *MockServerDispatcher_Expecter) Start() *MockServerDispatcher_Start_Call { + return &MockServerDispatcher_Start_Call{Call: _e.mock.On("Start")} +} + +func (_c *MockServerDispatcher_Start_Call) Run(run func()) *MockServerDispatcher_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockServerDispatcher_Start_Call) Return() *MockServerDispatcher_Start_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_Start_Call) RunAndReturn(run func()) *MockServerDispatcher_Start_Call { + _c.Run(run) + return _c +} + +// Stop provides a mock function with no fields +func (_m *MockServerDispatcher) Stop() { + _m.Called() +} + +// MockServerDispatcher_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type MockServerDispatcher_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *MockServerDispatcher_Expecter) Stop() *MockServerDispatcher_Stop_Call { + return &MockServerDispatcher_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *MockServerDispatcher_Stop_Call) Run(run func()) *MockServerDispatcher_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockServerDispatcher_Stop_Call) Return() *MockServerDispatcher_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerDispatcher_Stop_Call) RunAndReturn(run func()) *MockServerDispatcher_Stop_Call { + _c.Run(run) + return _c +} + +// NewMockServerDispatcher creates a new instance of MockServerDispatcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockServerDispatcher(t interface { + mock.TestingT + Cleanup(func()) +}) *MockServerDispatcher { + mock := &MockServerDispatcher{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_ServerQueueMap.go b/ocppj/mocks/mock_ServerQueueMap.go index 50295818..d44b8cf7 100644 --- a/ocppj/mocks/mock_ServerQueueMap.go +++ b/ocppj/mocks/mock_ServerQueueMap.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks @@ -50,7 +50,7 @@ func (_c *MockServerQueueMap_Add_Call) Return() *MockServerQueueMap_Add_Call { } func (_c *MockServerQueueMap_Add_Call) RunAndReturn(run func(string, ocppj.RequestQueue)) *MockServerQueueMap_Add_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -160,7 +160,7 @@ func (_c *MockServerQueueMap_GetOrCreate_Call) RunAndReturn(run func(string) ocp return _c } -// Init provides a mock function with given fields: +// Init provides a mock function with no fields func (_m *MockServerQueueMap) Init() { _m.Called() } @@ -188,7 +188,7 @@ func (_c *MockServerQueueMap_Init_Call) Return() *MockServerQueueMap_Init_Call { } func (_c *MockServerQueueMap_Init_Call) RunAndReturn(run func()) *MockServerQueueMap_Init_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -221,7 +221,7 @@ func (_c *MockServerQueueMap_Remove_Call) Return() *MockServerQueueMap_Remove_Ca } func (_c *MockServerQueueMap_Remove_Call) RunAndReturn(run func(string)) *MockServerQueueMap_Remove_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/ocppj/mocks/mock_ServerState.go b/ocppj/mocks/mock_ServerState.go new file mode 100644 index 00000000..db612eee --- /dev/null +++ b/ocppj/mocks/mock_ServerState.go @@ -0,0 +1,310 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" + + ocppj "github.com/lorenzodonini/ocpp-go/ocppj" +) + +// MockServerState is an autogenerated mock type for the ServerState type +type MockServerState struct { + mock.Mock +} + +type MockServerState_Expecter struct { + mock *mock.Mock +} + +func (_m *MockServerState) EXPECT() *MockServerState_Expecter { + return &MockServerState_Expecter{mock: &_m.Mock} +} + +// AddPendingRequest provides a mock function with given fields: clientID, requestID, req +func (_m *MockServerState) AddPendingRequest(clientID string, requestID string, req ocpp.Request) { + _m.Called(clientID, requestID, req) +} + +// MockServerState_AddPendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddPendingRequest' +type MockServerState_AddPendingRequest_Call struct { + *mock.Call +} + +// AddPendingRequest is a helper method to define mock.On call +// - clientID string +// - requestID string +// - req ocpp.Request +func (_e *MockServerState_Expecter) AddPendingRequest(clientID interface{}, requestID interface{}, req interface{}) *MockServerState_AddPendingRequest_Call { + return &MockServerState_AddPendingRequest_Call{Call: _e.mock.On("AddPendingRequest", clientID, requestID, req)} +} + +func (_c *MockServerState_AddPendingRequest_Call) Run(run func(clientID string, requestID string, req ocpp.Request)) *MockServerState_AddPendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string), args[2].(ocpp.Request)) + }) + return _c +} + +func (_c *MockServerState_AddPendingRequest_Call) Return() *MockServerState_AddPendingRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerState_AddPendingRequest_Call) RunAndReturn(run func(string, string, ocpp.Request)) *MockServerState_AddPendingRequest_Call { + _c.Run(run) + return _c +} + +// ClearAllPendingRequests provides a mock function with no fields +func (_m *MockServerState) ClearAllPendingRequests() { + _m.Called() +} + +// MockServerState_ClearAllPendingRequests_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearAllPendingRequests' +type MockServerState_ClearAllPendingRequests_Call struct { + *mock.Call +} + +// ClearAllPendingRequests is a helper method to define mock.On call +func (_e *MockServerState_Expecter) ClearAllPendingRequests() *MockServerState_ClearAllPendingRequests_Call { + return &MockServerState_ClearAllPendingRequests_Call{Call: _e.mock.On("ClearAllPendingRequests")} +} + +func (_c *MockServerState_ClearAllPendingRequests_Call) Run(run func()) *MockServerState_ClearAllPendingRequests_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockServerState_ClearAllPendingRequests_Call) Return() *MockServerState_ClearAllPendingRequests_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerState_ClearAllPendingRequests_Call) RunAndReturn(run func()) *MockServerState_ClearAllPendingRequests_Call { + _c.Run(run) + return _c +} + +// ClearClientPendingRequest provides a mock function with given fields: clientID +func (_m *MockServerState) ClearClientPendingRequest(clientID string) { + _m.Called(clientID) +} + +// MockServerState_ClearClientPendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClearClientPendingRequest' +type MockServerState_ClearClientPendingRequest_Call struct { + *mock.Call +} + +// ClearClientPendingRequest is a helper method to define mock.On call +// - clientID string +func (_e *MockServerState_Expecter) ClearClientPendingRequest(clientID interface{}) *MockServerState_ClearClientPendingRequest_Call { + return &MockServerState_ClearClientPendingRequest_Call{Call: _e.mock.On("ClearClientPendingRequest", clientID)} +} + +func (_c *MockServerState_ClearClientPendingRequest_Call) Run(run func(clientID string)) *MockServerState_ClearClientPendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerState_ClearClientPendingRequest_Call) Return() *MockServerState_ClearClientPendingRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerState_ClearClientPendingRequest_Call) RunAndReturn(run func(string)) *MockServerState_ClearClientPendingRequest_Call { + _c.Run(run) + return _c +} + +// DeletePendingRequest provides a mock function with given fields: clientID, requestID +func (_m *MockServerState) DeletePendingRequest(clientID string, requestID string) { + _m.Called(clientID, requestID) +} + +// MockServerState_DeletePendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeletePendingRequest' +type MockServerState_DeletePendingRequest_Call struct { + *mock.Call +} + +// DeletePendingRequest is a helper method to define mock.On call +// - clientID string +// - requestID string +func (_e *MockServerState_Expecter) DeletePendingRequest(clientID interface{}, requestID interface{}) *MockServerState_DeletePendingRequest_Call { + return &MockServerState_DeletePendingRequest_Call{Call: _e.mock.On("DeletePendingRequest", clientID, requestID)} +} + +func (_c *MockServerState_DeletePendingRequest_Call) Run(run func(clientID string, requestID string)) *MockServerState_DeletePendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *MockServerState_DeletePendingRequest_Call) Return() *MockServerState_DeletePendingRequest_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerState_DeletePendingRequest_Call) RunAndReturn(run func(string, string)) *MockServerState_DeletePendingRequest_Call { + _c.Run(run) + return _c +} + +// GetClientState provides a mock function with given fields: clientID +func (_m *MockServerState) GetClientState(clientID string) ocppj.ClientState { + ret := _m.Called(clientID) + + if len(ret) == 0 { + panic("no return value specified for GetClientState") + } + + var r0 ocppj.ClientState + if rf, ok := ret.Get(0).(func(string) ocppj.ClientState); ok { + r0 = rf(clientID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(ocppj.ClientState) + } + } + + return r0 +} + +// MockServerState_GetClientState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClientState' +type MockServerState_GetClientState_Call struct { + *mock.Call +} + +// GetClientState is a helper method to define mock.On call +// - clientID string +func (_e *MockServerState_Expecter) GetClientState(clientID interface{}) *MockServerState_GetClientState_Call { + return &MockServerState_GetClientState_Call{Call: _e.mock.On("GetClientState", clientID)} +} + +func (_c *MockServerState_GetClientState_Call) Run(run func(clientID string)) *MockServerState_GetClientState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerState_GetClientState_Call) Return(_a0 ocppj.ClientState) *MockServerState_GetClientState_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockServerState_GetClientState_Call) RunAndReturn(run func(string) ocppj.ClientState) *MockServerState_GetClientState_Call { + _c.Call.Return(run) + return _c +} + +// HasPendingRequest provides a mock function with given fields: clientID +func (_m *MockServerState) HasPendingRequest(clientID string) bool { + ret := _m.Called(clientID) + + if len(ret) == 0 { + panic("no return value specified for HasPendingRequest") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(clientID) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockServerState_HasPendingRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasPendingRequest' +type MockServerState_HasPendingRequest_Call struct { + *mock.Call +} + +// HasPendingRequest is a helper method to define mock.On call +// - clientID string +func (_e *MockServerState_Expecter) HasPendingRequest(clientID interface{}) *MockServerState_HasPendingRequest_Call { + return &MockServerState_HasPendingRequest_Call{Call: _e.mock.On("HasPendingRequest", clientID)} +} + +func (_c *MockServerState_HasPendingRequest_Call) Run(run func(clientID string)) *MockServerState_HasPendingRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerState_HasPendingRequest_Call) Return(_a0 bool) *MockServerState_HasPendingRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockServerState_HasPendingRequest_Call) RunAndReturn(run func(string) bool) *MockServerState_HasPendingRequest_Call { + _c.Call.Return(run) + return _c +} + +// HasPendingRequests provides a mock function with no fields +func (_m *MockServerState) HasPendingRequests() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HasPendingRequests") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockServerState_HasPendingRequests_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasPendingRequests' +type MockServerState_HasPendingRequests_Call struct { + *mock.Call +} + +// HasPendingRequests is a helper method to define mock.On call +func (_e *MockServerState_Expecter) HasPendingRequests() *MockServerState_HasPendingRequests_Call { + return &MockServerState_HasPendingRequests_Call{Call: _e.mock.On("HasPendingRequests")} +} + +func (_c *MockServerState_HasPendingRequests_Call) Run(run func()) *MockServerState_HasPendingRequests_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockServerState_HasPendingRequests_Call) Return(_a0 bool) *MockServerState_HasPendingRequests_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockServerState_HasPendingRequests_Call) RunAndReturn(run func() bool) *MockServerState_HasPendingRequests_Call { + _c.Call.Return(run) + return _c +} + +// NewMockServerState creates a new instance of MockServerState. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockServerState(t interface { + mock.TestingT + Cleanup(func()) +}) *MockServerState { + mock := &MockServerState{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocppj/mocks/mock_dialector.go b/ocppj/mocks/mock_dialector.go new file mode 100644 index 00000000..0d12e982 --- /dev/null +++ b/ocppj/mocks/mock_dialector.go @@ -0,0 +1,80 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + ocpp "github.com/lorenzodonini/ocpp-go/ocpp" + mock "github.com/stretchr/testify/mock" +) + +// Mockdialector is an autogenerated mock type for the dialector type +type Mockdialector struct { + mock.Mock +} + +type Mockdialector_Expecter struct { + mock *mock.Mock +} + +func (_m *Mockdialector) EXPECT() *Mockdialector_Expecter { + return &Mockdialector_Expecter{mock: &_m.Mock} +} + +// Dialect provides a mock function with no fields +func (_m *Mockdialector) Dialect() ocpp.Dialect { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Dialect") + } + + var r0 ocpp.Dialect + if rf, ok := ret.Get(0).(func() ocpp.Dialect); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(ocpp.Dialect) + } + + return r0 +} + +// Mockdialector_Dialect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Dialect' +type Mockdialector_Dialect_Call struct { + *mock.Call +} + +// Dialect is a helper method to define mock.On call +func (_e *Mockdialector_Expecter) Dialect() *Mockdialector_Dialect_Call { + return &Mockdialector_Dialect_Call{Call: _e.mock.On("Dialect")} +} + +func (_c *Mockdialector_Dialect_Call) Run(run func()) *Mockdialector_Dialect_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Mockdialector_Dialect_Call) Return(_a0 ocpp.Dialect) *Mockdialector_Dialect_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Mockdialector_Dialect_Call) RunAndReturn(run func() ocpp.Dialect) *Mockdialector_Dialect_Call { + _c.Call.Return(run) + return _c +} + +// NewMockdialector creates a new instance of Mockdialector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockdialector(t interface { + mock.TestingT + Cleanup(func()) +}) *Mockdialector { + mock := &Mockdialector{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ws/mocks/mock_Channel.go b/ws/mocks/mock_Channel.go index 1c3d4fbc..00d32e51 100644 --- a/ws/mocks/mock_Channel.go +++ b/ws/mocks/mock_Channel.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks @@ -23,7 +23,7 @@ func (_m *MockChannel) EXPECT() *MockChannel_Expecter { return &MockChannel_Expecter{mock: &_m.Mock} } -// ID provides a mock function with given fields: +// ID provides a mock function with no fields func (_m *MockChannel) ID() string { ret := _m.Called() @@ -68,7 +68,7 @@ func (_c *MockChannel_ID_Call) RunAndReturn(run func() string) *MockChannel_ID_C return _c } -// RemoteAddr provides a mock function with given fields: +// RemoteAddr provides a mock function with no fields func (_m *MockChannel) RemoteAddr() net.Addr { ret := _m.Called() @@ -115,7 +115,7 @@ func (_c *MockChannel_RemoteAddr_Call) RunAndReturn(run func() net.Addr) *MockCh return _c } -// TLSConnectionState provides a mock function with given fields: +// TLSConnectionState provides a mock function with no fields func (_m *MockChannel) TLSConnectionState() *tls.ConnectionState { ret := _m.Called() diff --git a/ws/mocks/mock_CheckClientHandler.go b/ws/mocks/mock_CheckClientHandler.go new file mode 100644 index 00000000..56e1d614 --- /dev/null +++ b/ws/mocks/mock_CheckClientHandler.go @@ -0,0 +1,83 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// MockCheckClientHandler is an autogenerated mock type for the CheckClientHandler type +type MockCheckClientHandler struct { + mock.Mock +} + +type MockCheckClientHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockCheckClientHandler) EXPECT() *MockCheckClientHandler_Expecter { + return &MockCheckClientHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: id, r +func (_m *MockCheckClientHandler) Execute(id string, r *http.Request) bool { + ret := _m.Called(id, r) + + if len(ret) == 0 { + panic("no return value specified for Execute") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string, *http.Request) bool); ok { + r0 = rf(id, r) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockCheckClientHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockCheckClientHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - id string +// - r *http.Request +func (_e *MockCheckClientHandler_Expecter) Execute(id interface{}, r interface{}) *MockCheckClientHandler_Execute_Call { + return &MockCheckClientHandler_Execute_Call{Call: _e.mock.On("Execute", id, r)} +} + +func (_c *MockCheckClientHandler_Execute_Call) Run(run func(id string, r *http.Request)) *MockCheckClientHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*http.Request)) + }) + return _c +} + +func (_c *MockCheckClientHandler_Execute_Call) Return(_a0 bool) *MockCheckClientHandler_Execute_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockCheckClientHandler_Execute_Call) RunAndReturn(run func(string, *http.Request) bool) *MockCheckClientHandler_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewMockCheckClientHandler creates a new instance of MockCheckClientHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockCheckClientHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockCheckClientHandler { + mock := &MockCheckClientHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ws/mocks/mock_WsClient.go b/ws/mocks/mock_WsClient.go index cdaa2e33..40a32fb9 100644 --- a/ws/mocks/mock_WsClient.go +++ b/ws/mocks/mock_WsClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks @@ -49,11 +49,11 @@ func (_c *MockWsClient_AddOption_Call) Return() *MockWsClient_AddOption_Call { } func (_c *MockWsClient_AddOption_Call) RunAndReturn(run func(interface{})) *MockWsClient_AddOption_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// Errors provides a mock function with given fields: +// Errors provides a mock function with no fields func (_m *MockWsClient) Errors() <-chan error { ret := _m.Called() @@ -100,7 +100,7 @@ func (_c *MockWsClient_Errors_Call) RunAndReturn(run func() <-chan error) *MockW return _c } -// IsConnected provides a mock function with given fields: +// IsConnected provides a mock function with no fields func (_m *MockWsClient) IsConnected() bool { ret := _m.Called() @@ -175,7 +175,7 @@ func (_c *MockWsClient_SetBasicAuth_Call) Return() *MockWsClient_SetBasicAuth_Ca } func (_c *MockWsClient_SetBasicAuth_Call) RunAndReturn(run func(string, string)) *MockWsClient_SetBasicAuth_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -208,7 +208,7 @@ func (_c *MockWsClient_SetDisconnectedHandler_Call) Return() *MockWsClient_SetDi } func (_c *MockWsClient_SetDisconnectedHandler_Call) RunAndReturn(run func(func(error))) *MockWsClient_SetDisconnectedHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -242,7 +242,7 @@ func (_c *MockWsClient_SetHeaderValue_Call) Return() *MockWsClient_SetHeaderValu } func (_c *MockWsClient_SetHeaderValue_Call) RunAndReturn(run func(string, string)) *MockWsClient_SetHeaderValue_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -275,7 +275,7 @@ func (_c *MockWsClient_SetMessageHandler_Call) Return() *MockWsClient_SetMessage } func (_c *MockWsClient_SetMessageHandler_Call) RunAndReturn(run func(func([]byte) error)) *MockWsClient_SetMessageHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -308,7 +308,7 @@ func (_c *MockWsClient_SetReconnectedHandler_Call) Return() *MockWsClient_SetRec } func (_c *MockWsClient_SetReconnectedHandler_Call) RunAndReturn(run func(func())) *MockWsClient_SetReconnectedHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -341,7 +341,7 @@ func (_c *MockWsClient_SetRequestedSubProtocol_Call) Return() *MockWsClient_SetR } func (_c *MockWsClient_SetRequestedSubProtocol_Call) RunAndReturn(run func(string)) *MockWsClient_SetRequestedSubProtocol_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -374,7 +374,7 @@ func (_c *MockWsClient_SetTimeoutConfig_Call) Return() *MockWsClient_SetTimeoutC } func (_c *MockWsClient_SetTimeoutConfig_Call) RunAndReturn(run func(ws.ClientTimeoutConfig)) *MockWsClient_SetTimeoutConfig_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -453,11 +453,11 @@ func (_c *MockWsClient_StartWithRetries_Call) Return() *MockWsClient_StartWithRe } func (_c *MockWsClient_StartWithRetries_Call) RunAndReturn(run func(string)) *MockWsClient_StartWithRetries_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// Stop provides a mock function with given fields: +// Stop provides a mock function with no fields func (_m *MockWsClient) Stop() { _m.Called() } @@ -485,7 +485,7 @@ func (_c *MockWsClient_Stop_Call) Return() *MockWsClient_Stop_Call { } func (_c *MockWsClient_Stop_Call) RunAndReturn(run func()) *MockWsClient_Stop_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/ws/mocks/mock_WsServer.go b/ws/mocks/mock_WsServer.go index 3fe68e4b..c382b211 100644 --- a/ws/mocks/mock_WsServer.go +++ b/ws/mocks/mock_WsServer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.51.0. DO NOT EDIT. package mocks @@ -55,11 +55,11 @@ func (_c *MockWsServer_AddSupportedSubprotocol_Call) Return() *MockWsServer_AddS } func (_c *MockWsServer_AddSupportedSubprotocol_Call) RunAndReturn(run func(string)) *MockWsServer_AddSupportedSubprotocol_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// Addr provides a mock function with given fields: +// Addr provides a mock function with no fields func (_m *MockWsServer) Addr() *net.TCPAddr { ret := _m.Called() @@ -106,7 +106,55 @@ func (_c *MockWsServer_Addr_Call) RunAndReturn(run func() *net.TCPAddr) *MockWsS return _c } -// Errors provides a mock function with given fields: +// Connections provides a mock function with given fields: websocketId +func (_m *MockWsServer) Connections(websocketId string) *ws.WebSocket { + ret := _m.Called(websocketId) + + if len(ret) == 0 { + panic("no return value specified for Connections") + } + + var r0 *ws.WebSocket + if rf, ok := ret.Get(0).(func(string) *ws.WebSocket); ok { + r0 = rf(websocketId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ws.WebSocket) + } + } + + return r0 +} + +// MockWsServer_Connections_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Connections' +type MockWsServer_Connections_Call struct { + *mock.Call +} + +// Connections is a helper method to define mock.On call +// - websocketId string +func (_e *MockWsServer_Expecter) Connections(websocketId interface{}) *MockWsServer_Connections_Call { + return &MockWsServer_Connections_Call{Call: _e.mock.On("Connections", websocketId)} +} + +func (_c *MockWsServer_Connections_Call) Run(run func(websocketId string)) *MockWsServer_Connections_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockWsServer_Connections_Call) Return(_a0 *ws.WebSocket) *MockWsServer_Connections_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsServer_Connections_Call) RunAndReturn(run func(string) *ws.WebSocket) *MockWsServer_Connections_Call { + _c.Call.Return(run) + return _c +} + +// Errors provides a mock function with no fields func (_m *MockWsServer) Errors() <-chan error { ret := _m.Called() @@ -182,7 +230,7 @@ func (_c *MockWsServer_SetBasicAuthHandler_Call) Return() *MockWsServer_SetBasic } func (_c *MockWsServer_SetBasicAuthHandler_Call) RunAndReturn(run func(func(string, string) bool)) *MockWsServer_SetBasicAuthHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -215,7 +263,7 @@ func (_c *MockWsServer_SetCheckClientHandler_Call) Return() *MockWsServer_SetChe } func (_c *MockWsServer_SetCheckClientHandler_Call) RunAndReturn(run func(func(string, *http.Request) bool)) *MockWsServer_SetCheckClientHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -248,7 +296,7 @@ func (_c *MockWsServer_SetCheckOriginHandler_Call) Return() *MockWsServer_SetChe } func (_c *MockWsServer_SetCheckOriginHandler_Call) RunAndReturn(run func(func(*http.Request) bool)) *MockWsServer_SetCheckOriginHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -281,7 +329,7 @@ func (_c *MockWsServer_SetDisconnectedClientHandler_Call) Return() *MockWsServer } func (_c *MockWsServer_SetDisconnectedClientHandler_Call) RunAndReturn(run func(func(ws.Channel))) *MockWsServer_SetDisconnectedClientHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -314,7 +362,7 @@ func (_c *MockWsServer_SetMessageHandler_Call) Return() *MockWsServer_SetMessage } func (_c *MockWsServer_SetMessageHandler_Call) RunAndReturn(run func(func(ws.Channel, []byte) error)) *MockWsServer_SetMessageHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -347,7 +395,7 @@ func (_c *MockWsServer_SetNewClientHandler_Call) Return() *MockWsServer_SetNewCl } func (_c *MockWsServer_SetNewClientHandler_Call) RunAndReturn(run func(func(ws.Channel))) *MockWsServer_SetNewClientHandler_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -380,7 +428,7 @@ func (_c *MockWsServer_SetTimeoutConfig_Call) Return() *MockWsServer_SetTimeoutC } func (_c *MockWsServer_SetTimeoutConfig_Call) RunAndReturn(run func(ws.ServerTimeoutConfig)) *MockWsServer_SetTimeoutConfig_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -414,11 +462,11 @@ func (_c *MockWsServer_Start_Call) Return() *MockWsServer_Start_Call { } func (_c *MockWsServer_Start_Call) RunAndReturn(run func(int, string)) *MockWsServer_Start_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// Stop provides a mock function with given fields: +// Stop provides a mock function with no fields func (_m *MockWsServer) Stop() { _m.Called() } @@ -446,7 +494,7 @@ func (_c *MockWsServer_Stop_Call) Return() *MockWsServer_Stop_Call { } func (_c *MockWsServer_Stop_Call) RunAndReturn(run func()) *MockWsServer_Stop_Call { - _c.Call.Return(run) + _c.Run(run) return _c }