diff --git a/.mockery.yaml b/.mockery.yaml new file mode 100644 index 00000000..a451b57a --- /dev/null +++ b/.mockery.yaml @@ -0,0 +1,139 @@ +with-expecter: true +dir: "{{.InterfaceDir}}/mocks" +outpkg: mocks +filename: "mock_{{.InterfaceName}}.go" +mockname: "Mock{{.InterfaceName}}" +all: true + +packages: + github.com/lorenzodonini/ocpp-go/ocpp1.6/core: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_core_{{.InterfaceName|snakecase}}.go" + mockname: "MockCore{{.InterfaceName}}" + interfaces: + CentralSystemHandler: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_certificates_{{.InterfaceName|snakecase}}.go" + mockname: "MockCertificates{{.InterfaceName}}" + + interfaces: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/logging: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_logging_{{.InterfaceName|snakecase}}.go" + mockname: "MockLog{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/extendedtriggermessage: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_extended_trigger_message_{{.InterfaceName|snakecase}}.go" + mockname: "MockExtendedTriggerMessage{{.InterfaceName}}" + + interfaces: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_firmware_{{.InterfaceName|snakecase}}.go" + mockname: "MockFirmware{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/localauth: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_local_auth_list_{{.InterfaceName|snakecase}}.go" + mockname: "MockLocalAuthList{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + + github.com/lorenzodonini/ocpp-go/ocpp1.6/remotetrigger: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_remote_trigger_{{.InterfaceName|snakecase}}.go" + mockname: "MockRemoteTrigger{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/reservation: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_reservation_{{.InterfaceName|snakecase}}.go" + mockname: "MockReservation{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + github.com/lorenzodonini/ocpp-go/ocpp1.6/securefirmware: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_secure_firmware_{{.InterfaceName}}.go" + mockname: "MockSecureFirmware{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + + github.com/lorenzodonini/ocpp-go/ocpp1.6/security: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_security_{{.InterfaceName|snakecase}}.go" + mockname: "MockSecurity{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + + github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_smart_charging_{{.InterfaceName|snakecase}}.go" + mockname: "MockSmartCharging{{.InterfaceName}}" + + interfaces: + CentralSystemHandler: + ChargePointHandler: + + + github.com/lorenzodonini/ocpp-go/ocpp1.6: + config: + dir: "ocpp1.6_test/mocks" + filename: "mock_ocpp16.go" + + interfaces: + ChargePointConnection: + ChargePoint: + CentralSystem: + + github.com/lorenzodonini/ocpp-go/ocppj: + interfaces: + ServerQueueMap: + RequestQueue: + + github.com/lorenzodonini/ocpp-go/ws: + interfaces: + WsClient: + WsServer: + Channel: \ No newline at end of file diff --git a/ocpp1.6/securefirmware/signed_update_firmware.go b/ocpp1.6/securefirmware/signed_update_firmware.go index b1a56a2e..d688d016 100644 --- a/ocpp1.6/securefirmware/signed_update_firmware.go +++ b/ocpp1.6/securefirmware/signed_update_firmware.go @@ -48,7 +48,7 @@ func isValidUpdateFirmwareStatus(fl validator.FieldLevel) bool { } } -// The field definition of the LogStatusNotification request payload sent by a Charging Station to the CSMS. +// The field definition of the SignedUpdateFirmwareRequest request payload sent by a Charging Station to the CSMS. type SignedUpdateFirmwareRequest struct { Retries *int `json:"retries,omitempty" validate:"omitempty,gte=0"` // This specifies how many times Charging Station must try to download the firmware before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry. RetryInterval *int `json:"retryInterval,omitempty" validate:"omitempty,gte=0"` // The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts. diff --git a/ocpp1.6_test/certificate_signed_test.go b/ocpp1.6_test/certificate_signed_test.go new file mode 100644 index 00000000..6eeb05d5 --- /dev/null +++ b/ocpp1.6_test/certificate_signed_test.go @@ -0,0 +1,84 @@ +package ocpp16_test + +import ( + "fmt" + + "github.com/lorenzodonini/ocpp-go/ocpp1.6/security" + "github.com/lorenzodonini/ocpp-go/ocpp1.6_test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func (suite *OcppV16TestSuite) TestCertificateSignedRequestValidation() { + t := suite.T() + var testTable = []GenericTestEntry{ + {security.CertificateSignedRequest{CertificateChain: "sampleCert"}, true}, + {security.CertificateSignedRequest{CertificateChain: ""}, false}, + {security.CertificateSignedRequest{}, false}, + {security.CertificateSignedRequest{CertificateChain: newLongString(100001)}, false}, + } + ExecuteGenericTestTable(t, testTable) +} + +func (suite *OcppV16TestSuite) TestCertificateSignedConfirmationValidation() { + t := suite.T() + var testTable = []GenericTestEntry{ + {security.CertificateSignedResponse{Status: security.CertificateSignedStatusAccepted}, true}, + {security.CertificateSignedResponse{Status: security.CertificateSignedStatusAccepted}, true}, + {security.CertificateSignedResponse{Status: security.CertificateSignedStatusRejected}, true}, + {security.CertificateSignedResponse{Status: "invalidCertificateSignedStatus"}, false}, + {security.CertificateSignedResponse{}, false}, + } + ExecuteGenericTestTable(t, testTable) +} + +// Test +func (suite *OcppV16TestSuite) TestCertificateSignedE2EMocked() { + t := suite.T() + wsId := "test_id" + messageId := defaultMessageId + wsUrl := "someUrl" + certificateChain := "someX509CertificateChain" + status := security.CertificateSignedStatusAccepted + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateChain":"%v"}]`, messageId, security.CertificateSignedFeatureName, certificateChain) + responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v"}]`, messageId, status) + certificateSignedConfirmation := security.NewCertificateSignedResponse(status) + channel := NewMockWebSocket(wsId) + + // Setting handlers + handler := mocks.NewMockSecurityChargePointHandler(t) + handler.EXPECT().OnCertificateSigned(mock.Anything).RunAndReturn(func(request *security.CertificateSignedRequest) (*security.CertificateSignedResponse, error) { + assert.Equal(t, certificateChain, request.CertificateChain) + return certificateSignedConfirmation, nil + }) + + setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true}) + setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true}) + + // Run Test + suite.centralSystem.Start(8887, "somePath") + suite.chargePoint.SetSecurityHandler(handler) + err := suite.chargePoint.Start(wsUrl) + require.Nil(t, err) + resultChannel := make(chan bool, 1) + err = suite.centralSystem.CertificateSigned(wsId, func(confirmation *security.CertificateSignedResponse, err error) { + require.Nil(t, err) + require.NotNil(t, confirmation) + assert.Equal(t, status, confirmation.Status) + resultChannel <- true + }, certificateChain, func(request *security.CertificateSignedRequest) { + request.CertificateChain = certificateChain + }) + require.Nil(t, err) + result := <-resultChannel + assert.True(t, result) +} + +func (suite *OcppV16TestSuite) TestCertificateSignedInvalidEndpoint() { + messageId := defaultMessageId + certificateChain := "someX509CertificateChain" + certificateSignedRequest := security.NewCertificateSignedRequest(certificateChain) + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateChain":"%v"}]`, messageId, security.CertificateSignedFeatureName, certificateChain) + testUnsupportedRequestFromChargePoint(suite, certificateSignedRequest, requestJson, messageId) +} diff --git a/ocpp1.6_test/delete_certificate_test.go b/ocpp1.6_test/delete_certificate_test.go new file mode 100644 index 00000000..7cdfb80c --- /dev/null +++ b/ocpp1.6_test/delete_certificate_test.go @@ -0,0 +1,88 @@ +package ocpp16_test + +import ( + "fmt" + + "github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" + "github.com/lorenzodonini/ocpp-go/ocpp1.6_test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +// Test +func (suite *OcppV16TestSuite) TestDeleteCertificateRequestValidation() { + t := suite.T() + var requestTable = []GenericTestEntry{ + {certificates.DeleteCertificateRequest{CertificateHashData: types.CertificateHashData{HashAlgorithm: types.SHA256, IssuerNameHash: "hash00", IssuerKeyHash: "hash01", SerialNumber: "serial0"}}, true}, + {certificates.DeleteCertificateRequest{}, false}, + {certificates.DeleteCertificateRequest{CertificateHashData: types.CertificateHashData{HashAlgorithm: "invalidHashAlgorithm", IssuerNameHash: "hash00", IssuerKeyHash: "hash01", SerialNumber: "serial0"}}, false}, + } + ExecuteGenericTestTable(t, requestTable) +} + +func (suite *OcppV16TestSuite) TestDeleteCertificateConfirmationValidation() { + t := suite.T() + var confirmationTable = []GenericTestEntry{ + {certificates.DeleteCertificateResponse{Status: certificates.DeleteCertificateStatusAccepted}, true}, + {certificates.DeleteCertificateResponse{Status: certificates.DeleteCertificateStatusFailed}, true}, + {certificates.DeleteCertificateResponse{Status: certificates.DeleteCertificateStatusNotFound}, true}, + {certificates.DeleteCertificateResponse{Status: "invalidDeleteCertificateStatus"}, false}, + {certificates.DeleteCertificateResponse{}, false}, + } + ExecuteGenericTestTable(t, confirmationTable) +} + +func (suite *OcppV16TestSuite) TestDeleteCertificateE2EMocked() { + t := suite.T() + wsId := "test_id" + messageId := defaultMessageId + wsUrl := "someUrl" + certificateHashData := types.CertificateHashData{HashAlgorithm: types.SHA256, IssuerNameHash: "hash00", IssuerKeyHash: "hash01", SerialNumber: "serial0"} + status := certificates.DeleteCertificateStatusAccepted + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateHashData":{"hashAlgorithm":"%v","issuerNameHash":"%v","issuerKeyHash":"%v","serialNumber":"%v"}}]`, + messageId, certificates.DeleteCertificateFeatureName, certificateHashData.HashAlgorithm, certificateHashData.IssuerNameHash, certificateHashData.IssuerKeyHash, certificateHashData.SerialNumber) + responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v"}]`, messageId, status) + deleteCertificateConfirmation := certificates.NewDeleteCertificateResponse(status) + channel := NewMockWebSocket(wsId) + + handler := mocks.NewMockCertificatesChargePointHandler(t) + handler.EXPECT().OnDeleteCertificate(mock.Anything).RunAndReturn(func(request *certificates.DeleteCertificateRequest) (*certificates.DeleteCertificateResponse, error) { + assert.Equal(t, certificateHashData.HashAlgorithm, request.CertificateHashData.HashAlgorithm) + assert.Equal(t, certificateHashData.IssuerNameHash, request.CertificateHashData.IssuerNameHash) + assert.Equal(t, certificateHashData.IssuerKeyHash, request.CertificateHashData.IssuerKeyHash) + assert.Equal(t, certificateHashData.SerialNumber, request.CertificateHashData.SerialNumber) + return deleteCertificateConfirmation, nil + }) + + setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true}) + setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true}) + suite.chargePoint.SetCertificateHandler(handler) + + // Run Test + suite.centralSystem.Start(8887, "somePath") + err := suite.chargePoint.Start(wsUrl) + require.Nil(t, err) + + resultChannel := make(chan bool, 1) + err = suite.centralSystem.DeleteCertificate(wsId, func(confirmation *certificates.DeleteCertificateResponse, err error) { + require.Nil(t, err) + require.NotNil(t, confirmation) + assert.Equal(t, status, confirmation.Status) + resultChannel <- true + }, certificateHashData) + require.Nil(t, err) + + result := <-resultChannel + assert.True(t, result) +} + +func (suite *OcppV16TestSuite) TestDeleteCertificateInvalidEndpoint() { + messageId := defaultMessageId + certificateHashData := types.CertificateHashData{HashAlgorithm: types.SHA256, IssuerNameHash: "hash00", IssuerKeyHash: "hash01", SerialNumber: "serial0"} + deleteCertificateRequest := certificates.NewDeleteCertificateRequest(certificateHashData) + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateHashData":{"hashAlgorithm":"%v","issuerNameHash":"%v","issuerKeyHash":"%v","serialNumber":"%v"}}]`, + messageId, certificates.DeleteCertificateFeatureName, certificateHashData.HashAlgorithm, certificateHashData.IssuerNameHash, certificateHashData.IssuerKeyHash, certificateHashData.SerialNumber) + testUnsupportedRequestFromChargePoint(suite, deleteCertificateRequest, requestJson, messageId) +} diff --git a/ocpp1.6_test/get_installed_certificate_ids_test.go b/ocpp1.6_test/get_installed_certificate_ids_test.go new file mode 100644 index 00000000..36967b0c --- /dev/null +++ b/ocpp1.6_test/get_installed_certificate_ids_test.go @@ -0,0 +1,87 @@ +package ocpp16_test + +import ( + "fmt" + + "github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" + "github.com/lorenzodonini/ocpp-go/ocpp1.6_test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func (suite *OcppV16TestSuite) TestGetInstalledCertificateIdsRequestValidation() { + t := suite.T() + var testTable = []GenericTestEntry{ + {certificates.GetInstalledCertificateIdsRequest{CertificateType: types.CentralSystemRootCertificate}, true}, + {certificates.GetInstalledCertificateIdsRequest{}, false}, + {certificates.GetInstalledCertificateIdsRequest{CertificateType: "invalidCertificateUse"}, false}, + } + ExecuteGenericTestTable(t, testTable) +} + +func (suite *OcppV16TestSuite) TestGetInstalledCertificateIdsConfirmationValidation() { + t := suite.T() + var testTable = []GenericTestEntry{ + {certificates.GetInstalledCertificateIdsResponse{Status: certificates.GetInstalledCertificateStatusAccepted}, true}, + {certificates.GetInstalledCertificateIdsResponse{Status: certificates.GetInstalledCertificateStatusNotFound}, true}, + {certificates.GetInstalledCertificateIdsResponse{Status: certificates.GetInstalledCertificateStatusAccepted}, true}, + {certificates.GetInstalledCertificateIdsResponse{}, false}, + {certificates.GetInstalledCertificateIdsResponse{Status: "invalidGetInstalledCertificateStatus"}, false}, + } + ExecuteGenericTestTable(t, testTable) +} + +// Test +func (suite *OcppV16TestSuite) TestGetInstalledCertificateIdsE2EMocked() { + t := suite.T() + wsId := "test_id" + messageId := defaultMessageId + wsUrl := "someUrl" + certificateType := types.CentralSystemRootCertificate + status := certificates.GetInstalledCertificateStatusAccepted + + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateType":"%v"}]`, messageId, certificates.GetInstalledCertificateIdsFeatureName, certificateType) + responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v"}]`, + messageId, status) + getInstalledCertificateIdsConfirmation := certificates.NewGetInstalledCertificateIdsResponse(status) + channel := NewMockWebSocket(wsId) + + // Setting handlers + handler := mocks.NewMockCertificatesChargePointHandler(t) + handler.EXPECT().OnGetInstalledCertificateIds(mock.Anything).RunAndReturn(func(request *certificates.GetInstalledCertificateIdsRequest) (*certificates.GetInstalledCertificateIdsResponse, error) { + assert.Equal(t, certificateType, request.CertificateType) + return getInstalledCertificateIdsConfirmation, nil + }) + + setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true}) + setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true}) + suite.chargePoint.SetCertificateHandler(handler) + + // Run Test + suite.centralSystem.Start(8887, "somePath") + suite.chargePoint.SetCertificateHandler(handler) + err := suite.chargePoint.Start(wsUrl) + require.Nil(t, err) + resultChannel := make(chan bool, 1) + err = suite.centralSystem.GetInstalledCertificateIds(wsId, func(confirmation *certificates.GetInstalledCertificateIdsResponse, err error) { + require.Nil(t, err) + require.NotNil(t, confirmation) + assert.Equal(t, status, confirmation.Status) + resultChannel <- true + }, certificateType) + + require.Nil(t, err) + result := <-resultChannel + assert.True(t, result) +} + +func (suite *OcppV16TestSuite) TestGetInstalledCertificateIdsInvalidEndpoint() { + messageId := defaultMessageId + certificateType := types.CentralSystemRootCertificate + GetInstalledCertificateIdsRequest := certificates.NewGetInstalledCertificateIdsRequest(certificateType) + GetInstalledCertificateIdsRequest.CertificateType = certificateType + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateType":"%v"}]`, messageId, certificates.GetInstalledCertificateIdsFeatureName, certificateType) + testUnsupportedRequestFromChargePoint(suite, GetInstalledCertificateIdsRequest, requestJson, messageId) +} diff --git a/ocpp1.6_test/install_certificate_test.go b/ocpp1.6_test/install_certificate_test.go new file mode 100644 index 00000000..eca258c0 --- /dev/null +++ b/ocpp1.6_test/install_certificate_test.go @@ -0,0 +1,91 @@ +package ocpp16_test + +import ( + "fmt" + + "github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" + "github.com/lorenzodonini/ocpp-go/ocpp1.6_test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func (suite *OcppV16TestSuite) TestInstallCertificateRequestValidation() { + t := suite.T() + var testTable = []GenericTestEntry{ + {certificates.InstallCertificateRequest{CertificateType: types.ManufacturerRootCertificate, Certificate: "0xdeadbeef"}, true}, + {certificates.InstallCertificateRequest{CertificateType: types.ManufacturerRootCertificate}, false}, + {certificates.InstallCertificateRequest{CertificateType: types.CentralSystemRootCertificate, Certificate: "0xdeadbeef"}, true}, + {certificates.InstallCertificateRequest{CertificateType: types.CentralSystemRootCertificate, Certificate: ""}, false}, + {certificates.InstallCertificateRequest{Certificate: "0xdeadbeef"}, false}, + {certificates.InstallCertificateRequest{}, false}, + {certificates.InstallCertificateRequest{CertificateType: "invalidCertificateUse", Certificate: "0xdeadbeef"}, false}, + {certificates.InstallCertificateRequest{CertificateType: types.ManufacturerRootCertificate, Certificate: newLongString(5501)}, false}, + } + ExecuteGenericTestTable(t, testTable) +} + +func (suite *OcppV16TestSuite) TestInstallCertificateConfirmationValidation() { + t := suite.T() + var testTable = []GenericTestEntry{ + {certificates.InstallCertificateResponse{Status: certificates.CertificateStatusAccepted}, true}, + {certificates.InstallCertificateResponse{Status: certificates.CertificateStatusRejected}, true}, + {certificates.InstallCertificateResponse{Status: certificates.CertificateStatusFailed}, true}, + {certificates.InstallCertificateResponse{}, false}, + {certificates.InstallCertificateResponse{Status: "invalidInstallCertificateStatus"}, false}, + } + ExecuteGenericTestTable(t, testTable) +} + +// Test +func (suite *OcppV16TestSuite) TestInstallCertificateE2EMocked() { + t := suite.T() + wsId := "test_id" + messageId := defaultMessageId + wsUrl := "someUrl" + certificateType := types.CentralSystemRootCertificate + status := certificates.CertificateStatusAccepted + certificate := "0xdeadbeef" + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateType":"%v","certificate":"%v"}]`, messageId, certificates.InstallCertificateFeatureName, certificateType, certificate) + responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v"}]`, messageId, status) + installCertificateResponse := certificates.NewInstallCertificateResponse(status) + channel := NewMockWebSocket(wsId) + + // Setting handlers + handler := mocks.NewMockCertificatesChargePointHandler(t) + handler.EXPECT().OnInstallCertificate(mock.Anything).RunAndReturn(func(request *certificates.InstallCertificateRequest) (*certificates.InstallCertificateResponse, error) { + assert.Equal(t, certificateType, request.CertificateType) + assert.Equal(t, certificate, request.Certificate) + return installCertificateResponse, nil + }) + + setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true}) + setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true}) + suite.chargePoint.SetCertificateHandler(handler) + + // Run Test + suite.centralSystem.Start(8887, "somePath") + suite.chargePoint.SetCertificateHandler(handler) + err := suite.chargePoint.Start(wsUrl) + require.Nil(t, err) + resultChannel := make(chan bool, 1) + err = suite.centralSystem.InstallCertificate(wsId, func(response *certificates.InstallCertificateResponse, err error) { + require.Nil(t, err) + require.NotNil(t, response) + assert.Equal(t, status, response.Status) + resultChannel <- true + }, certificateType, certificate) + require.Nil(t, err) + result := <-resultChannel + assert.True(t, result) +} + +func (suite *OcppV16TestSuite) TestInstallCertificateInvalidEndpoint() { + messageId := defaultMessageId + certificateType := types.CentralSystemRootCertificate + certificate := "0xdeadbeef" + installCertificateRequest := certificates.NewInstallCertificateRequest(certificateType, certificate) + requestJson := fmt.Sprintf(`[2,"%v","%v",{"certificateType":"%v","certificate":"%v"}]`, messageId, certificates.InstallCertificateFeatureName, certificateType, certificate) + testUnsupportedRequestFromChargePoint(suite, installCertificateRequest, requestJson, messageId) +} diff --git a/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go b/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go new file mode 100644 index 00000000..a0bfeaa9 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_certificates_charge_point_handler.go @@ -0,0 +1,209 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + certificates "github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates" + mock "github.com/stretchr/testify/mock" +) + +// MockCertificatesChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockCertificatesChargePointHandler struct { + mock.Mock +} + +type MockCertificatesChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockCertificatesChargePointHandler) EXPECT() *MockCertificatesChargePointHandler_Expecter { + return &MockCertificatesChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnDeleteCertificate provides a mock function with given fields: request +func (_m *MockCertificatesChargePointHandler) OnDeleteCertificate(request *certificates.DeleteCertificateRequest) (*certificates.DeleteCertificateResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnDeleteCertificate") + } + + var r0 *certificates.DeleteCertificateResponse + var r1 error + if rf, ok := ret.Get(0).(func(*certificates.DeleteCertificateRequest) (*certificates.DeleteCertificateResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*certificates.DeleteCertificateRequest) *certificates.DeleteCertificateResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*certificates.DeleteCertificateResponse) + } + } + + if rf, ok := ret.Get(1).(func(*certificates.DeleteCertificateRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCertificatesChargePointHandler_OnDeleteCertificate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnDeleteCertificate' +type MockCertificatesChargePointHandler_OnDeleteCertificate_Call struct { + *mock.Call +} + +// OnDeleteCertificate is a helper method to define mock.On call +// - request *certificates.DeleteCertificateRequest +func (_e *MockCertificatesChargePointHandler_Expecter) OnDeleteCertificate(request interface{}) *MockCertificatesChargePointHandler_OnDeleteCertificate_Call { + return &MockCertificatesChargePointHandler_OnDeleteCertificate_Call{Call: _e.mock.On("OnDeleteCertificate", request)} +} + +func (_c *MockCertificatesChargePointHandler_OnDeleteCertificate_Call) Run(run func(request *certificates.DeleteCertificateRequest)) *MockCertificatesChargePointHandler_OnDeleteCertificate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*certificates.DeleteCertificateRequest)) + }) + return _c +} + +func (_c *MockCertificatesChargePointHandler_OnDeleteCertificate_Call) Return(response *certificates.DeleteCertificateResponse, err error) *MockCertificatesChargePointHandler_OnDeleteCertificate_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockCertificatesChargePointHandler_OnDeleteCertificate_Call) RunAndReturn(run func(*certificates.DeleteCertificateRequest) (*certificates.DeleteCertificateResponse, error)) *MockCertificatesChargePointHandler_OnDeleteCertificate_Call { + _c.Call.Return(run) + return _c +} + +// OnGetInstalledCertificateIds provides a mock function with given fields: request +func (_m *MockCertificatesChargePointHandler) OnGetInstalledCertificateIds(request *certificates.GetInstalledCertificateIdsRequest) (*certificates.GetInstalledCertificateIdsResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnGetInstalledCertificateIds") + } + + var r0 *certificates.GetInstalledCertificateIdsResponse + var r1 error + if rf, ok := ret.Get(0).(func(*certificates.GetInstalledCertificateIdsRequest) (*certificates.GetInstalledCertificateIdsResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*certificates.GetInstalledCertificateIdsRequest) *certificates.GetInstalledCertificateIdsResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*certificates.GetInstalledCertificateIdsResponse) + } + } + + if rf, ok := ret.Get(1).(func(*certificates.GetInstalledCertificateIdsRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnGetInstalledCertificateIds' +type MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call struct { + *mock.Call +} + +// OnGetInstalledCertificateIds is a helper method to define mock.On call +// - request *certificates.GetInstalledCertificateIdsRequest +func (_e *MockCertificatesChargePointHandler_Expecter) OnGetInstalledCertificateIds(request interface{}) *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call { + return &MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call{Call: _e.mock.On("OnGetInstalledCertificateIds", request)} +} + +func (_c *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call) Run(run func(request *certificates.GetInstalledCertificateIdsRequest)) *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*certificates.GetInstalledCertificateIdsRequest)) + }) + return _c +} + +func (_c *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call) Return(response *certificates.GetInstalledCertificateIdsResponse, err error) *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call) RunAndReturn(run func(*certificates.GetInstalledCertificateIdsRequest) (*certificates.GetInstalledCertificateIdsResponse, error)) *MockCertificatesChargePointHandler_OnGetInstalledCertificateIds_Call { + _c.Call.Return(run) + return _c +} + +// OnInstallCertificate provides a mock function with given fields: request +func (_m *MockCertificatesChargePointHandler) OnInstallCertificate(request *certificates.InstallCertificateRequest) (*certificates.InstallCertificateResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnInstallCertificate") + } + + var r0 *certificates.InstallCertificateResponse + var r1 error + if rf, ok := ret.Get(0).(func(*certificates.InstallCertificateRequest) (*certificates.InstallCertificateResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*certificates.InstallCertificateRequest) *certificates.InstallCertificateResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*certificates.InstallCertificateResponse) + } + } + + if rf, ok := ret.Get(1).(func(*certificates.InstallCertificateRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCertificatesChargePointHandler_OnInstallCertificate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnInstallCertificate' +type MockCertificatesChargePointHandler_OnInstallCertificate_Call struct { + *mock.Call +} + +// OnInstallCertificate is a helper method to define mock.On call +// - request *certificates.InstallCertificateRequest +func (_e *MockCertificatesChargePointHandler_Expecter) OnInstallCertificate(request interface{}) *MockCertificatesChargePointHandler_OnInstallCertificate_Call { + return &MockCertificatesChargePointHandler_OnInstallCertificate_Call{Call: _e.mock.On("OnInstallCertificate", request)} +} + +func (_c *MockCertificatesChargePointHandler_OnInstallCertificate_Call) Run(run func(request *certificates.InstallCertificateRequest)) *MockCertificatesChargePointHandler_OnInstallCertificate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*certificates.InstallCertificateRequest)) + }) + return _c +} + +func (_c *MockCertificatesChargePointHandler_OnInstallCertificate_Call) Return(response *certificates.InstallCertificateResponse, err error) *MockCertificatesChargePointHandler_OnInstallCertificate_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockCertificatesChargePointHandler_OnInstallCertificate_Call) RunAndReturn(run func(*certificates.InstallCertificateRequest) (*certificates.InstallCertificateResponse, error)) *MockCertificatesChargePointHandler_OnInstallCertificate_Call { + _c.Call.Return(run) + return _c +} + +// NewMockCertificatesChargePointHandler creates a new instance of MockCertificatesChargePointHandler. 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 NewMockCertificatesChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockCertificatesChargePointHandler { + mock := &MockCertificatesChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_core_central_system_handler.go b/ocpp1.6_test/mocks/mock_core_central_system_handler.go new file mode 100644 index 00000000..2f200d07 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_core_central_system_handler.go @@ -0,0 +1,507 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + core "github.com/lorenzodonini/ocpp-go/ocpp1.6/core" + mock "github.com/stretchr/testify/mock" +) + +// MockCoreCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockCoreCentralSystemHandler struct { + mock.Mock +} + +type MockCoreCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockCoreCentralSystemHandler) EXPECT() *MockCoreCentralSystemHandler_Expecter { + return &MockCoreCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// OnAuthorize provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnAuthorize(chargePointId string, request *core.AuthorizeRequest) (*core.AuthorizeConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnAuthorize") + } + + var r0 *core.AuthorizeConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.AuthorizeRequest) (*core.AuthorizeConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.AuthorizeRequest) *core.AuthorizeConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.AuthorizeConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.AuthorizeRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnAuthorize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnAuthorize' +type MockCoreCentralSystemHandler_OnAuthorize_Call struct { + *mock.Call +} + +// OnAuthorize is a helper method to define mock.On call +// - chargePointId string +// - request *core.AuthorizeRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnAuthorize(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnAuthorize_Call { + return &MockCoreCentralSystemHandler_OnAuthorize_Call{Call: _e.mock.On("OnAuthorize", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnAuthorize_Call) Run(run func(chargePointId string, request *core.AuthorizeRequest)) *MockCoreCentralSystemHandler_OnAuthorize_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.AuthorizeRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnAuthorize_Call) Return(confirmation *core.AuthorizeConfirmation, err error) *MockCoreCentralSystemHandler_OnAuthorize_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnAuthorize_Call) RunAndReturn(run func(string, *core.AuthorizeRequest) (*core.AuthorizeConfirmation, error)) *MockCoreCentralSystemHandler_OnAuthorize_Call { + _c.Call.Return(run) + return _c +} + +// OnBootNotification provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnBootNotification(chargePointId string, request *core.BootNotificationRequest) (*core.BootNotificationConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnBootNotification") + } + + var r0 *core.BootNotificationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.BootNotificationRequest) (*core.BootNotificationConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.BootNotificationRequest) *core.BootNotificationConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.BootNotificationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.BootNotificationRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnBootNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnBootNotification' +type MockCoreCentralSystemHandler_OnBootNotification_Call struct { + *mock.Call +} + +// OnBootNotification is a helper method to define mock.On call +// - chargePointId string +// - request *core.BootNotificationRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnBootNotification(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnBootNotification_Call { + return &MockCoreCentralSystemHandler_OnBootNotification_Call{Call: _e.mock.On("OnBootNotification", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnBootNotification_Call) Run(run func(chargePointId string, request *core.BootNotificationRequest)) *MockCoreCentralSystemHandler_OnBootNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.BootNotificationRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnBootNotification_Call) Return(confirmation *core.BootNotificationConfirmation, err error) *MockCoreCentralSystemHandler_OnBootNotification_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnBootNotification_Call) RunAndReturn(run func(string, *core.BootNotificationRequest) (*core.BootNotificationConfirmation, error)) *MockCoreCentralSystemHandler_OnBootNotification_Call { + _c.Call.Return(run) + return _c +} + +// OnDataTransfer provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnDataTransfer(chargePointId string, request *core.DataTransferRequest) (*core.DataTransferConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnDataTransfer") + } + + var r0 *core.DataTransferConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.DataTransferRequest) (*core.DataTransferConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.DataTransferRequest) *core.DataTransferConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.DataTransferConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.DataTransferRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnDataTransfer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnDataTransfer' +type MockCoreCentralSystemHandler_OnDataTransfer_Call struct { + *mock.Call +} + +// OnDataTransfer is a helper method to define mock.On call +// - chargePointId string +// - request *core.DataTransferRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnDataTransfer(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnDataTransfer_Call { + return &MockCoreCentralSystemHandler_OnDataTransfer_Call{Call: _e.mock.On("OnDataTransfer", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnDataTransfer_Call) Run(run func(chargePointId string, request *core.DataTransferRequest)) *MockCoreCentralSystemHandler_OnDataTransfer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.DataTransferRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnDataTransfer_Call) Return(confirmation *core.DataTransferConfirmation, err error) *MockCoreCentralSystemHandler_OnDataTransfer_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnDataTransfer_Call) RunAndReturn(run func(string, *core.DataTransferRequest) (*core.DataTransferConfirmation, error)) *MockCoreCentralSystemHandler_OnDataTransfer_Call { + _c.Call.Return(run) + return _c +} + +// OnHeartbeat provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnHeartbeat(chargePointId string, request *core.HeartbeatRequest) (*core.HeartbeatConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnHeartbeat") + } + + var r0 *core.HeartbeatConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.HeartbeatRequest) (*core.HeartbeatConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.HeartbeatRequest) *core.HeartbeatConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.HeartbeatConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.HeartbeatRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnHeartbeat' +type MockCoreCentralSystemHandler_OnHeartbeat_Call struct { + *mock.Call +} + +// OnHeartbeat is a helper method to define mock.On call +// - chargePointId string +// - request *core.HeartbeatRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnHeartbeat(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnHeartbeat_Call { + return &MockCoreCentralSystemHandler_OnHeartbeat_Call{Call: _e.mock.On("OnHeartbeat", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnHeartbeat_Call) Run(run func(chargePointId string, request *core.HeartbeatRequest)) *MockCoreCentralSystemHandler_OnHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.HeartbeatRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnHeartbeat_Call) Return(confirmation *core.HeartbeatConfirmation, err error) *MockCoreCentralSystemHandler_OnHeartbeat_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnHeartbeat_Call) RunAndReturn(run func(string, *core.HeartbeatRequest) (*core.HeartbeatConfirmation, error)) *MockCoreCentralSystemHandler_OnHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// OnMeterValues provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnMeterValues(chargePointId string, request *core.MeterValuesRequest) (*core.MeterValuesConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnMeterValues") + } + + var r0 *core.MeterValuesConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.MeterValuesRequest) (*core.MeterValuesConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.MeterValuesRequest) *core.MeterValuesConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.MeterValuesConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.MeterValuesRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnMeterValues_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnMeterValues' +type MockCoreCentralSystemHandler_OnMeterValues_Call struct { + *mock.Call +} + +// OnMeterValues is a helper method to define mock.On call +// - chargePointId string +// - request *core.MeterValuesRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnMeterValues(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnMeterValues_Call { + return &MockCoreCentralSystemHandler_OnMeterValues_Call{Call: _e.mock.On("OnMeterValues", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnMeterValues_Call) Run(run func(chargePointId string, request *core.MeterValuesRequest)) *MockCoreCentralSystemHandler_OnMeterValues_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.MeterValuesRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnMeterValues_Call) Return(confirmation *core.MeterValuesConfirmation, err error) *MockCoreCentralSystemHandler_OnMeterValues_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnMeterValues_Call) RunAndReturn(run func(string, *core.MeterValuesRequest) (*core.MeterValuesConfirmation, error)) *MockCoreCentralSystemHandler_OnMeterValues_Call { + _c.Call.Return(run) + return _c +} + +// OnStartTransaction provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnStartTransaction(chargePointId string, request *core.StartTransactionRequest) (*core.StartTransactionConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnStartTransaction") + } + + var r0 *core.StartTransactionConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.StartTransactionRequest) (*core.StartTransactionConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.StartTransactionRequest) *core.StartTransactionConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.StartTransactionConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.StartTransactionRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnStartTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnStartTransaction' +type MockCoreCentralSystemHandler_OnStartTransaction_Call struct { + *mock.Call +} + +// OnStartTransaction is a helper method to define mock.On call +// - chargePointId string +// - request *core.StartTransactionRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnStartTransaction(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnStartTransaction_Call { + return &MockCoreCentralSystemHandler_OnStartTransaction_Call{Call: _e.mock.On("OnStartTransaction", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnStartTransaction_Call) Run(run func(chargePointId string, request *core.StartTransactionRequest)) *MockCoreCentralSystemHandler_OnStartTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.StartTransactionRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnStartTransaction_Call) Return(confirmation *core.StartTransactionConfirmation, err error) *MockCoreCentralSystemHandler_OnStartTransaction_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnStartTransaction_Call) RunAndReturn(run func(string, *core.StartTransactionRequest) (*core.StartTransactionConfirmation, error)) *MockCoreCentralSystemHandler_OnStartTransaction_Call { + _c.Call.Return(run) + return _c +} + +// OnStatusNotification provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnStatusNotification(chargePointId string, request *core.StatusNotificationRequest) (*core.StatusNotificationConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnStatusNotification") + } + + var r0 *core.StatusNotificationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.StatusNotificationRequest) (*core.StatusNotificationConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.StatusNotificationRequest) *core.StatusNotificationConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.StatusNotificationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.StatusNotificationRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnStatusNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnStatusNotification' +type MockCoreCentralSystemHandler_OnStatusNotification_Call struct { + *mock.Call +} + +// OnStatusNotification is a helper method to define mock.On call +// - chargePointId string +// - request *core.StatusNotificationRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnStatusNotification(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnStatusNotification_Call { + return &MockCoreCentralSystemHandler_OnStatusNotification_Call{Call: _e.mock.On("OnStatusNotification", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnStatusNotification_Call) Run(run func(chargePointId string, request *core.StatusNotificationRequest)) *MockCoreCentralSystemHandler_OnStatusNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.StatusNotificationRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnStatusNotification_Call) Return(confirmation *core.StatusNotificationConfirmation, err error) *MockCoreCentralSystemHandler_OnStatusNotification_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnStatusNotification_Call) RunAndReturn(run func(string, *core.StatusNotificationRequest) (*core.StatusNotificationConfirmation, error)) *MockCoreCentralSystemHandler_OnStatusNotification_Call { + _c.Call.Return(run) + return _c +} + +// OnStopTransaction provides a mock function with given fields: chargePointId, request +func (_m *MockCoreCentralSystemHandler) OnStopTransaction(chargePointId string, request *core.StopTransactionRequest) (*core.StopTransactionConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnStopTransaction") + } + + var r0 *core.StopTransactionConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *core.StopTransactionRequest) (*core.StopTransactionConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *core.StopTransactionRequest) *core.StopTransactionConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.StopTransactionConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *core.StopTransactionRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreCentralSystemHandler_OnStopTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnStopTransaction' +type MockCoreCentralSystemHandler_OnStopTransaction_Call struct { + *mock.Call +} + +// OnStopTransaction is a helper method to define mock.On call +// - chargePointId string +// - request *core.StopTransactionRequest +func (_e *MockCoreCentralSystemHandler_Expecter) OnStopTransaction(chargePointId interface{}, request interface{}) *MockCoreCentralSystemHandler_OnStopTransaction_Call { + return &MockCoreCentralSystemHandler_OnStopTransaction_Call{Call: _e.mock.On("OnStopTransaction", chargePointId, request)} +} + +func (_c *MockCoreCentralSystemHandler_OnStopTransaction_Call) Run(run func(chargePointId string, request *core.StopTransactionRequest)) *MockCoreCentralSystemHandler_OnStopTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*core.StopTransactionRequest)) + }) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnStopTransaction_Call) Return(confirmation *core.StopTransactionConfirmation, err error) *MockCoreCentralSystemHandler_OnStopTransaction_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreCentralSystemHandler_OnStopTransaction_Call) RunAndReturn(run func(string, *core.StopTransactionRequest) (*core.StopTransactionConfirmation, error)) *MockCoreCentralSystemHandler_OnStopTransaction_Call { + _c.Call.Return(run) + return _c +} + +// NewMockCoreCentralSystemHandler creates a new instance of MockCoreCentralSystemHandler. 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 NewMockCoreCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockCoreCentralSystemHandler { + mock := &MockCoreCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_core_charge_point_handler.go b/ocpp1.6_test/mocks/mock_core_charge_point_handler.go new file mode 100644 index 00000000..2ebb07dd --- /dev/null +++ b/ocpp1.6_test/mocks/mock_core_charge_point_handler.go @@ -0,0 +1,557 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + core "github.com/lorenzodonini/ocpp-go/ocpp1.6/core" + mock "github.com/stretchr/testify/mock" +) + +// MockCoreChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockCoreChargePointHandler struct { + mock.Mock +} + +type MockCoreChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockCoreChargePointHandler) EXPECT() *MockCoreChargePointHandler_Expecter { + return &MockCoreChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnChangeAvailability provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnChangeAvailability(request *core.ChangeAvailabilityRequest) (*core.ChangeAvailabilityConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnChangeAvailability") + } + + var r0 *core.ChangeAvailabilityConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.ChangeAvailabilityRequest) (*core.ChangeAvailabilityConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.ChangeAvailabilityRequest) *core.ChangeAvailabilityConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.ChangeAvailabilityConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.ChangeAvailabilityRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnChangeAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnChangeAvailability' +type MockCoreChargePointHandler_OnChangeAvailability_Call struct { + *mock.Call +} + +// OnChangeAvailability is a helper method to define mock.On call +// - request *core.ChangeAvailabilityRequest +func (_e *MockCoreChargePointHandler_Expecter) OnChangeAvailability(request interface{}) *MockCoreChargePointHandler_OnChangeAvailability_Call { + return &MockCoreChargePointHandler_OnChangeAvailability_Call{Call: _e.mock.On("OnChangeAvailability", request)} +} + +func (_c *MockCoreChargePointHandler_OnChangeAvailability_Call) Run(run func(request *core.ChangeAvailabilityRequest)) *MockCoreChargePointHandler_OnChangeAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.ChangeAvailabilityRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnChangeAvailability_Call) Return(confirmation *core.ChangeAvailabilityConfirmation, err error) *MockCoreChargePointHandler_OnChangeAvailability_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnChangeAvailability_Call) RunAndReturn(run func(*core.ChangeAvailabilityRequest) (*core.ChangeAvailabilityConfirmation, error)) *MockCoreChargePointHandler_OnChangeAvailability_Call { + _c.Call.Return(run) + return _c +} + +// OnChangeConfiguration provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnChangeConfiguration(request *core.ChangeConfigurationRequest) (*core.ChangeConfigurationConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnChangeConfiguration") + } + + var r0 *core.ChangeConfigurationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.ChangeConfigurationRequest) (*core.ChangeConfigurationConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.ChangeConfigurationRequest) *core.ChangeConfigurationConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.ChangeConfigurationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.ChangeConfigurationRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnChangeConfiguration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnChangeConfiguration' +type MockCoreChargePointHandler_OnChangeConfiguration_Call struct { + *mock.Call +} + +// OnChangeConfiguration is a helper method to define mock.On call +// - request *core.ChangeConfigurationRequest +func (_e *MockCoreChargePointHandler_Expecter) OnChangeConfiguration(request interface{}) *MockCoreChargePointHandler_OnChangeConfiguration_Call { + return &MockCoreChargePointHandler_OnChangeConfiguration_Call{Call: _e.mock.On("OnChangeConfiguration", request)} +} + +func (_c *MockCoreChargePointHandler_OnChangeConfiguration_Call) Run(run func(request *core.ChangeConfigurationRequest)) *MockCoreChargePointHandler_OnChangeConfiguration_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.ChangeConfigurationRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnChangeConfiguration_Call) Return(confirmation *core.ChangeConfigurationConfirmation, err error) *MockCoreChargePointHandler_OnChangeConfiguration_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnChangeConfiguration_Call) RunAndReturn(run func(*core.ChangeConfigurationRequest) (*core.ChangeConfigurationConfirmation, error)) *MockCoreChargePointHandler_OnChangeConfiguration_Call { + _c.Call.Return(run) + return _c +} + +// OnClearCache provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnClearCache(request *core.ClearCacheRequest) (*core.ClearCacheConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnClearCache") + } + + var r0 *core.ClearCacheConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.ClearCacheRequest) (*core.ClearCacheConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.ClearCacheRequest) *core.ClearCacheConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.ClearCacheConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.ClearCacheRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnClearCache_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnClearCache' +type MockCoreChargePointHandler_OnClearCache_Call struct { + *mock.Call +} + +// OnClearCache is a helper method to define mock.On call +// - request *core.ClearCacheRequest +func (_e *MockCoreChargePointHandler_Expecter) OnClearCache(request interface{}) *MockCoreChargePointHandler_OnClearCache_Call { + return &MockCoreChargePointHandler_OnClearCache_Call{Call: _e.mock.On("OnClearCache", request)} +} + +func (_c *MockCoreChargePointHandler_OnClearCache_Call) Run(run func(request *core.ClearCacheRequest)) *MockCoreChargePointHandler_OnClearCache_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.ClearCacheRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnClearCache_Call) Return(confirmation *core.ClearCacheConfirmation, err error) *MockCoreChargePointHandler_OnClearCache_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnClearCache_Call) RunAndReturn(run func(*core.ClearCacheRequest) (*core.ClearCacheConfirmation, error)) *MockCoreChargePointHandler_OnClearCache_Call { + _c.Call.Return(run) + return _c +} + +// OnDataTransfer provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnDataTransfer(request *core.DataTransferRequest) (*core.DataTransferConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnDataTransfer") + } + + var r0 *core.DataTransferConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.DataTransferRequest) (*core.DataTransferConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.DataTransferRequest) *core.DataTransferConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.DataTransferConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.DataTransferRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnDataTransfer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnDataTransfer' +type MockCoreChargePointHandler_OnDataTransfer_Call struct { + *mock.Call +} + +// OnDataTransfer is a helper method to define mock.On call +// - request *core.DataTransferRequest +func (_e *MockCoreChargePointHandler_Expecter) OnDataTransfer(request interface{}) *MockCoreChargePointHandler_OnDataTransfer_Call { + return &MockCoreChargePointHandler_OnDataTransfer_Call{Call: _e.mock.On("OnDataTransfer", request)} +} + +func (_c *MockCoreChargePointHandler_OnDataTransfer_Call) Run(run func(request *core.DataTransferRequest)) *MockCoreChargePointHandler_OnDataTransfer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.DataTransferRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnDataTransfer_Call) Return(confirmation *core.DataTransferConfirmation, err error) *MockCoreChargePointHandler_OnDataTransfer_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnDataTransfer_Call) RunAndReturn(run func(*core.DataTransferRequest) (*core.DataTransferConfirmation, error)) *MockCoreChargePointHandler_OnDataTransfer_Call { + _c.Call.Return(run) + return _c +} + +// OnGetConfiguration provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnGetConfiguration(request *core.GetConfigurationRequest) (*core.GetConfigurationConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnGetConfiguration") + } + + var r0 *core.GetConfigurationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.GetConfigurationRequest) (*core.GetConfigurationConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.GetConfigurationRequest) *core.GetConfigurationConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.GetConfigurationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.GetConfigurationRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnGetConfiguration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnGetConfiguration' +type MockCoreChargePointHandler_OnGetConfiguration_Call struct { + *mock.Call +} + +// OnGetConfiguration is a helper method to define mock.On call +// - request *core.GetConfigurationRequest +func (_e *MockCoreChargePointHandler_Expecter) OnGetConfiguration(request interface{}) *MockCoreChargePointHandler_OnGetConfiguration_Call { + return &MockCoreChargePointHandler_OnGetConfiguration_Call{Call: _e.mock.On("OnGetConfiguration", request)} +} + +func (_c *MockCoreChargePointHandler_OnGetConfiguration_Call) Run(run func(request *core.GetConfigurationRequest)) *MockCoreChargePointHandler_OnGetConfiguration_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.GetConfigurationRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnGetConfiguration_Call) Return(confirmation *core.GetConfigurationConfirmation, err error) *MockCoreChargePointHandler_OnGetConfiguration_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnGetConfiguration_Call) RunAndReturn(run func(*core.GetConfigurationRequest) (*core.GetConfigurationConfirmation, error)) *MockCoreChargePointHandler_OnGetConfiguration_Call { + _c.Call.Return(run) + return _c +} + +// OnRemoteStartTransaction provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnRemoteStartTransaction(request *core.RemoteStartTransactionRequest) (*core.RemoteStartTransactionConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnRemoteStartTransaction") + } + + var r0 *core.RemoteStartTransactionConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.RemoteStartTransactionRequest) (*core.RemoteStartTransactionConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.RemoteStartTransactionRequest) *core.RemoteStartTransactionConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.RemoteStartTransactionConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.RemoteStartTransactionRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnRemoteStartTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnRemoteStartTransaction' +type MockCoreChargePointHandler_OnRemoteStartTransaction_Call struct { + *mock.Call +} + +// OnRemoteStartTransaction is a helper method to define mock.On call +// - request *core.RemoteStartTransactionRequest +func (_e *MockCoreChargePointHandler_Expecter) OnRemoteStartTransaction(request interface{}) *MockCoreChargePointHandler_OnRemoteStartTransaction_Call { + return &MockCoreChargePointHandler_OnRemoteStartTransaction_Call{Call: _e.mock.On("OnRemoteStartTransaction", request)} +} + +func (_c *MockCoreChargePointHandler_OnRemoteStartTransaction_Call) Run(run func(request *core.RemoteStartTransactionRequest)) *MockCoreChargePointHandler_OnRemoteStartTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.RemoteStartTransactionRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnRemoteStartTransaction_Call) Return(confirmation *core.RemoteStartTransactionConfirmation, err error) *MockCoreChargePointHandler_OnRemoteStartTransaction_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnRemoteStartTransaction_Call) RunAndReturn(run func(*core.RemoteStartTransactionRequest) (*core.RemoteStartTransactionConfirmation, error)) *MockCoreChargePointHandler_OnRemoteStartTransaction_Call { + _c.Call.Return(run) + return _c +} + +// OnRemoteStopTransaction provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnRemoteStopTransaction(request *core.RemoteStopTransactionRequest) (*core.RemoteStopTransactionConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnRemoteStopTransaction") + } + + var r0 *core.RemoteStopTransactionConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.RemoteStopTransactionRequest) (*core.RemoteStopTransactionConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.RemoteStopTransactionRequest) *core.RemoteStopTransactionConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.RemoteStopTransactionConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.RemoteStopTransactionRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnRemoteStopTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnRemoteStopTransaction' +type MockCoreChargePointHandler_OnRemoteStopTransaction_Call struct { + *mock.Call +} + +// OnRemoteStopTransaction is a helper method to define mock.On call +// - request *core.RemoteStopTransactionRequest +func (_e *MockCoreChargePointHandler_Expecter) OnRemoteStopTransaction(request interface{}) *MockCoreChargePointHandler_OnRemoteStopTransaction_Call { + return &MockCoreChargePointHandler_OnRemoteStopTransaction_Call{Call: _e.mock.On("OnRemoteStopTransaction", request)} +} + +func (_c *MockCoreChargePointHandler_OnRemoteStopTransaction_Call) Run(run func(request *core.RemoteStopTransactionRequest)) *MockCoreChargePointHandler_OnRemoteStopTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.RemoteStopTransactionRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnRemoteStopTransaction_Call) Return(confirmation *core.RemoteStopTransactionConfirmation, err error) *MockCoreChargePointHandler_OnRemoteStopTransaction_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnRemoteStopTransaction_Call) RunAndReturn(run func(*core.RemoteStopTransactionRequest) (*core.RemoteStopTransactionConfirmation, error)) *MockCoreChargePointHandler_OnRemoteStopTransaction_Call { + _c.Call.Return(run) + return _c +} + +// OnReset provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnReset(request *core.ResetRequest) (*core.ResetConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnReset") + } + + var r0 *core.ResetConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.ResetRequest) (*core.ResetConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.ResetRequest) *core.ResetConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.ResetConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.ResetRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnReset_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnReset' +type MockCoreChargePointHandler_OnReset_Call struct { + *mock.Call +} + +// OnReset is a helper method to define mock.On call +// - request *core.ResetRequest +func (_e *MockCoreChargePointHandler_Expecter) OnReset(request interface{}) *MockCoreChargePointHandler_OnReset_Call { + return &MockCoreChargePointHandler_OnReset_Call{Call: _e.mock.On("OnReset", request)} +} + +func (_c *MockCoreChargePointHandler_OnReset_Call) Run(run func(request *core.ResetRequest)) *MockCoreChargePointHandler_OnReset_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.ResetRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnReset_Call) Return(confirmation *core.ResetConfirmation, err error) *MockCoreChargePointHandler_OnReset_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnReset_Call) RunAndReturn(run func(*core.ResetRequest) (*core.ResetConfirmation, error)) *MockCoreChargePointHandler_OnReset_Call { + _c.Call.Return(run) + return _c +} + +// OnUnlockConnector provides a mock function with given fields: request +func (_m *MockCoreChargePointHandler) OnUnlockConnector(request *core.UnlockConnectorRequest) (*core.UnlockConnectorConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnUnlockConnector") + } + + var r0 *core.UnlockConnectorConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*core.UnlockConnectorRequest) (*core.UnlockConnectorConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*core.UnlockConnectorRequest) *core.UnlockConnectorConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*core.UnlockConnectorConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*core.UnlockConnectorRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockCoreChargePointHandler_OnUnlockConnector_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnUnlockConnector' +type MockCoreChargePointHandler_OnUnlockConnector_Call struct { + *mock.Call +} + +// OnUnlockConnector is a helper method to define mock.On call +// - request *core.UnlockConnectorRequest +func (_e *MockCoreChargePointHandler_Expecter) OnUnlockConnector(request interface{}) *MockCoreChargePointHandler_OnUnlockConnector_Call { + return &MockCoreChargePointHandler_OnUnlockConnector_Call{Call: _e.mock.On("OnUnlockConnector", request)} +} + +func (_c *MockCoreChargePointHandler_OnUnlockConnector_Call) Run(run func(request *core.UnlockConnectorRequest)) *MockCoreChargePointHandler_OnUnlockConnector_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*core.UnlockConnectorRequest)) + }) + return _c +} + +func (_c *MockCoreChargePointHandler_OnUnlockConnector_Call) Return(confirmation *core.UnlockConnectorConfirmation, err error) *MockCoreChargePointHandler_OnUnlockConnector_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockCoreChargePointHandler_OnUnlockConnector_Call) RunAndReturn(run func(*core.UnlockConnectorRequest) (*core.UnlockConnectorConfirmation, error)) *MockCoreChargePointHandler_OnUnlockConnector_Call { + _c.Call.Return(run) + return _c +} + +// NewMockCoreChargePointHandler creates a new instance of MockCoreChargePointHandler. 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 NewMockCoreChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockCoreChargePointHandler { + mock := &MockCoreChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..f2dba253 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_extended_trigger_message_charge_point_handler.go @@ -0,0 +1,93 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + extendedtriggermessage "github.com/lorenzodonini/ocpp-go/ocpp1.6/extendedtriggermessage" + mock "github.com/stretchr/testify/mock" +) + +// MockExtendedTriggerMessageChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockExtendedTriggerMessageChargePointHandler struct { + mock.Mock +} + +type MockExtendedTriggerMessageChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockExtendedTriggerMessageChargePointHandler) EXPECT() *MockExtendedTriggerMessageChargePointHandler_Expecter { + return &MockExtendedTriggerMessageChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnExtendedTriggerMessage provides a mock function with given fields: request +func (_m *MockExtendedTriggerMessageChargePointHandler) OnExtendedTriggerMessage(request *extendedtriggermessage.ExtendedTriggerMessageRequest) (*extendedtriggermessage.ExtendedTriggerMessageResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnExtendedTriggerMessage") + } + + var r0 *extendedtriggermessage.ExtendedTriggerMessageResponse + var r1 error + if rf, ok := ret.Get(0).(func(*extendedtriggermessage.ExtendedTriggerMessageRequest) (*extendedtriggermessage.ExtendedTriggerMessageResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*extendedtriggermessage.ExtendedTriggerMessageRequest) *extendedtriggermessage.ExtendedTriggerMessageResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*extendedtriggermessage.ExtendedTriggerMessageResponse) + } + } + + if rf, ok := ret.Get(1).(func(*extendedtriggermessage.ExtendedTriggerMessageRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnExtendedTriggerMessage' +type MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call struct { + *mock.Call +} + +// OnExtendedTriggerMessage is a helper method to define mock.On call +// - request *extendedtriggermessage.ExtendedTriggerMessageRequest +func (_e *MockExtendedTriggerMessageChargePointHandler_Expecter) OnExtendedTriggerMessage(request interface{}) *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call { + return &MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call{Call: _e.mock.On("OnExtendedTriggerMessage", request)} +} + +func (_c *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call) Run(run func(request *extendedtriggermessage.ExtendedTriggerMessageRequest)) *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*extendedtriggermessage.ExtendedTriggerMessageRequest)) + }) + return _c +} + +func (_c *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call) Return(response *extendedtriggermessage.ExtendedTriggerMessageResponse, err error) *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call) RunAndReturn(run func(*extendedtriggermessage.ExtendedTriggerMessageRequest) (*extendedtriggermessage.ExtendedTriggerMessageResponse, error)) *MockExtendedTriggerMessageChargePointHandler_OnExtendedTriggerMessage_Call { + _c.Call.Return(run) + return _c +} + +// NewMockExtendedTriggerMessageChargePointHandler creates a new instance of MockExtendedTriggerMessageChargePointHandler. 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 NewMockExtendedTriggerMessageChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockExtendedTriggerMessageChargePointHandler { + mock := &MockExtendedTriggerMessageChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go b/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go new file mode 100644 index 00000000..96e0c872 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_firmware_central_system_handler.go @@ -0,0 +1,153 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + firmware "github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware" + mock "github.com/stretchr/testify/mock" +) + +// MockFirmwareCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockFirmwareCentralSystemHandler struct { + mock.Mock +} + +type MockFirmwareCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFirmwareCentralSystemHandler) EXPECT() *MockFirmwareCentralSystemHandler_Expecter { + return &MockFirmwareCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// OnDiagnosticsStatusNotification provides a mock function with given fields: chargePointId, request +func (_m *MockFirmwareCentralSystemHandler) OnDiagnosticsStatusNotification(chargePointId string, request *firmware.DiagnosticsStatusNotificationRequest) (*firmware.DiagnosticsStatusNotificationConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnDiagnosticsStatusNotification") + } + + var r0 *firmware.DiagnosticsStatusNotificationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *firmware.DiagnosticsStatusNotificationRequest) (*firmware.DiagnosticsStatusNotificationConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *firmware.DiagnosticsStatusNotificationRequest) *firmware.DiagnosticsStatusNotificationConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*firmware.DiagnosticsStatusNotificationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *firmware.DiagnosticsStatusNotificationRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnDiagnosticsStatusNotification' +type MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call struct { + *mock.Call +} + +// OnDiagnosticsStatusNotification is a helper method to define mock.On call +// - chargePointId string +// - request *firmware.DiagnosticsStatusNotificationRequest +func (_e *MockFirmwareCentralSystemHandler_Expecter) OnDiagnosticsStatusNotification(chargePointId interface{}, request interface{}) *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call { + return &MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call{Call: _e.mock.On("OnDiagnosticsStatusNotification", chargePointId, request)} +} + +func (_c *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call) Run(run func(chargePointId string, request *firmware.DiagnosticsStatusNotificationRequest)) *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*firmware.DiagnosticsStatusNotificationRequest)) + }) + return _c +} + +func (_c *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call) Return(confirmation *firmware.DiagnosticsStatusNotificationConfirmation, err error) *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call) RunAndReturn(run func(string, *firmware.DiagnosticsStatusNotificationRequest) (*firmware.DiagnosticsStatusNotificationConfirmation, error)) *MockFirmwareCentralSystemHandler_OnDiagnosticsStatusNotification_Call { + _c.Call.Return(run) + return _c +} + +// OnFirmwareStatusNotification provides a mock function with given fields: chargePointId, request +func (_m *MockFirmwareCentralSystemHandler) OnFirmwareStatusNotification(chargePointId string, request *firmware.FirmwareStatusNotificationRequest) (*firmware.FirmwareStatusNotificationConfirmation, error) { + ret := _m.Called(chargePointId, request) + + if len(ret) == 0 { + panic("no return value specified for OnFirmwareStatusNotification") + } + + var r0 *firmware.FirmwareStatusNotificationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(string, *firmware.FirmwareStatusNotificationRequest) (*firmware.FirmwareStatusNotificationConfirmation, error)); ok { + return rf(chargePointId, request) + } + if rf, ok := ret.Get(0).(func(string, *firmware.FirmwareStatusNotificationRequest) *firmware.FirmwareStatusNotificationConfirmation); ok { + r0 = rf(chargePointId, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*firmware.FirmwareStatusNotificationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(string, *firmware.FirmwareStatusNotificationRequest) error); ok { + r1 = rf(chargePointId, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnFirmwareStatusNotification' +type MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call struct { + *mock.Call +} + +// OnFirmwareStatusNotification is a helper method to define mock.On call +// - chargePointId string +// - request *firmware.FirmwareStatusNotificationRequest +func (_e *MockFirmwareCentralSystemHandler_Expecter) OnFirmwareStatusNotification(chargePointId interface{}, request interface{}) *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call { + return &MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call{Call: _e.mock.On("OnFirmwareStatusNotification", chargePointId, request)} +} + +func (_c *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call) Run(run func(chargePointId string, request *firmware.FirmwareStatusNotificationRequest)) *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*firmware.FirmwareStatusNotificationRequest)) + }) + return _c +} + +func (_c *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call) Return(confirmation *firmware.FirmwareStatusNotificationConfirmation, err error) *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call) RunAndReturn(run func(string, *firmware.FirmwareStatusNotificationRequest) (*firmware.FirmwareStatusNotificationConfirmation, error)) *MockFirmwareCentralSystemHandler_OnFirmwareStatusNotification_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFirmwareCentralSystemHandler creates a new instance of MockFirmwareCentralSystemHandler. 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 NewMockFirmwareCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFirmwareCentralSystemHandler { + mock := &MockFirmwareCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go b/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go new file mode 100644 index 00000000..24041b80 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_firmware_charge_point_handler.go @@ -0,0 +1,151 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + firmware "github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware" + mock "github.com/stretchr/testify/mock" +) + +// MockFirmwareChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockFirmwareChargePointHandler struct { + mock.Mock +} + +type MockFirmwareChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFirmwareChargePointHandler) EXPECT() *MockFirmwareChargePointHandler_Expecter { + return &MockFirmwareChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnGetDiagnostics provides a mock function with given fields: request +func (_m *MockFirmwareChargePointHandler) OnGetDiagnostics(request *firmware.GetDiagnosticsRequest) (*firmware.GetDiagnosticsConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnGetDiagnostics") + } + + var r0 *firmware.GetDiagnosticsConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*firmware.GetDiagnosticsRequest) (*firmware.GetDiagnosticsConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*firmware.GetDiagnosticsRequest) *firmware.GetDiagnosticsConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*firmware.GetDiagnosticsConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*firmware.GetDiagnosticsRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirmwareChargePointHandler_OnGetDiagnostics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnGetDiagnostics' +type MockFirmwareChargePointHandler_OnGetDiagnostics_Call struct { + *mock.Call +} + +// OnGetDiagnostics is a helper method to define mock.On call +// - request *firmware.GetDiagnosticsRequest +func (_e *MockFirmwareChargePointHandler_Expecter) OnGetDiagnostics(request interface{}) *MockFirmwareChargePointHandler_OnGetDiagnostics_Call { + return &MockFirmwareChargePointHandler_OnGetDiagnostics_Call{Call: _e.mock.On("OnGetDiagnostics", request)} +} + +func (_c *MockFirmwareChargePointHandler_OnGetDiagnostics_Call) Run(run func(request *firmware.GetDiagnosticsRequest)) *MockFirmwareChargePointHandler_OnGetDiagnostics_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*firmware.GetDiagnosticsRequest)) + }) + return _c +} + +func (_c *MockFirmwareChargePointHandler_OnGetDiagnostics_Call) Return(confirmation *firmware.GetDiagnosticsConfirmation, err error) *MockFirmwareChargePointHandler_OnGetDiagnostics_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockFirmwareChargePointHandler_OnGetDiagnostics_Call) RunAndReturn(run func(*firmware.GetDiagnosticsRequest) (*firmware.GetDiagnosticsConfirmation, error)) *MockFirmwareChargePointHandler_OnGetDiagnostics_Call { + _c.Call.Return(run) + return _c +} + +// OnUpdateFirmware provides a mock function with given fields: request +func (_m *MockFirmwareChargePointHandler) OnUpdateFirmware(request *firmware.UpdateFirmwareRequest) (*firmware.UpdateFirmwareConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnUpdateFirmware") + } + + var r0 *firmware.UpdateFirmwareConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*firmware.UpdateFirmwareRequest) (*firmware.UpdateFirmwareConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*firmware.UpdateFirmwareRequest) *firmware.UpdateFirmwareConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*firmware.UpdateFirmwareConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*firmware.UpdateFirmwareRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockFirmwareChargePointHandler_OnUpdateFirmware_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnUpdateFirmware' +type MockFirmwareChargePointHandler_OnUpdateFirmware_Call struct { + *mock.Call +} + +// OnUpdateFirmware is a helper method to define mock.On call +// - request *firmware.UpdateFirmwareRequest +func (_e *MockFirmwareChargePointHandler_Expecter) OnUpdateFirmware(request interface{}) *MockFirmwareChargePointHandler_OnUpdateFirmware_Call { + return &MockFirmwareChargePointHandler_OnUpdateFirmware_Call{Call: _e.mock.On("OnUpdateFirmware", request)} +} + +func (_c *MockFirmwareChargePointHandler_OnUpdateFirmware_Call) Run(run func(request *firmware.UpdateFirmwareRequest)) *MockFirmwareChargePointHandler_OnUpdateFirmware_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*firmware.UpdateFirmwareRequest)) + }) + return _c +} + +func (_c *MockFirmwareChargePointHandler_OnUpdateFirmware_Call) Return(confirmation *firmware.UpdateFirmwareConfirmation, err error) *MockFirmwareChargePointHandler_OnUpdateFirmware_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockFirmwareChargePointHandler_OnUpdateFirmware_Call) RunAndReturn(run func(*firmware.UpdateFirmwareRequest) (*firmware.UpdateFirmwareConfirmation, error)) *MockFirmwareChargePointHandler_OnUpdateFirmware_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFirmwareChargePointHandler creates a new instance of MockFirmwareChargePointHandler. 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 NewMockFirmwareChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFirmwareChargePointHandler { + mock := &MockFirmwareChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..e3e7d459 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_local_auth_list_central_system_handler.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockLocalAuthListCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockLocalAuthListCentralSystemHandler struct { + mock.Mock +} + +type MockLocalAuthListCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLocalAuthListCentralSystemHandler) EXPECT() *MockLocalAuthListCentralSystemHandler_Expecter { + return &MockLocalAuthListCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// NewMockLocalAuthListCentralSystemHandler creates a new instance of MockLocalAuthListCentralSystemHandler. 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 NewMockLocalAuthListCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLocalAuthListCentralSystemHandler { + mock := &MockLocalAuthListCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..0209f9bf --- /dev/null +++ b/ocpp1.6_test/mocks/mock_local_auth_list_charge_point_handler.go @@ -0,0 +1,151 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + localauth "github.com/lorenzodonini/ocpp-go/ocpp1.6/localauth" + mock "github.com/stretchr/testify/mock" +) + +// MockLocalAuthListChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockLocalAuthListChargePointHandler struct { + mock.Mock +} + +type MockLocalAuthListChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLocalAuthListChargePointHandler) EXPECT() *MockLocalAuthListChargePointHandler_Expecter { + return &MockLocalAuthListChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnGetLocalListVersion provides a mock function with given fields: request +func (_m *MockLocalAuthListChargePointHandler) OnGetLocalListVersion(request *localauth.GetLocalListVersionRequest) (*localauth.GetLocalListVersionConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnGetLocalListVersion") + } + + var r0 *localauth.GetLocalListVersionConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*localauth.GetLocalListVersionRequest) (*localauth.GetLocalListVersionConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*localauth.GetLocalListVersionRequest) *localauth.GetLocalListVersionConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*localauth.GetLocalListVersionConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*localauth.GetLocalListVersionRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnGetLocalListVersion' +type MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call struct { + *mock.Call +} + +// OnGetLocalListVersion is a helper method to define mock.On call +// - request *localauth.GetLocalListVersionRequest +func (_e *MockLocalAuthListChargePointHandler_Expecter) OnGetLocalListVersion(request interface{}) *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call { + return &MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call{Call: _e.mock.On("OnGetLocalListVersion", request)} +} + +func (_c *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call) Run(run func(request *localauth.GetLocalListVersionRequest)) *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*localauth.GetLocalListVersionRequest)) + }) + return _c +} + +func (_c *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call) Return(confirmation *localauth.GetLocalListVersionConfirmation, err error) *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call) RunAndReturn(run func(*localauth.GetLocalListVersionRequest) (*localauth.GetLocalListVersionConfirmation, error)) *MockLocalAuthListChargePointHandler_OnGetLocalListVersion_Call { + _c.Call.Return(run) + return _c +} + +// OnSendLocalList provides a mock function with given fields: request +func (_m *MockLocalAuthListChargePointHandler) OnSendLocalList(request *localauth.SendLocalListRequest) (*localauth.SendLocalListConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnSendLocalList") + } + + var r0 *localauth.SendLocalListConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*localauth.SendLocalListRequest) (*localauth.SendLocalListConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*localauth.SendLocalListRequest) *localauth.SendLocalListConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*localauth.SendLocalListConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*localauth.SendLocalListRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLocalAuthListChargePointHandler_OnSendLocalList_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnSendLocalList' +type MockLocalAuthListChargePointHandler_OnSendLocalList_Call struct { + *mock.Call +} + +// OnSendLocalList is a helper method to define mock.On call +// - request *localauth.SendLocalListRequest +func (_e *MockLocalAuthListChargePointHandler_Expecter) OnSendLocalList(request interface{}) *MockLocalAuthListChargePointHandler_OnSendLocalList_Call { + return &MockLocalAuthListChargePointHandler_OnSendLocalList_Call{Call: _e.mock.On("OnSendLocalList", request)} +} + +func (_c *MockLocalAuthListChargePointHandler_OnSendLocalList_Call) Run(run func(request *localauth.SendLocalListRequest)) *MockLocalAuthListChargePointHandler_OnSendLocalList_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*localauth.SendLocalListRequest)) + }) + return _c +} + +func (_c *MockLocalAuthListChargePointHandler_OnSendLocalList_Call) Return(confirmation *localauth.SendLocalListConfirmation, err error) *MockLocalAuthListChargePointHandler_OnSendLocalList_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockLocalAuthListChargePointHandler_OnSendLocalList_Call) RunAndReturn(run func(*localauth.SendLocalListRequest) (*localauth.SendLocalListConfirmation, error)) *MockLocalAuthListChargePointHandler_OnSendLocalList_Call { + _c.Call.Return(run) + return _c +} + +// NewMockLocalAuthListChargePointHandler creates a new instance of MockLocalAuthListChargePointHandler. 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 NewMockLocalAuthListChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLocalAuthListChargePointHandler { + mock := &MockLocalAuthListChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_logging_central_system_handler.go b/ocpp1.6_test/mocks/mock_logging_central_system_handler.go new file mode 100644 index 00000000..a3a8397f --- /dev/null +++ b/ocpp1.6_test/mocks/mock_logging_central_system_handler.go @@ -0,0 +1,94 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + logging "github.com/lorenzodonini/ocpp-go/ocpp1.6/logging" + mock "github.com/stretchr/testify/mock" +) + +// MockLogCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockLogCentralSystemHandler struct { + mock.Mock +} + +type MockLogCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLogCentralSystemHandler) EXPECT() *MockLogCentralSystemHandler_Expecter { + return &MockLogCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// OnLogStatusNotification provides a mock function with given fields: chargingStationID, request +func (_m *MockLogCentralSystemHandler) OnLogStatusNotification(chargingStationID string, request *logging.LogStatusNotificationRequest) (*logging.LogStatusNotificationResponse, error) { + ret := _m.Called(chargingStationID, request) + + if len(ret) == 0 { + panic("no return value specified for OnLogStatusNotification") + } + + var r0 *logging.LogStatusNotificationResponse + var r1 error + if rf, ok := ret.Get(0).(func(string, *logging.LogStatusNotificationRequest) (*logging.LogStatusNotificationResponse, error)); ok { + return rf(chargingStationID, request) + } + if rf, ok := ret.Get(0).(func(string, *logging.LogStatusNotificationRequest) *logging.LogStatusNotificationResponse); ok { + r0 = rf(chargingStationID, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*logging.LogStatusNotificationResponse) + } + } + + if rf, ok := ret.Get(1).(func(string, *logging.LogStatusNotificationRequest) error); ok { + r1 = rf(chargingStationID, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLogCentralSystemHandler_OnLogStatusNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnLogStatusNotification' +type MockLogCentralSystemHandler_OnLogStatusNotification_Call struct { + *mock.Call +} + +// OnLogStatusNotification is a helper method to define mock.On call +// - chargingStationID string +// - request *logging.LogStatusNotificationRequest +func (_e *MockLogCentralSystemHandler_Expecter) OnLogStatusNotification(chargingStationID interface{}, request interface{}) *MockLogCentralSystemHandler_OnLogStatusNotification_Call { + return &MockLogCentralSystemHandler_OnLogStatusNotification_Call{Call: _e.mock.On("OnLogStatusNotification", chargingStationID, request)} +} + +func (_c *MockLogCentralSystemHandler_OnLogStatusNotification_Call) Run(run func(chargingStationID string, request *logging.LogStatusNotificationRequest)) *MockLogCentralSystemHandler_OnLogStatusNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*logging.LogStatusNotificationRequest)) + }) + return _c +} + +func (_c *MockLogCentralSystemHandler_OnLogStatusNotification_Call) Return(response *logging.LogStatusNotificationResponse, err error) *MockLogCentralSystemHandler_OnLogStatusNotification_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockLogCentralSystemHandler_OnLogStatusNotification_Call) RunAndReturn(run func(string, *logging.LogStatusNotificationRequest) (*logging.LogStatusNotificationResponse, error)) *MockLogCentralSystemHandler_OnLogStatusNotification_Call { + _c.Call.Return(run) + return _c +} + +// NewMockLogCentralSystemHandler creates a new instance of MockLogCentralSystemHandler. 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 NewMockLogCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLogCentralSystemHandler { + mock := &MockLogCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go b/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go new file mode 100644 index 00000000..ca649fa2 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_logging_charge_point_handler.go @@ -0,0 +1,93 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + logging "github.com/lorenzodonini/ocpp-go/ocpp1.6/logging" + mock "github.com/stretchr/testify/mock" +) + +// MockLogChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockLogChargePointHandler struct { + mock.Mock +} + +type MockLogChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLogChargePointHandler) EXPECT() *MockLogChargePointHandler_Expecter { + return &MockLogChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnGetLog provides a mock function with given fields: request +func (_m *MockLogChargePointHandler) OnGetLog(request *logging.GetLogRequest) (*logging.GetLogResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnGetLog") + } + + var r0 *logging.GetLogResponse + var r1 error + if rf, ok := ret.Get(0).(func(*logging.GetLogRequest) (*logging.GetLogResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*logging.GetLogRequest) *logging.GetLogResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*logging.GetLogResponse) + } + } + + if rf, ok := ret.Get(1).(func(*logging.GetLogRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLogChargePointHandler_OnGetLog_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnGetLog' +type MockLogChargePointHandler_OnGetLog_Call struct { + *mock.Call +} + +// OnGetLog is a helper method to define mock.On call +// - request *logging.GetLogRequest +func (_e *MockLogChargePointHandler_Expecter) OnGetLog(request interface{}) *MockLogChargePointHandler_OnGetLog_Call { + return &MockLogChargePointHandler_OnGetLog_Call{Call: _e.mock.On("OnGetLog", request)} +} + +func (_c *MockLogChargePointHandler_OnGetLog_Call) Run(run func(request *logging.GetLogRequest)) *MockLogChargePointHandler_OnGetLog_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*logging.GetLogRequest)) + }) + return _c +} + +func (_c *MockLogChargePointHandler_OnGetLog_Call) Return(response *logging.GetLogResponse, err error) *MockLogChargePointHandler_OnGetLog_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockLogChargePointHandler_OnGetLog_Call) RunAndReturn(run func(*logging.GetLogRequest) (*logging.GetLogResponse, error)) *MockLogChargePointHandler_OnGetLog_Call { + _c.Call.Return(run) + return _c +} + +// NewMockLogChargePointHandler creates a new instance of MockLogChargePointHandler. 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 NewMockLogChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLogChargePointHandler { + mock := &MockLogChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_ocpp16.go b/ocpp1.6_test/mocks/mock_ocpp16.go new file mode 100644 index 00000000..1be648d5 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_ocpp16.go @@ -0,0 +1,68 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + ocpp16 "github.com/lorenzodonini/ocpp-go/ocpp1.6" + mock "github.com/stretchr/testify/mock" +) + +// MockChargePointConnectionHandler is an autogenerated mock type for the ChargePointConnectionHandler type +type MockChargePointConnectionHandler struct { + mock.Mock +} + +type MockChargePointConnectionHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockChargePointConnectionHandler) EXPECT() *MockChargePointConnectionHandler_Expecter { + return &MockChargePointConnectionHandler_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: chargePoint +func (_m *MockChargePointConnectionHandler) Execute(chargePoint ocpp16.ChargePointConnection) { + _m.Called(chargePoint) +} + +// MockChargePointConnectionHandler_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockChargePointConnectionHandler_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - chargePoint ocpp16.ChargePointConnection +func (_e *MockChargePointConnectionHandler_Expecter) Execute(chargePoint interface{}) *MockChargePointConnectionHandler_Execute_Call { + return &MockChargePointConnectionHandler_Execute_Call{Call: _e.mock.On("Execute", chargePoint)} +} + +func (_c *MockChargePointConnectionHandler_Execute_Call) Run(run func(chargePoint ocpp16.ChargePointConnection)) *MockChargePointConnectionHandler_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ocpp16.ChargePointConnection)) + }) + return _c +} + +func (_c *MockChargePointConnectionHandler_Execute_Call) Return() *MockChargePointConnectionHandler_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *MockChargePointConnectionHandler_Execute_Call) RunAndReturn(run func(ocpp16.ChargePointConnection)) *MockChargePointConnectionHandler_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewMockChargePointConnectionHandler creates a new instance of MockChargePointConnectionHandler. 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 NewMockChargePointConnectionHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockChargePointConnectionHandler { + mock := &MockChargePointConnectionHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..9bb64c22 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_remote_trigger_central_system_handler.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockRemoteTriggerCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockRemoteTriggerCentralSystemHandler struct { + mock.Mock +} + +type MockRemoteTriggerCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockRemoteTriggerCentralSystemHandler) EXPECT() *MockRemoteTriggerCentralSystemHandler_Expecter { + return &MockRemoteTriggerCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// NewMockRemoteTriggerCentralSystemHandler creates a new instance of MockRemoteTriggerCentralSystemHandler. 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 NewMockRemoteTriggerCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockRemoteTriggerCentralSystemHandler { + mock := &MockRemoteTriggerCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..5c49ed07 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_remote_trigger_charge_point_handler.go @@ -0,0 +1,93 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + remotetrigger "github.com/lorenzodonini/ocpp-go/ocpp1.6/remotetrigger" + mock "github.com/stretchr/testify/mock" +) + +// MockRemoteTriggerChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockRemoteTriggerChargePointHandler struct { + mock.Mock +} + +type MockRemoteTriggerChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockRemoteTriggerChargePointHandler) EXPECT() *MockRemoteTriggerChargePointHandler_Expecter { + return &MockRemoteTriggerChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnTriggerMessage provides a mock function with given fields: request +func (_m *MockRemoteTriggerChargePointHandler) OnTriggerMessage(request *remotetrigger.TriggerMessageRequest) (*remotetrigger.TriggerMessageConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnTriggerMessage") + } + + var r0 *remotetrigger.TriggerMessageConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*remotetrigger.TriggerMessageRequest) (*remotetrigger.TriggerMessageConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*remotetrigger.TriggerMessageRequest) *remotetrigger.TriggerMessageConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*remotetrigger.TriggerMessageConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*remotetrigger.TriggerMessageRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnTriggerMessage' +type MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call struct { + *mock.Call +} + +// OnTriggerMessage is a helper method to define mock.On call +// - request *remotetrigger.TriggerMessageRequest +func (_e *MockRemoteTriggerChargePointHandler_Expecter) OnTriggerMessage(request interface{}) *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call { + return &MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call{Call: _e.mock.On("OnTriggerMessage", request)} +} + +func (_c *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call) Run(run func(request *remotetrigger.TriggerMessageRequest)) *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*remotetrigger.TriggerMessageRequest)) + }) + return _c +} + +func (_c *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call) Return(confirmation *remotetrigger.TriggerMessageConfirmation, err error) *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call) RunAndReturn(run func(*remotetrigger.TriggerMessageRequest) (*remotetrigger.TriggerMessageConfirmation, error)) *MockRemoteTriggerChargePointHandler_OnTriggerMessage_Call { + _c.Call.Return(run) + return _c +} + +// NewMockRemoteTriggerChargePointHandler creates a new instance of MockRemoteTriggerChargePointHandler. 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 NewMockRemoteTriggerChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockRemoteTriggerChargePointHandler { + mock := &MockRemoteTriggerChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go b/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go new file mode 100644 index 00000000..542945b3 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_reservation_central_system_handler.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockReservationCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockReservationCentralSystemHandler struct { + mock.Mock +} + +type MockReservationCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockReservationCentralSystemHandler) EXPECT() *MockReservationCentralSystemHandler_Expecter { + return &MockReservationCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// NewMockReservationCentralSystemHandler creates a new instance of MockReservationCentralSystemHandler. 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 NewMockReservationCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockReservationCentralSystemHandler { + mock := &MockReservationCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go b/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go new file mode 100644 index 00000000..7067a0f5 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_reservation_charge_point_handler.go @@ -0,0 +1,151 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + reservation "github.com/lorenzodonini/ocpp-go/ocpp1.6/reservation" + mock "github.com/stretchr/testify/mock" +) + +// MockReservationChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockReservationChargePointHandler struct { + mock.Mock +} + +type MockReservationChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockReservationChargePointHandler) EXPECT() *MockReservationChargePointHandler_Expecter { + return &MockReservationChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnCancelReservation provides a mock function with given fields: request +func (_m *MockReservationChargePointHandler) OnCancelReservation(request *reservation.CancelReservationRequest) (*reservation.CancelReservationConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnCancelReservation") + } + + var r0 *reservation.CancelReservationConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*reservation.CancelReservationRequest) (*reservation.CancelReservationConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*reservation.CancelReservationRequest) *reservation.CancelReservationConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*reservation.CancelReservationConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*reservation.CancelReservationRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReservationChargePointHandler_OnCancelReservation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnCancelReservation' +type MockReservationChargePointHandler_OnCancelReservation_Call struct { + *mock.Call +} + +// OnCancelReservation is a helper method to define mock.On call +// - request *reservation.CancelReservationRequest +func (_e *MockReservationChargePointHandler_Expecter) OnCancelReservation(request interface{}) *MockReservationChargePointHandler_OnCancelReservation_Call { + return &MockReservationChargePointHandler_OnCancelReservation_Call{Call: _e.mock.On("OnCancelReservation", request)} +} + +func (_c *MockReservationChargePointHandler_OnCancelReservation_Call) Run(run func(request *reservation.CancelReservationRequest)) *MockReservationChargePointHandler_OnCancelReservation_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*reservation.CancelReservationRequest)) + }) + return _c +} + +func (_c *MockReservationChargePointHandler_OnCancelReservation_Call) Return(confirmation *reservation.CancelReservationConfirmation, err error) *MockReservationChargePointHandler_OnCancelReservation_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockReservationChargePointHandler_OnCancelReservation_Call) RunAndReturn(run func(*reservation.CancelReservationRequest) (*reservation.CancelReservationConfirmation, error)) *MockReservationChargePointHandler_OnCancelReservation_Call { + _c.Call.Return(run) + return _c +} + +// OnReserveNow provides a mock function with given fields: request +func (_m *MockReservationChargePointHandler) OnReserveNow(request *reservation.ReserveNowRequest) (*reservation.ReserveNowConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnReserveNow") + } + + var r0 *reservation.ReserveNowConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*reservation.ReserveNowRequest) (*reservation.ReserveNowConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*reservation.ReserveNowRequest) *reservation.ReserveNowConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*reservation.ReserveNowConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*reservation.ReserveNowRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReservationChargePointHandler_OnReserveNow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnReserveNow' +type MockReservationChargePointHandler_OnReserveNow_Call struct { + *mock.Call +} + +// OnReserveNow is a helper method to define mock.On call +// - request *reservation.ReserveNowRequest +func (_e *MockReservationChargePointHandler_Expecter) OnReserveNow(request interface{}) *MockReservationChargePointHandler_OnReserveNow_Call { + return &MockReservationChargePointHandler_OnReserveNow_Call{Call: _e.mock.On("OnReserveNow", request)} +} + +func (_c *MockReservationChargePointHandler_OnReserveNow_Call) Run(run func(request *reservation.ReserveNowRequest)) *MockReservationChargePointHandler_OnReserveNow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*reservation.ReserveNowRequest)) + }) + return _c +} + +func (_c *MockReservationChargePointHandler_OnReserveNow_Call) Return(confirmation *reservation.ReserveNowConfirmation, err error) *MockReservationChargePointHandler_OnReserveNow_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockReservationChargePointHandler_OnReserveNow_Call) RunAndReturn(run func(*reservation.ReserveNowRequest) (*reservation.ReserveNowConfirmation, error)) *MockReservationChargePointHandler_OnReserveNow_Call { + _c.Call.Return(run) + return _c +} + +// NewMockReservationChargePointHandler creates a new instance of MockReservationChargePointHandler. 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 NewMockReservationChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockReservationChargePointHandler { + mock := &MockReservationChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go b/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go new file mode 100644 index 00000000..ae01d1d8 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_secure_firmware_CentralSystemHandler.go @@ -0,0 +1,94 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + securefirmware "github.com/lorenzodonini/ocpp-go/ocpp1.6/securefirmware" + mock "github.com/stretchr/testify/mock" +) + +// MockSecureFirmwareCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockSecureFirmwareCentralSystemHandler struct { + mock.Mock +} + +type MockSecureFirmwareCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSecureFirmwareCentralSystemHandler) EXPECT() *MockSecureFirmwareCentralSystemHandler_Expecter { + return &MockSecureFirmwareCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// OnSignedFirmwareStatusNotification provides a mock function with given fields: chargingStationID, request +func (_m *MockSecureFirmwareCentralSystemHandler) OnSignedFirmwareStatusNotification(chargingStationID string, request *securefirmware.SignedFirmwareStatusNotificationRequest) (*securefirmware.SignedFirmwareStatusNotificationResponse, error) { + ret := _m.Called(chargingStationID, request) + + if len(ret) == 0 { + panic("no return value specified for OnSignedFirmwareStatusNotification") + } + + var r0 *securefirmware.SignedFirmwareStatusNotificationResponse + var r1 error + if rf, ok := ret.Get(0).(func(string, *securefirmware.SignedFirmwareStatusNotificationRequest) (*securefirmware.SignedFirmwareStatusNotificationResponse, error)); ok { + return rf(chargingStationID, request) + } + if rf, ok := ret.Get(0).(func(string, *securefirmware.SignedFirmwareStatusNotificationRequest) *securefirmware.SignedFirmwareStatusNotificationResponse); ok { + r0 = rf(chargingStationID, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*securefirmware.SignedFirmwareStatusNotificationResponse) + } + } + + if rf, ok := ret.Get(1).(func(string, *securefirmware.SignedFirmwareStatusNotificationRequest) error); ok { + r1 = rf(chargingStationID, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnSignedFirmwareStatusNotification' +type MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call struct { + *mock.Call +} + +// OnSignedFirmwareStatusNotification is a helper method to define mock.On call +// - chargingStationID string +// - request *securefirmware.SignedFirmwareStatusNotificationRequest +func (_e *MockSecureFirmwareCentralSystemHandler_Expecter) OnSignedFirmwareStatusNotification(chargingStationID interface{}, request interface{}) *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call { + return &MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call{Call: _e.mock.On("OnSignedFirmwareStatusNotification", chargingStationID, request)} +} + +func (_c *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call) Run(run func(chargingStationID string, request *securefirmware.SignedFirmwareStatusNotificationRequest)) *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*securefirmware.SignedFirmwareStatusNotificationRequest)) + }) + return _c +} + +func (_c *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call) Return(response *securefirmware.SignedFirmwareStatusNotificationResponse, err error) *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call) RunAndReturn(run func(string, *securefirmware.SignedFirmwareStatusNotificationRequest) (*securefirmware.SignedFirmwareStatusNotificationResponse, error)) *MockSecureFirmwareCentralSystemHandler_OnSignedFirmwareStatusNotification_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSecureFirmwareCentralSystemHandler creates a new instance of MockSecureFirmwareCentralSystemHandler. 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 NewMockSecureFirmwareCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSecureFirmwareCentralSystemHandler { + mock := &MockSecureFirmwareCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go b/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go new file mode 100644 index 00000000..ef07f7c1 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_secure_firmware_ChargePointHandler.go @@ -0,0 +1,93 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + securefirmware "github.com/lorenzodonini/ocpp-go/ocpp1.6/securefirmware" + mock "github.com/stretchr/testify/mock" +) + +// MockSecureFirmwareChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockSecureFirmwareChargePointHandler struct { + mock.Mock +} + +type MockSecureFirmwareChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSecureFirmwareChargePointHandler) EXPECT() *MockSecureFirmwareChargePointHandler_Expecter { + return &MockSecureFirmwareChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnSignedUpdateFirmware provides a mock function with given fields: request +func (_m *MockSecureFirmwareChargePointHandler) OnSignedUpdateFirmware(request *securefirmware.SignedUpdateFirmwareRequest) (*securefirmware.SignedUpdateFirmwareResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnSignedUpdateFirmware") + } + + var r0 *securefirmware.SignedUpdateFirmwareResponse + var r1 error + if rf, ok := ret.Get(0).(func(*securefirmware.SignedUpdateFirmwareRequest) (*securefirmware.SignedUpdateFirmwareResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*securefirmware.SignedUpdateFirmwareRequest) *securefirmware.SignedUpdateFirmwareResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*securefirmware.SignedUpdateFirmwareResponse) + } + } + + if rf, ok := ret.Get(1).(func(*securefirmware.SignedUpdateFirmwareRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnSignedUpdateFirmware' +type MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call struct { + *mock.Call +} + +// OnSignedUpdateFirmware is a helper method to define mock.On call +// - request *securefirmware.SignedUpdateFirmwareRequest +func (_e *MockSecureFirmwareChargePointHandler_Expecter) OnSignedUpdateFirmware(request interface{}) *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call { + return &MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call{Call: _e.mock.On("OnSignedUpdateFirmware", request)} +} + +func (_c *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call) Run(run func(request *securefirmware.SignedUpdateFirmwareRequest)) *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*securefirmware.SignedUpdateFirmwareRequest)) + }) + return _c +} + +func (_c *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call) Return(response *securefirmware.SignedUpdateFirmwareResponse, err error) *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call) RunAndReturn(run func(*securefirmware.SignedUpdateFirmwareRequest) (*securefirmware.SignedUpdateFirmwareResponse, error)) *MockSecureFirmwareChargePointHandler_OnSignedUpdateFirmware_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSecureFirmwareChargePointHandler creates a new instance of MockSecureFirmwareChargePointHandler. 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 NewMockSecureFirmwareChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSecureFirmwareChargePointHandler { + mock := &MockSecureFirmwareChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_security_central_system_handler.go b/ocpp1.6_test/mocks/mock_security_central_system_handler.go new file mode 100644 index 00000000..9d07b0c0 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_security_central_system_handler.go @@ -0,0 +1,153 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + security "github.com/lorenzodonini/ocpp-go/ocpp1.6/security" + mock "github.com/stretchr/testify/mock" +) + +// MockSecurityCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockSecurityCentralSystemHandler struct { + mock.Mock +} + +type MockSecurityCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSecurityCentralSystemHandler) EXPECT() *MockSecurityCentralSystemHandler_Expecter { + return &MockSecurityCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// OnSecurityEventNotification provides a mock function with given fields: chargingStationID, request +func (_m *MockSecurityCentralSystemHandler) OnSecurityEventNotification(chargingStationID string, request *security.SecurityEventNotificationRequest) (*security.SecurityEventNotificationResponse, error) { + ret := _m.Called(chargingStationID, request) + + if len(ret) == 0 { + panic("no return value specified for OnSecurityEventNotification") + } + + var r0 *security.SecurityEventNotificationResponse + var r1 error + if rf, ok := ret.Get(0).(func(string, *security.SecurityEventNotificationRequest) (*security.SecurityEventNotificationResponse, error)); ok { + return rf(chargingStationID, request) + } + if rf, ok := ret.Get(0).(func(string, *security.SecurityEventNotificationRequest) *security.SecurityEventNotificationResponse); ok { + r0 = rf(chargingStationID, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*security.SecurityEventNotificationResponse) + } + } + + if rf, ok := ret.Get(1).(func(string, *security.SecurityEventNotificationRequest) error); ok { + r1 = rf(chargingStationID, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnSecurityEventNotification' +type MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call struct { + *mock.Call +} + +// OnSecurityEventNotification is a helper method to define mock.On call +// - chargingStationID string +// - request *security.SecurityEventNotificationRequest +func (_e *MockSecurityCentralSystemHandler_Expecter) OnSecurityEventNotification(chargingStationID interface{}, request interface{}) *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call { + return &MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call{Call: _e.mock.On("OnSecurityEventNotification", chargingStationID, request)} +} + +func (_c *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call) Run(run func(chargingStationID string, request *security.SecurityEventNotificationRequest)) *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*security.SecurityEventNotificationRequest)) + }) + return _c +} + +func (_c *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call) Return(response *security.SecurityEventNotificationResponse, err error) *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call) RunAndReturn(run func(string, *security.SecurityEventNotificationRequest) (*security.SecurityEventNotificationResponse, error)) *MockSecurityCentralSystemHandler_OnSecurityEventNotification_Call { + _c.Call.Return(run) + return _c +} + +// OnSignCertificate provides a mock function with given fields: chargingStationID, request +func (_m *MockSecurityCentralSystemHandler) OnSignCertificate(chargingStationID string, request *security.SignCertificateRequest) (*security.SignCertificateResponse, error) { + ret := _m.Called(chargingStationID, request) + + if len(ret) == 0 { + panic("no return value specified for OnSignCertificate") + } + + var r0 *security.SignCertificateResponse + var r1 error + if rf, ok := ret.Get(0).(func(string, *security.SignCertificateRequest) (*security.SignCertificateResponse, error)); ok { + return rf(chargingStationID, request) + } + if rf, ok := ret.Get(0).(func(string, *security.SignCertificateRequest) *security.SignCertificateResponse); ok { + r0 = rf(chargingStationID, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*security.SignCertificateResponse) + } + } + + if rf, ok := ret.Get(1).(func(string, *security.SignCertificateRequest) error); ok { + r1 = rf(chargingStationID, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSecurityCentralSystemHandler_OnSignCertificate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnSignCertificate' +type MockSecurityCentralSystemHandler_OnSignCertificate_Call struct { + *mock.Call +} + +// OnSignCertificate is a helper method to define mock.On call +// - chargingStationID string +// - request *security.SignCertificateRequest +func (_e *MockSecurityCentralSystemHandler_Expecter) OnSignCertificate(chargingStationID interface{}, request interface{}) *MockSecurityCentralSystemHandler_OnSignCertificate_Call { + return &MockSecurityCentralSystemHandler_OnSignCertificate_Call{Call: _e.mock.On("OnSignCertificate", chargingStationID, request)} +} + +func (_c *MockSecurityCentralSystemHandler_OnSignCertificate_Call) Run(run func(chargingStationID string, request *security.SignCertificateRequest)) *MockSecurityCentralSystemHandler_OnSignCertificate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*security.SignCertificateRequest)) + }) + return _c +} + +func (_c *MockSecurityCentralSystemHandler_OnSignCertificate_Call) Return(response *security.SignCertificateResponse, err error) *MockSecurityCentralSystemHandler_OnSignCertificate_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockSecurityCentralSystemHandler_OnSignCertificate_Call) RunAndReturn(run func(string, *security.SignCertificateRequest) (*security.SignCertificateResponse, error)) *MockSecurityCentralSystemHandler_OnSignCertificate_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSecurityCentralSystemHandler creates a new instance of MockSecurityCentralSystemHandler. 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 NewMockSecurityCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSecurityCentralSystemHandler { + mock := &MockSecurityCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/mocks/mock_security_charge_point_handler.go b/ocpp1.6_test/mocks/mock_security_charge_point_handler.go new file mode 100644 index 00000000..ec7cf4b6 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_security_charge_point_handler.go @@ -0,0 +1,93 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + security "github.com/lorenzodonini/ocpp-go/ocpp1.6/security" + mock "github.com/stretchr/testify/mock" +) + +// MockSecurityChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockSecurityChargePointHandler struct { + mock.Mock +} + +type MockSecurityChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSecurityChargePointHandler) EXPECT() *MockSecurityChargePointHandler_Expecter { + return &MockSecurityChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnCertificateSigned provides a mock function with given fields: request +func (_m *MockSecurityChargePointHandler) OnCertificateSigned(request *security.CertificateSignedRequest) (*security.CertificateSignedResponse, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnCertificateSigned") + } + + var r0 *security.CertificateSignedResponse + var r1 error + if rf, ok := ret.Get(0).(func(*security.CertificateSignedRequest) (*security.CertificateSignedResponse, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*security.CertificateSignedRequest) *security.CertificateSignedResponse); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*security.CertificateSignedResponse) + } + } + + if rf, ok := ret.Get(1).(func(*security.CertificateSignedRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSecurityChargePointHandler_OnCertificateSigned_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnCertificateSigned' +type MockSecurityChargePointHandler_OnCertificateSigned_Call struct { + *mock.Call +} + +// OnCertificateSigned is a helper method to define mock.On call +// - request *security.CertificateSignedRequest +func (_e *MockSecurityChargePointHandler_Expecter) OnCertificateSigned(request interface{}) *MockSecurityChargePointHandler_OnCertificateSigned_Call { + return &MockSecurityChargePointHandler_OnCertificateSigned_Call{Call: _e.mock.On("OnCertificateSigned", request)} +} + +func (_c *MockSecurityChargePointHandler_OnCertificateSigned_Call) Run(run func(request *security.CertificateSignedRequest)) *MockSecurityChargePointHandler_OnCertificateSigned_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*security.CertificateSignedRequest)) + }) + return _c +} + +func (_c *MockSecurityChargePointHandler_OnCertificateSigned_Call) Return(response *security.CertificateSignedResponse, err error) *MockSecurityChargePointHandler_OnCertificateSigned_Call { + _c.Call.Return(response, err) + return _c +} + +func (_c *MockSecurityChargePointHandler_OnCertificateSigned_Call) RunAndReturn(run func(*security.CertificateSignedRequest) (*security.CertificateSignedResponse, error)) *MockSecurityChargePointHandler_OnCertificateSigned_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSecurityChargePointHandler creates a new instance of MockSecurityChargePointHandler. 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 NewMockSecurityChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSecurityChargePointHandler { + mock := &MockSecurityChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..b629878a --- /dev/null +++ b/ocpp1.6_test/mocks/mock_smart_charging_central_system_handler.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockSmartChargingCentralSystemHandler is an autogenerated mock type for the CentralSystemHandler type +type MockSmartChargingCentralSystemHandler struct { + mock.Mock +} + +type MockSmartChargingCentralSystemHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSmartChargingCentralSystemHandler) EXPECT() *MockSmartChargingCentralSystemHandler_Expecter { + return &MockSmartChargingCentralSystemHandler_Expecter{mock: &_m.Mock} +} + +// NewMockSmartChargingCentralSystemHandler creates a new instance of MockSmartChargingCentralSystemHandler. 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 NewMockSmartChargingCentralSystemHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSmartChargingCentralSystemHandler { + mock := &MockSmartChargingCentralSystemHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 new file mode 100644 index 00000000..1372d231 --- /dev/null +++ b/ocpp1.6_test/mocks/mock_smart_charging_charge_point_handler.go @@ -0,0 +1,209 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + smartcharging "github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging" + mock "github.com/stretchr/testify/mock" +) + +// MockSmartChargingChargePointHandler is an autogenerated mock type for the ChargePointHandler type +type MockSmartChargingChargePointHandler struct { + mock.Mock +} + +type MockSmartChargingChargePointHandler_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSmartChargingChargePointHandler) EXPECT() *MockSmartChargingChargePointHandler_Expecter { + return &MockSmartChargingChargePointHandler_Expecter{mock: &_m.Mock} +} + +// OnClearChargingProfile provides a mock function with given fields: request +func (_m *MockSmartChargingChargePointHandler) OnClearChargingProfile(request *smartcharging.ClearChargingProfileRequest) (*smartcharging.ClearChargingProfileConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnClearChargingProfile") + } + + var r0 *smartcharging.ClearChargingProfileConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*smartcharging.ClearChargingProfileRequest) (*smartcharging.ClearChargingProfileConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*smartcharging.ClearChargingProfileRequest) *smartcharging.ClearChargingProfileConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*smartcharging.ClearChargingProfileConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*smartcharging.ClearChargingProfileRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSmartChargingChargePointHandler_OnClearChargingProfile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnClearChargingProfile' +type MockSmartChargingChargePointHandler_OnClearChargingProfile_Call struct { + *mock.Call +} + +// OnClearChargingProfile is a helper method to define mock.On call +// - request *smartcharging.ClearChargingProfileRequest +func (_e *MockSmartChargingChargePointHandler_Expecter) OnClearChargingProfile(request interface{}) *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call { + return &MockSmartChargingChargePointHandler_OnClearChargingProfile_Call{Call: _e.mock.On("OnClearChargingProfile", request)} +} + +func (_c *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call) Run(run func(request *smartcharging.ClearChargingProfileRequest)) *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*smartcharging.ClearChargingProfileRequest)) + }) + return _c +} + +func (_c *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call) Return(confirmation *smartcharging.ClearChargingProfileConfirmation, err error) *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call) RunAndReturn(run func(*smartcharging.ClearChargingProfileRequest) (*smartcharging.ClearChargingProfileConfirmation, error)) *MockSmartChargingChargePointHandler_OnClearChargingProfile_Call { + _c.Call.Return(run) + return _c +} + +// OnGetCompositeSchedule provides a mock function with given fields: request +func (_m *MockSmartChargingChargePointHandler) OnGetCompositeSchedule(request *smartcharging.GetCompositeScheduleRequest) (*smartcharging.GetCompositeScheduleConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnGetCompositeSchedule") + } + + var r0 *smartcharging.GetCompositeScheduleConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*smartcharging.GetCompositeScheduleRequest) (*smartcharging.GetCompositeScheduleConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*smartcharging.GetCompositeScheduleRequest) *smartcharging.GetCompositeScheduleConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*smartcharging.GetCompositeScheduleConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*smartcharging.GetCompositeScheduleRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnGetCompositeSchedule' +type MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call struct { + *mock.Call +} + +// OnGetCompositeSchedule is a helper method to define mock.On call +// - request *smartcharging.GetCompositeScheduleRequest +func (_e *MockSmartChargingChargePointHandler_Expecter) OnGetCompositeSchedule(request interface{}) *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call { + return &MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call{Call: _e.mock.On("OnGetCompositeSchedule", request)} +} + +func (_c *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call) Run(run func(request *smartcharging.GetCompositeScheduleRequest)) *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*smartcharging.GetCompositeScheduleRequest)) + }) + return _c +} + +func (_c *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call) Return(confirmation *smartcharging.GetCompositeScheduleConfirmation, err error) *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call) RunAndReturn(run func(*smartcharging.GetCompositeScheduleRequest) (*smartcharging.GetCompositeScheduleConfirmation, error)) *MockSmartChargingChargePointHandler_OnGetCompositeSchedule_Call { + _c.Call.Return(run) + return _c +} + +// OnSetChargingProfile provides a mock function with given fields: request +func (_m *MockSmartChargingChargePointHandler) OnSetChargingProfile(request *smartcharging.SetChargingProfileRequest) (*smartcharging.SetChargingProfileConfirmation, error) { + ret := _m.Called(request) + + if len(ret) == 0 { + panic("no return value specified for OnSetChargingProfile") + } + + var r0 *smartcharging.SetChargingProfileConfirmation + var r1 error + if rf, ok := ret.Get(0).(func(*smartcharging.SetChargingProfileRequest) (*smartcharging.SetChargingProfileConfirmation, error)); ok { + return rf(request) + } + if rf, ok := ret.Get(0).(func(*smartcharging.SetChargingProfileRequest) *smartcharging.SetChargingProfileConfirmation); ok { + r0 = rf(request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*smartcharging.SetChargingProfileConfirmation) + } + } + + if rf, ok := ret.Get(1).(func(*smartcharging.SetChargingProfileRequest) error); ok { + r1 = rf(request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSmartChargingChargePointHandler_OnSetChargingProfile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnSetChargingProfile' +type MockSmartChargingChargePointHandler_OnSetChargingProfile_Call struct { + *mock.Call +} + +// OnSetChargingProfile is a helper method to define mock.On call +// - request *smartcharging.SetChargingProfileRequest +func (_e *MockSmartChargingChargePointHandler_Expecter) OnSetChargingProfile(request interface{}) *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call { + return &MockSmartChargingChargePointHandler_OnSetChargingProfile_Call{Call: _e.mock.On("OnSetChargingProfile", request)} +} + +func (_c *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call) Run(run func(request *smartcharging.SetChargingProfileRequest)) *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*smartcharging.SetChargingProfileRequest)) + }) + return _c +} + +func (_c *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call) Return(confirmation *smartcharging.SetChargingProfileConfirmation, err error) *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call { + _c.Call.Return(confirmation, err) + return _c +} + +func (_c *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call) RunAndReturn(run func(*smartcharging.SetChargingProfileRequest) (*smartcharging.SetChargingProfileConfirmation, error)) *MockSmartChargingChargePointHandler_OnSetChargingProfile_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSmartChargingChargePointHandler creates a new instance of MockSmartChargingChargePointHandler. 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 NewMockSmartChargingChargePointHandler(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSmartChargingChargePointHandler { + mock := &MockSmartChargingChargePointHandler{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ocpp1.6_test/ocpp16_extension_test.go b/ocpp1.6_test/ocpp16_extension_test.go index 6f5f9094..feae6509 100644 --- a/ocpp1.6_test/ocpp16_extension_test.go +++ b/ocpp1.6_test/ocpp16_extension_test.go @@ -1,109 +1,15 @@ package ocpp16_test import ( - "github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates" - "github.com/lorenzodonini/ocpp-go/ocpp1.6/extendedtriggermessage" - "github.com/lorenzodonini/ocpp-go/ocpp1.6/securefirmware" - "github.com/lorenzodonini/ocpp-go/ocpp1.6/security" - "github.com/stretchr/testify/mock" + "strings" ) -// ---------------------- MOCK CP SECURITY HANDLER ---------------------- -type MockChargePointSecurityHandler struct { - mock.Mock -} - -func (m *MockChargePointSecurityHandler) OnCertificateSigned(request *security.CertificateSignedRequest) (response *security.CertificateSignedResponse, err error) { - args := m.MethodCalled("OnCertificateSigned", request) - conf := args.Get(0).(*security.CertificateSignedResponse) - return conf, args.Error(1) -} - -// ---------------------- MOCK CS SECURITY HANDLER ---------------------- -type MockCentralSystemSecurityListener struct { - mock.Mock -} - -func (m *MockCentralSystemSecurityListener) OnSecurityEventNotification(chargingStationID string, request *security.SecurityEventNotificationRequest) (response *security.SecurityEventNotificationResponse, err error) { - args := m.MethodCalled("OnSecurityEventNotification", request) - conf := args.Get(0).(*security.SecurityEventNotificationResponse) - return conf, args.Error(1) -} - -func (m *MockCentralSystemSecurityListener) OnSignCertificate(chargingStationID string, request *security.SignCertificateRequest) (response *security.SignCertificateResponse, err error) { - args := m.MethodCalled("OnSignCertificate", request) - conf := args.Get(0).(*security.SignCertificateResponse) - return conf, args.Error(1) -} - -// ---------------------- MOCK CS CERTIFICATE HANDLER ---------------------- - -type MockCentralSystemCertificateListener struct { - mock.Mock -} - -// ---------------------- MOCK CP CERTIFICATE HANDLER ---------------------- - -type MockChargePointCertificateHandler struct { - mock.Mock -} - -func (m *MockChargePointCertificateHandler) OnDeleteCertificate(request *certificates.DeleteCertificateRequest) (response *certificates.DeleteCertificateResponse, err error) { - args := m.MethodCalled("OnDeleteCertificate", request) - conf := args.Get(0).(*certificates.DeleteCertificateResponse) - return conf, args.Error(1) -} - -func (m *MockChargePointCertificateHandler) OnGetInstalledCertificateIds(request *certificates.GetInstalledCertificateIdsRequest) (response *certificates.GetInstalledCertificateIdsResponse, err error) { - args := m.MethodCalled("OnGetInstalledCertificateIds", request) - conf := args.Get(0).(*certificates.GetInstalledCertificateIdsResponse) - return conf, args.Error(1) -} - -func (m *MockChargePointCertificateHandler) OnInstallCertificate(request *certificates.InstallCertificateRequest) (response *certificates.InstallCertificateResponse, err error) { - args := m.MethodCalled("OnInstallCertificate", request) - conf := args.Get(0).(*certificates.InstallCertificateResponse) - return conf, args.Error(1) -} - -// ---------------------- MOCK CS EXTENDED TRIGGER MESSAGE HANDLER ---------------------- - -type MockCentralSystemExtendedTriggerMessageListener struct { - mock.Mock -} - -// ---------------------- MOCK CP EXTENDED TRIGGER MESSAGE HANDLER ---------------------- - -type MockChargePointExtendedTriggerMessageHandler struct { - mock.Mock -} - -func (m *MockChargePointExtendedTriggerMessageHandler) OnExtendedTriggerMessage(request *extendedtriggermessage.ExtendedTriggerMessageRequest) (response *extendedtriggermessage.ExtendedTriggerMessageResponse, err error) { - args := m.MethodCalled("OnExtendedTriggerMessage", request) - conf := args.Get(0).(*extendedtriggermessage.ExtendedTriggerMessageResponse) - return conf, args.Error(1) -} - -// ---------------------- MOCK CS SECURE FIRMWARE UPDATE HANDLER ---------------------- - -type MockCentralSystemSecureFirmwareUpdateListener struct { - mock.Mock -} - -func (m *MockCentralSystemSecureFirmwareUpdateListener) OnSignedFirmwareStatusNotification(chargingStationID string, request *securefirmware.SignedFirmwareStatusNotificationRequest) (response *securefirmware.SignedFirmwareStatusNotificationResponse, err error) { - args := m.MethodCalled("OnSignedFirmwareStatusNotification", request) - conf := args.Get(0).(*securefirmware.SignedFirmwareStatusNotificationResponse) - return conf, args.Error(1) -} - -// ---------------------- MOCK CP SECURE FIRMWARE UPDATE HANDLER ---------------------- - -type MockChargePointSecureFirmwareUpdateHandler struct { - mock.Mock -} - -func (m *MockChargePointSecureFirmwareUpdateHandler) OnSignedUpdateFirmware(request *securefirmware.SignedUpdateFirmwareRequest) (response *securefirmware.SignedUpdateFirmwareResponse, err error) { - args := m.MethodCalled("OnSignedUpdateFirmware", request) - conf := args.Get(0).(*securefirmware.SignedUpdateFirmwareResponse) - return conf, args.Error(1) +// Generates a new dummy string of the specified length. +func newLongString(length int) string { + reps := length / 32 + s := strings.Repeat("................................", reps) + for i := len(s); i < length; i++ { + s += "." + } + return s } diff --git a/ocpp1.6_test/ocpp16_test.go b/ocpp1.6_test/ocpp16_test.go index 4a826bd1..9a701f58 100644 --- a/ocpp1.6_test/ocpp16_test.go +++ b/ocpp1.6_test/ocpp16_test.go @@ -9,21 +9,24 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/lorenzodonini/ocpp-go/ocpp" ocpp16 "github.com/lorenzodonini/ocpp-go/ocpp1.6" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/certificates" "github.com/lorenzodonini/ocpp-go/ocpp1.6/core" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/extendedtriggermessage" "github.com/lorenzodonini/ocpp-go/ocpp1.6/firmware" "github.com/lorenzodonini/ocpp-go/ocpp1.6/localauth" "github.com/lorenzodonini/ocpp-go/ocpp1.6/remotetrigger" "github.com/lorenzodonini/ocpp-go/ocpp1.6/reservation" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/securefirmware" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/security" "github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging" "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" "github.com/lorenzodonini/ocpp-go/ocppj" "github.com/lorenzodonini/ocpp-go/ws" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) @@ -692,14 +695,47 @@ func (suite *OcppV16TestSuite) SetupTest() { reservationProfile := reservation.Profile remoteTriggerProfile := remotetrigger.Profile smartChargingProfile := smartcharging.Profile + certificatesProfile := certificates.Profile + secureFirmwareUpdateProfile := securefirmware.Profile + extendedTriggerMessageProfile := extendedtriggermessage.Profile + securityProfile := security.Profile mockClient := MockWebsocketClient{} mockServer := MockWebsocketServer{} suite.mockWsClient = &mockClient suite.mockWsServer = &mockServer suite.clientDispatcher = ocppj.NewDefaultClientDispatcher(ocppj.NewFIFOClientQueue(queueCapacity)) suite.serverDispatcher = ocppj.NewDefaultServerDispatcher(ocppj.NewFIFOQueueMap(queueCapacity)) - suite.ocppjChargePoint = ocppj.NewClient("test_id", suite.mockWsClient, suite.clientDispatcher, nil, coreProfile, localAuthListProfile, firmwareProfile, reservationProfile, remoteTriggerProfile, smartChargingProfile) - suite.ocppjCentralSystem = ocppj.NewServer(suite.mockWsServer, suite.serverDispatcher, nil, coreProfile, localAuthListProfile, firmwareProfile, reservationProfile, remoteTriggerProfile, smartChargingProfile) + suite.ocppjChargePoint = ocppj.NewClient( + "test_id", + suite.mockWsClient, + suite.clientDispatcher, + nil, + coreProfile, + localAuthListProfile, + firmwareProfile, + reservationProfile, + remoteTriggerProfile, + smartChargingProfile, + certificatesProfile, + extendedTriggerMessageProfile, + securityProfile, + secureFirmwareUpdateProfile, + ) + suite.ocppjCentralSystem = ocppj.NewServer( + suite.mockWsServer, + suite.serverDispatcher, + nil, + coreProfile, + localAuthListProfile, + firmwareProfile, + reservationProfile, + remoteTriggerProfile, + smartChargingProfile, + certificatesProfile, + extendedTriggerMessageProfile, + securityProfile, + secureFirmwareUpdateProfile, + ) suite.chargePoint = ocpp16.NewChargePoint("test_id", suite.ocppjChargePoint, suite.mockWsClient) suite.centralSystem = ocpp16.NewCentralSystem(suite.ocppjCentralSystem, suite.mockWsServer) suite.messageIdGenerator = TestRandomIdGenerator{generator: func() string { diff --git a/ocpp1.6_test/sign_certificate_test.go b/ocpp1.6_test/sign_certificate_test.go new file mode 100644 index 00000000..17dbd375 --- /dev/null +++ b/ocpp1.6_test/sign_certificate_test.go @@ -0,0 +1,81 @@ +package ocpp16_test + +import ( + "fmt" + + "github.com/lorenzodonini/ocpp-go/ocpp1.6/security" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" + "github.com/lorenzodonini/ocpp-go/ocpp1.6_test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +// Test +func (suite *OcppV16TestSuite) TestSignCertificateRequestValidation() { + var requestTable = []GenericTestEntry{ + {security.SignCertificateRequest{CSR: "deadc0de", CertificateType: types.ChargingStationCert}, true}, + {security.SignCertificateRequest{CSR: "deadc0de"}, true}, + {security.SignCertificateRequest{}, false}, + {security.SignCertificateRequest{CSR: "deadc0de", CertificateType: "invalidType"}, false}, + } + ExecuteGenericTestTable(suite.T(), requestTable) +} + +func (suite *OcppV16TestSuite) TestSignCertificateConfirmationValidation() { + t := suite.T() + var confirmationTable = []GenericTestEntry{ + {security.SignCertificateResponse{Status: types.GenericStatusAccepted}, true}, + {security.SignCertificateResponse{Status: types.GenericStatusAccepted}, true}, + {security.SignCertificateResponse{}, false}, + {security.SignCertificateResponse{Status: "invalidStatus"}, false}, + } + ExecuteGenericTestTable(t, confirmationTable) +} + +func (suite *OcppV16TestSuite) TestSignCertificateE2EMocked() { + t := suite.T() + wsId := "test_id" + messageId := defaultMessageId + wsUrl := "someUrl" + csr := "deadc0de" + certificateType := types.ChargingStationCert + status := types.GenericStatusAccepted + requestJson := fmt.Sprintf(`[2,"%v","%v",{"csr":"%v","certificateType":"%v"}]`, + messageId, security.SignCertificateFeatureName, csr, certificateType) + responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v"}]`, messageId, status) + signCertificateResponse := security.NewSignCertificateResponse(status) + channel := NewMockWebSocket(wsId) + + handler := mocks.NewMockSecurityCentralSystemHandler(t) + handler.EXPECT().OnSignCertificate(wsId, mock.Anything).RunAndReturn(func(s string, request *security.SignCertificateRequest) (*security.SignCertificateResponse, error) { + assert.Equal(t, csr, request.CSR) + assert.Equal(t, certificateType, request.CertificateType) + return signCertificateResponse, nil + }) + + setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true}) + setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true}) + suite.centralSystem.SetSecurityHandler(handler) + + // Run Test + suite.centralSystem.Start(8887, "somePath") + err := suite.chargePoint.Start(wsUrl) + require.Nil(t, err) + response, err := suite.chargePoint.SignCertificate(csr, func(request *security.SignCertificateRequest) { + request.CertificateType = certificateType + }) + require.Nil(t, err) + require.NotNil(t, response) + assert.Equal(t, status, response.Status) +} + +func (suite *OcppV16TestSuite) TestSignCertificateInvalidEndpoint() { + messageId := defaultMessageId + csr := "deadc0de" + certificateType := types.ChargingStationCert + request := security.NewSignCertificateRequest(csr) + requestJson := fmt.Sprintf(`[2,"%v","%v",{"csr":"%v","certificateType":"%v"}]`, + messageId, security.SignCertificateFeatureName, csr, certificateType) + testUnsupportedRequestFromCentralSystem(suite, request, requestJson, messageId) +} diff --git a/ocpp1.6_test/signed_update_firmware_test.go b/ocpp1.6_test/signed_update_firmware_test.go new file mode 100644 index 00000000..561219ad --- /dev/null +++ b/ocpp1.6_test/signed_update_firmware_test.go @@ -0,0 +1,131 @@ +package ocpp16_test + +import ( + "fmt" + "time" + + "github.com/lorenzodonini/ocpp-go/ocpp1.6/securefirmware" + "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" + "github.com/lorenzodonini/ocpp-go/ocpp1.6_test/mocks" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +// Test +func (suite *OcppV16TestSuite) TestSignedUpdateFirmwareRequestValidation() { + t := suite.T() + fw := securefirmware.Firmware{ + Location: "https://someurl", + RetrieveDateTime: types.NewDateTime(time.Now()), + InstallDateTime: types.NewDateTime(time.Now()), + SigningCertificate: "1337c0de", + Signature: "deadc0de", + } + var requestTable = []GenericTestEntry{ + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(300), RequestID: 42, Firmware: fw}, true}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RequestID: 42, Firmware: fw}, true}, + {securefirmware.SignedUpdateFirmwareRequest{RequestID: 42, Firmware: fw}, true}, + {securefirmware.SignedUpdateFirmwareRequest{Firmware: fw}, true}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(300), RequestID: 42, Firmware: securefirmware.Firmware{Location: "https://someurl", RetrieveDateTime: types.NewDateTime(time.Now())}}, true}, + {securefirmware.SignedUpdateFirmwareRequest{}, false}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(-1), RetryInterval: newInt(300), RequestID: 42, Firmware: fw}, false}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(-1), RequestID: 42, Firmware: fw}, false}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(300), RequestID: -1, Firmware: fw}, false}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(300), RequestID: 42, Firmware: securefirmware.Firmware{RetrieveDateTime: types.NewDateTime(time.Now()), InstallDateTime: types.NewDateTime(time.Now()), SigningCertificate: "1337c0de", Signature: "deadc0de"}}, false}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(300), RequestID: 42, Firmware: securefirmware.Firmware{Location: "https://someurl", InstallDateTime: types.NewDateTime(time.Now()), SigningCertificate: "1337c0de", Signature: "deadc0de"}}, false}, + {securefirmware.SignedUpdateFirmwareRequest{Retries: newInt(5), RetryInterval: newInt(300), RequestID: 42, Firmware: securefirmware.Firmware{Location: ">512.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................", RetrieveDateTime: types.NewDateTime(time.Now()), InstallDateTime: types.NewDateTime(time.Now()), SigningCertificate: "1337c0de", Signature: "deadc0de"}}, false}, + } + ExecuteGenericTestTable(t, requestTable) +} + +func (suite *OcppV16TestSuite) TestSignedUpdateFirmwareResponseValidation() { + t := suite.T() + var responseTable = []GenericTestEntry{ + {securefirmware.SignedUpdateFirmwareResponse{Status: securefirmware.UpdateFirmwareStatusAccepted}, true}, + {securefirmware.SignedUpdateFirmwareResponse{Status: securefirmware.UpdateFirmwareStatusAccepted}, true}, + {securefirmware.SignedUpdateFirmwareResponse{Status: securefirmware.UpdateFirmwareStatusAccepted}, true}, + {securefirmware.SignedUpdateFirmwareResponse{}, false}, + {securefirmware.SignedUpdateFirmwareResponse{Status: "invalidFirmwareUpdateStatus"}, false}, + } + ExecuteGenericTestTable(t, responseTable) +} + +func (suite *OcppV16TestSuite) TestSignedUpdateFirmwareE2EMocked() { + t := suite.T() + wsId := "test_id" + messageId := defaultMessageId + wsUrl := "someUrl" + fw := securefirmware.Firmware{ + Location: "https://someurl", + RetrieveDateTime: types.NewDateTime(time.Now()), + InstallDateTime: types.NewDateTime(time.Now()), + SigningCertificate: "1337c0de", + Signature: "deadc0de", + } + retries := newInt(5) + requestID := 42 + retryInterval := newInt(300) + status := securefirmware.UpdateFirmwareStatusAccepted + requestJson := fmt.Sprintf(`[2,"%v","%v",{"retries":%v,"retryInterval":%v,"requestId":%v,"firmware":{"location":"%v","retrieveDateTime":"%v","installDateTime":"%v","signingCertificate":"%v","signature":"%v"}}]`, + messageId, securefirmware.SignedUpdateFirmwareFeatureName, *retries, *retryInterval, requestID, fw.Location, fw.RetrieveDateTime.FormatTimestamp(), fw.InstallDateTime.FormatTimestamp(), fw.SigningCertificate, fw.Signature) + responseJson := fmt.Sprintf(`[3,"%v",{"status":"%v"}]`, messageId, status) + updateFirmwareResponse := securefirmware.NewSignedUpdateFirmwareResponse(status) + channel := NewMockWebSocket(wsId) + + handler := mocks.NewMockSecureFirmwareChargePointHandler(t) + handler.EXPECT().OnSignedUpdateFirmware(mock.Anything).RunAndReturn(func(request *securefirmware.SignedUpdateFirmwareRequest) (*securefirmware.SignedUpdateFirmwareResponse, error) { + assert.Equal(t, *retries, *request.Retries) + assert.Equal(t, *retryInterval, *request.RetryInterval) + assert.Equal(t, requestID, request.RequestID) + assert.Equal(t, fw.Location, request.Firmware.Location) + assertDateTimeEquality(t, *fw.RetrieveDateTime, *request.Firmware.RetrieveDateTime) + assertDateTimeEquality(t, *fw.InstallDateTime, *request.Firmware.InstallDateTime) + assert.Equal(t, fw.SigningCertificate, request.Firmware.SigningCertificate) + assert.Equal(t, fw.Signature, request.Firmware.Signature) + + return updateFirmwareResponse, nil + }) + + setupDefaultCentralSystemHandlers(suite, nil, expectedCentralSystemOptions{clientId: wsId, rawWrittenMessage: []byte(requestJson), forwardWrittenMessage: true}) + setupDefaultChargePointHandlers(suite, nil, expectedChargePointOptions{serverUrl: wsUrl, clientId: wsId, createChannelOnStart: true, channel: channel, rawWrittenMessage: []byte(responseJson), forwardWrittenMessage: true}) + suite.chargePoint.SetSecureFirmwareHandler(handler) + + // Run Test + suite.centralSystem.Start(8887, "somePath") + err := suite.chargePoint.Start(wsUrl) + assert.Nil(t, err) + resultChannel := make(chan bool, 1) + err = suite.centralSystem.SignedUpdateFirmware(wsId, func(resp *securefirmware.SignedUpdateFirmwareResponse, err error) { + assert.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, status, resp.Status) + resultChannel <- true + }, requestID, fw, func(request *securefirmware.SignedUpdateFirmwareRequest) { + request.Retries = retries + request.RetryInterval = retryInterval + }) + require.Nil(t, err) + result := <-resultChannel + assert.True(t, result) +} + +func (suite *OcppV16TestSuite) TestSignedUpdateFirmwareInvalidEndpoint() { + messageId := defaultMessageId + fw := securefirmware.Firmware{ + Location: "https://someurl", + RetrieveDateTime: types.NewDateTime(time.Now()), + InstallDateTime: types.NewDateTime(time.Now()), + SigningCertificate: "1337c0de", + Signature: "deadc0de", + } + retries := newInt(5) + requestID := 42 + retryInterval := newInt(300) + request := securefirmware.NewSignedUpdateFirmwareRequest(requestID, fw) + request.Retries = retries + request.RetryInterval = retryInterval + requestJson := fmt.Sprintf(`[2,"%v","%v",{"retries":%v,"retryInterval":%v,"requestId":%v,"firmware":{"location":"%v","retrieveDateTime":"%v","installDateTime":"%v","signingCertificate":"%v","signature":"%v"}}]`, + messageId, securefirmware.SignedUpdateFirmwareFeatureName, *retries, *retryInterval, requestID, fw.Location, fw.RetrieveDateTime.FormatTimestamp(), fw.InstallDateTime.FormatTimestamp(), fw.SigningCertificate, fw.Signature) + testUnsupportedRequestFromChargePoint(suite, request, requestJson, messageId) +} diff --git a/ocppj/mocks/mock_RequestQueue.go b/ocppj/mocks/mock_RequestQueue.go new file mode 100644 index 00000000..1a4f9264 --- /dev/null +++ b/ocppj/mocks/mock_RequestQueue.go @@ -0,0 +1,339 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockRequestQueue is an autogenerated mock type for the RequestQueue type +type MockRequestQueue struct { + mock.Mock +} + +type MockRequestQueue_Expecter struct { + mock *mock.Mock +} + +func (_m *MockRequestQueue) EXPECT() *MockRequestQueue_Expecter { + return &MockRequestQueue_Expecter{mock: &_m.Mock} +} + +// Init provides a mock function with given fields: +func (_m *MockRequestQueue) Init() { + _m.Called() +} + +// MockRequestQueue_Init_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Init' +type MockRequestQueue_Init_Call struct { + *mock.Call +} + +// Init is a helper method to define mock.On call +func (_e *MockRequestQueue_Expecter) Init() *MockRequestQueue_Init_Call { + return &MockRequestQueue_Init_Call{Call: _e.mock.On("Init")} +} + +func (_c *MockRequestQueue_Init_Call) Run(run func()) *MockRequestQueue_Init_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockRequestQueue_Init_Call) Return() *MockRequestQueue_Init_Call { + _c.Call.Return() + return _c +} + +func (_c *MockRequestQueue_Init_Call) RunAndReturn(run func()) *MockRequestQueue_Init_Call { + _c.Call.Return(run) + return _c +} + +// IsEmpty provides a mock function with given fields: +func (_m *MockRequestQueue) IsEmpty() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsEmpty") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockRequestQueue_IsEmpty_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsEmpty' +type MockRequestQueue_IsEmpty_Call struct { + *mock.Call +} + +// IsEmpty is a helper method to define mock.On call +func (_e *MockRequestQueue_Expecter) IsEmpty() *MockRequestQueue_IsEmpty_Call { + return &MockRequestQueue_IsEmpty_Call{Call: _e.mock.On("IsEmpty")} +} + +func (_c *MockRequestQueue_IsEmpty_Call) Run(run func()) *MockRequestQueue_IsEmpty_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockRequestQueue_IsEmpty_Call) Return(_a0 bool) *MockRequestQueue_IsEmpty_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRequestQueue_IsEmpty_Call) RunAndReturn(run func() bool) *MockRequestQueue_IsEmpty_Call { + _c.Call.Return(run) + return _c +} + +// IsFull provides a mock function with given fields: +func (_m *MockRequestQueue) IsFull() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsFull") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockRequestQueue_IsFull_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsFull' +type MockRequestQueue_IsFull_Call struct { + *mock.Call +} + +// IsFull is a helper method to define mock.On call +func (_e *MockRequestQueue_Expecter) IsFull() *MockRequestQueue_IsFull_Call { + return &MockRequestQueue_IsFull_Call{Call: _e.mock.On("IsFull")} +} + +func (_c *MockRequestQueue_IsFull_Call) Run(run func()) *MockRequestQueue_IsFull_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockRequestQueue_IsFull_Call) Return(_a0 bool) *MockRequestQueue_IsFull_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRequestQueue_IsFull_Call) RunAndReturn(run func() bool) *MockRequestQueue_IsFull_Call { + _c.Call.Return(run) + return _c +} + +// Peek provides a mock function with given fields: +func (_m *MockRequestQueue) Peek() interface{} { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Peek") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func() interface{}); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// MockRequestQueue_Peek_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Peek' +type MockRequestQueue_Peek_Call struct { + *mock.Call +} + +// Peek is a helper method to define mock.On call +func (_e *MockRequestQueue_Expecter) Peek() *MockRequestQueue_Peek_Call { + return &MockRequestQueue_Peek_Call{Call: _e.mock.On("Peek")} +} + +func (_c *MockRequestQueue_Peek_Call) Run(run func()) *MockRequestQueue_Peek_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockRequestQueue_Peek_Call) Return(_a0 interface{}) *MockRequestQueue_Peek_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRequestQueue_Peek_Call) RunAndReturn(run func() interface{}) *MockRequestQueue_Peek_Call { + _c.Call.Return(run) + return _c +} + +// Pop provides a mock function with given fields: +func (_m *MockRequestQueue) Pop() interface{} { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Pop") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func() interface{}); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// MockRequestQueue_Pop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Pop' +type MockRequestQueue_Pop_Call struct { + *mock.Call +} + +// Pop is a helper method to define mock.On call +func (_e *MockRequestQueue_Expecter) Pop() *MockRequestQueue_Pop_Call { + return &MockRequestQueue_Pop_Call{Call: _e.mock.On("Pop")} +} + +func (_c *MockRequestQueue_Pop_Call) Run(run func()) *MockRequestQueue_Pop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockRequestQueue_Pop_Call) Return(_a0 interface{}) *MockRequestQueue_Pop_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRequestQueue_Pop_Call) RunAndReturn(run func() interface{}) *MockRequestQueue_Pop_Call { + _c.Call.Return(run) + return _c +} + +// Push provides a mock function with given fields: element +func (_m *MockRequestQueue) Push(element interface{}) error { + ret := _m.Called(element) + + if len(ret) == 0 { + panic("no return value specified for Push") + } + + var r0 error + if rf, ok := ret.Get(0).(func(interface{}) error); ok { + r0 = rf(element) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockRequestQueue_Push_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Push' +type MockRequestQueue_Push_Call struct { + *mock.Call +} + +// Push is a helper method to define mock.On call +// - element interface{} +func (_e *MockRequestQueue_Expecter) Push(element interface{}) *MockRequestQueue_Push_Call { + return &MockRequestQueue_Push_Call{Call: _e.mock.On("Push", element)} +} + +func (_c *MockRequestQueue_Push_Call) Run(run func(element interface{})) *MockRequestQueue_Push_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{})) + }) + return _c +} + +func (_c *MockRequestQueue_Push_Call) Return(_a0 error) *MockRequestQueue_Push_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRequestQueue_Push_Call) RunAndReturn(run func(interface{}) error) *MockRequestQueue_Push_Call { + _c.Call.Return(run) + return _c +} + +// Size provides a mock function with given fields: +func (_m *MockRequestQueue) Size() int { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Size") + } + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// MockRequestQueue_Size_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Size' +type MockRequestQueue_Size_Call struct { + *mock.Call +} + +// Size is a helper method to define mock.On call +func (_e *MockRequestQueue_Expecter) Size() *MockRequestQueue_Size_Call { + return &MockRequestQueue_Size_Call{Call: _e.mock.On("Size")} +} + +func (_c *MockRequestQueue_Size_Call) Run(run func()) *MockRequestQueue_Size_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockRequestQueue_Size_Call) Return(_a0 int) *MockRequestQueue_Size_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRequestQueue_Size_Call) RunAndReturn(run func() int) *MockRequestQueue_Size_Call { + _c.Call.Return(run) + return _c +} + +// NewMockRequestQueue creates a new instance of MockRequestQueue. 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 NewMockRequestQueue(t interface { + mock.TestingT + Cleanup(func()) +}) *MockRequestQueue { + mock := &MockRequestQueue{} + 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 new file mode 100644 index 00000000..50295818 --- /dev/null +++ b/ocppj/mocks/mock_ServerQueueMap.go @@ -0,0 +1,240 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + ocppj "github.com/lorenzodonini/ocpp-go/ocppj" + mock "github.com/stretchr/testify/mock" +) + +// MockServerQueueMap is an autogenerated mock type for the ServerQueueMap type +type MockServerQueueMap struct { + mock.Mock +} + +type MockServerQueueMap_Expecter struct { + mock *mock.Mock +} + +func (_m *MockServerQueueMap) EXPECT() *MockServerQueueMap_Expecter { + return &MockServerQueueMap_Expecter{mock: &_m.Mock} +} + +// Add provides a mock function with given fields: clientID, queue +func (_m *MockServerQueueMap) Add(clientID string, queue ocppj.RequestQueue) { + _m.Called(clientID, queue) +} + +// MockServerQueueMap_Add_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Add' +type MockServerQueueMap_Add_Call struct { + *mock.Call +} + +// Add is a helper method to define mock.On call +// - clientID string +// - queue ocppj.RequestQueue +func (_e *MockServerQueueMap_Expecter) Add(clientID interface{}, queue interface{}) *MockServerQueueMap_Add_Call { + return &MockServerQueueMap_Add_Call{Call: _e.mock.On("Add", clientID, queue)} +} + +func (_c *MockServerQueueMap_Add_Call) Run(run func(clientID string, queue ocppj.RequestQueue)) *MockServerQueueMap_Add_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(ocppj.RequestQueue)) + }) + return _c +} + +func (_c *MockServerQueueMap_Add_Call) Return() *MockServerQueueMap_Add_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerQueueMap_Add_Call) RunAndReturn(run func(string, ocppj.RequestQueue)) *MockServerQueueMap_Add_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: clientID +func (_m *MockServerQueueMap) Get(clientID string) (ocppj.RequestQueue, bool) { + ret := _m.Called(clientID) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 ocppj.RequestQueue + var r1 bool + if rf, ok := ret.Get(0).(func(string) (ocppj.RequestQueue, bool)); ok { + return rf(clientID) + } + if rf, ok := ret.Get(0).(func(string) ocppj.RequestQueue); ok { + r0 = rf(clientID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(ocppj.RequestQueue) + } + } + + if rf, ok := ret.Get(1).(func(string) bool); ok { + r1 = rf(clientID) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// MockServerQueueMap_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockServerQueueMap_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - clientID string +func (_e *MockServerQueueMap_Expecter) Get(clientID interface{}) *MockServerQueueMap_Get_Call { + return &MockServerQueueMap_Get_Call{Call: _e.mock.On("Get", clientID)} +} + +func (_c *MockServerQueueMap_Get_Call) Run(run func(clientID string)) *MockServerQueueMap_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerQueueMap_Get_Call) Return(_a0 ocppj.RequestQueue, _a1 bool) *MockServerQueueMap_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockServerQueueMap_Get_Call) RunAndReturn(run func(string) (ocppj.RequestQueue, bool)) *MockServerQueueMap_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetOrCreate provides a mock function with given fields: clientID +func (_m *MockServerQueueMap) GetOrCreate(clientID string) ocppj.RequestQueue { + ret := _m.Called(clientID) + + if len(ret) == 0 { + panic("no return value specified for GetOrCreate") + } + + var r0 ocppj.RequestQueue + if rf, ok := ret.Get(0).(func(string) ocppj.RequestQueue); ok { + r0 = rf(clientID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(ocppj.RequestQueue) + } + } + + return r0 +} + +// MockServerQueueMap_GetOrCreate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrCreate' +type MockServerQueueMap_GetOrCreate_Call struct { + *mock.Call +} + +// GetOrCreate is a helper method to define mock.On call +// - clientID string +func (_e *MockServerQueueMap_Expecter) GetOrCreate(clientID interface{}) *MockServerQueueMap_GetOrCreate_Call { + return &MockServerQueueMap_GetOrCreate_Call{Call: _e.mock.On("GetOrCreate", clientID)} +} + +func (_c *MockServerQueueMap_GetOrCreate_Call) Run(run func(clientID string)) *MockServerQueueMap_GetOrCreate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerQueueMap_GetOrCreate_Call) Return(_a0 ocppj.RequestQueue) *MockServerQueueMap_GetOrCreate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockServerQueueMap_GetOrCreate_Call) RunAndReturn(run func(string) ocppj.RequestQueue) *MockServerQueueMap_GetOrCreate_Call { + _c.Call.Return(run) + return _c +} + +// Init provides a mock function with given fields: +func (_m *MockServerQueueMap) Init() { + _m.Called() +} + +// MockServerQueueMap_Init_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Init' +type MockServerQueueMap_Init_Call struct { + *mock.Call +} + +// Init is a helper method to define mock.On call +func (_e *MockServerQueueMap_Expecter) Init() *MockServerQueueMap_Init_Call { + return &MockServerQueueMap_Init_Call{Call: _e.mock.On("Init")} +} + +func (_c *MockServerQueueMap_Init_Call) Run(run func()) *MockServerQueueMap_Init_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockServerQueueMap_Init_Call) Return() *MockServerQueueMap_Init_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerQueueMap_Init_Call) RunAndReturn(run func()) *MockServerQueueMap_Init_Call { + _c.Call.Return(run) + return _c +} + +// Remove provides a mock function with given fields: clientID +func (_m *MockServerQueueMap) Remove(clientID string) { + _m.Called(clientID) +} + +// MockServerQueueMap_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' +type MockServerQueueMap_Remove_Call struct { + *mock.Call +} + +// Remove is a helper method to define mock.On call +// - clientID string +func (_e *MockServerQueueMap_Expecter) Remove(clientID interface{}) *MockServerQueueMap_Remove_Call { + return &MockServerQueueMap_Remove_Call{Call: _e.mock.On("Remove", clientID)} +} + +func (_c *MockServerQueueMap_Remove_Call) Run(run func(clientID string)) *MockServerQueueMap_Remove_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockServerQueueMap_Remove_Call) Return() *MockServerQueueMap_Remove_Call { + _c.Call.Return() + return _c +} + +func (_c *MockServerQueueMap_Remove_Call) RunAndReturn(run func(string)) *MockServerQueueMap_Remove_Call { + _c.Call.Return(run) + return _c +} + +// NewMockServerQueueMap creates a new instance of MockServerQueueMap. 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 NewMockServerQueueMap(t interface { + mock.TestingT + Cleanup(func()) +}) *MockServerQueueMap { + mock := &MockServerQueueMap{} + 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 new file mode 100644 index 00000000..1c3d4fbc --- /dev/null +++ b/ws/mocks/mock_Channel.go @@ -0,0 +1,177 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + net "net" + + mock "github.com/stretchr/testify/mock" + + tls "crypto/tls" +) + +// MockChannel is an autogenerated mock type for the Channel type +type MockChannel struct { + mock.Mock +} + +type MockChannel_Expecter struct { + mock *mock.Mock +} + +func (_m *MockChannel) EXPECT() *MockChannel_Expecter { + return &MockChannel_Expecter{mock: &_m.Mock} +} + +// ID provides a mock function with given fields: +func (_m *MockChannel) ID() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ID") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockChannel_ID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ID' +type MockChannel_ID_Call struct { + *mock.Call +} + +// ID is a helper method to define mock.On call +func (_e *MockChannel_Expecter) ID() *MockChannel_ID_Call { + return &MockChannel_ID_Call{Call: _e.mock.On("ID")} +} + +func (_c *MockChannel_ID_Call) Run(run func()) *MockChannel_ID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockChannel_ID_Call) Return(_a0 string) *MockChannel_ID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockChannel_ID_Call) RunAndReturn(run func() string) *MockChannel_ID_Call { + _c.Call.Return(run) + return _c +} + +// RemoteAddr provides a mock function with given fields: +func (_m *MockChannel) RemoteAddr() net.Addr { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteAddr") + } + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// MockChannel_RemoteAddr_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteAddr' +type MockChannel_RemoteAddr_Call struct { + *mock.Call +} + +// RemoteAddr is a helper method to define mock.On call +func (_e *MockChannel_Expecter) RemoteAddr() *MockChannel_RemoteAddr_Call { + return &MockChannel_RemoteAddr_Call{Call: _e.mock.On("RemoteAddr")} +} + +func (_c *MockChannel_RemoteAddr_Call) Run(run func()) *MockChannel_RemoteAddr_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockChannel_RemoteAddr_Call) Return(_a0 net.Addr) *MockChannel_RemoteAddr_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockChannel_RemoteAddr_Call) RunAndReturn(run func() net.Addr) *MockChannel_RemoteAddr_Call { + _c.Call.Return(run) + return _c +} + +// TLSConnectionState provides a mock function with given fields: +func (_m *MockChannel) TLSConnectionState() *tls.ConnectionState { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for TLSConnectionState") + } + + var r0 *tls.ConnectionState + if rf, ok := ret.Get(0).(func() *tls.ConnectionState); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*tls.ConnectionState) + } + } + + return r0 +} + +// MockChannel_TLSConnectionState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TLSConnectionState' +type MockChannel_TLSConnectionState_Call struct { + *mock.Call +} + +// TLSConnectionState is a helper method to define mock.On call +func (_e *MockChannel_Expecter) TLSConnectionState() *MockChannel_TLSConnectionState_Call { + return &MockChannel_TLSConnectionState_Call{Call: _e.mock.On("TLSConnectionState")} +} + +func (_c *MockChannel_TLSConnectionState_Call) Run(run func()) *MockChannel_TLSConnectionState_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockChannel_TLSConnectionState_Call) Return(_a0 *tls.ConnectionState) *MockChannel_TLSConnectionState_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockChannel_TLSConnectionState_Call) RunAndReturn(run func() *tls.ConnectionState) *MockChannel_TLSConnectionState_Call { + _c.Call.Return(run) + return _c +} + +// NewMockChannel creates a new instance of MockChannel. 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 NewMockChannel(t interface { + mock.TestingT + Cleanup(func()) +}) *MockChannel { + mock := &MockChannel{} + 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 new file mode 100644 index 00000000..cdaa2e33 --- /dev/null +++ b/ws/mocks/mock_WsClient.go @@ -0,0 +1,550 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + ws "github.com/lorenzodonini/ocpp-go/ws" + mock "github.com/stretchr/testify/mock" +) + +// MockWsClient is an autogenerated mock type for the WsClient type +type MockWsClient struct { + mock.Mock +} + +type MockWsClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockWsClient) EXPECT() *MockWsClient_Expecter { + return &MockWsClient_Expecter{mock: &_m.Mock} +} + +// AddOption provides a mock function with given fields: option +func (_m *MockWsClient) AddOption(option interface{}) { + _m.Called(option) +} + +// MockWsClient_AddOption_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddOption' +type MockWsClient_AddOption_Call struct { + *mock.Call +} + +// AddOption is a helper method to define mock.On call +// - option interface{} +func (_e *MockWsClient_Expecter) AddOption(option interface{}) *MockWsClient_AddOption_Call { + return &MockWsClient_AddOption_Call{Call: _e.mock.On("AddOption", option)} +} + +func (_c *MockWsClient_AddOption_Call) Run(run func(option interface{})) *MockWsClient_AddOption_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{})) + }) + return _c +} + +func (_c *MockWsClient_AddOption_Call) Return() *MockWsClient_AddOption_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_AddOption_Call) RunAndReturn(run func(interface{})) *MockWsClient_AddOption_Call { + _c.Call.Return(run) + return _c +} + +// Errors provides a mock function with given fields: +func (_m *MockWsClient) Errors() <-chan error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Errors") + } + + var r0 <-chan error + if rf, ok := ret.Get(0).(func() <-chan error); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(<-chan error) + } + } + + return r0 +} + +// MockWsClient_Errors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Errors' +type MockWsClient_Errors_Call struct { + *mock.Call +} + +// Errors is a helper method to define mock.On call +func (_e *MockWsClient_Expecter) Errors() *MockWsClient_Errors_Call { + return &MockWsClient_Errors_Call{Call: _e.mock.On("Errors")} +} + +func (_c *MockWsClient_Errors_Call) Run(run func()) *MockWsClient_Errors_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWsClient_Errors_Call) Return(_a0 <-chan error) *MockWsClient_Errors_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsClient_Errors_Call) RunAndReturn(run func() <-chan error) *MockWsClient_Errors_Call { + _c.Call.Return(run) + return _c +} + +// IsConnected provides a mock function with given fields: +func (_m *MockWsClient) IsConnected() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockWsClient_IsConnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsConnected' +type MockWsClient_IsConnected_Call struct { + *mock.Call +} + +// IsConnected is a helper method to define mock.On call +func (_e *MockWsClient_Expecter) IsConnected() *MockWsClient_IsConnected_Call { + return &MockWsClient_IsConnected_Call{Call: _e.mock.On("IsConnected")} +} + +func (_c *MockWsClient_IsConnected_Call) Run(run func()) *MockWsClient_IsConnected_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWsClient_IsConnected_Call) Return(_a0 bool) *MockWsClient_IsConnected_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsClient_IsConnected_Call) RunAndReturn(run func() bool) *MockWsClient_IsConnected_Call { + _c.Call.Return(run) + return _c +} + +// SetBasicAuth provides a mock function with given fields: username, password +func (_m *MockWsClient) SetBasicAuth(username string, password string) { + _m.Called(username, password) +} + +// MockWsClient_SetBasicAuth_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetBasicAuth' +type MockWsClient_SetBasicAuth_Call struct { + *mock.Call +} + +// SetBasicAuth is a helper method to define mock.On call +// - username string +// - password string +func (_e *MockWsClient_Expecter) SetBasicAuth(username interface{}, password interface{}) *MockWsClient_SetBasicAuth_Call { + return &MockWsClient_SetBasicAuth_Call{Call: _e.mock.On("SetBasicAuth", username, password)} +} + +func (_c *MockWsClient_SetBasicAuth_Call) Run(run func(username string, password string)) *MockWsClient_SetBasicAuth_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *MockWsClient_SetBasicAuth_Call) Return() *MockWsClient_SetBasicAuth_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetBasicAuth_Call) RunAndReturn(run func(string, string)) *MockWsClient_SetBasicAuth_Call { + _c.Call.Return(run) + return _c +} + +// SetDisconnectedHandler provides a mock function with given fields: handler +func (_m *MockWsClient) SetDisconnectedHandler(handler func(error)) { + _m.Called(handler) +} + +// MockWsClient_SetDisconnectedHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDisconnectedHandler' +type MockWsClient_SetDisconnectedHandler_Call struct { + *mock.Call +} + +// SetDisconnectedHandler is a helper method to define mock.On call +// - handler func(error) +func (_e *MockWsClient_Expecter) SetDisconnectedHandler(handler interface{}) *MockWsClient_SetDisconnectedHandler_Call { + return &MockWsClient_SetDisconnectedHandler_Call{Call: _e.mock.On("SetDisconnectedHandler", handler)} +} + +func (_c *MockWsClient_SetDisconnectedHandler_Call) Run(run func(handler func(error))) *MockWsClient_SetDisconnectedHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(error))) + }) + return _c +} + +func (_c *MockWsClient_SetDisconnectedHandler_Call) Return() *MockWsClient_SetDisconnectedHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetDisconnectedHandler_Call) RunAndReturn(run func(func(error))) *MockWsClient_SetDisconnectedHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetHeaderValue provides a mock function with given fields: key, value +func (_m *MockWsClient) SetHeaderValue(key string, value string) { + _m.Called(key, value) +} + +// MockWsClient_SetHeaderValue_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHeaderValue' +type MockWsClient_SetHeaderValue_Call struct { + *mock.Call +} + +// SetHeaderValue is a helper method to define mock.On call +// - key string +// - value string +func (_e *MockWsClient_Expecter) SetHeaderValue(key interface{}, value interface{}) *MockWsClient_SetHeaderValue_Call { + return &MockWsClient_SetHeaderValue_Call{Call: _e.mock.On("SetHeaderValue", key, value)} +} + +func (_c *MockWsClient_SetHeaderValue_Call) Run(run func(key string, value string)) *MockWsClient_SetHeaderValue_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *MockWsClient_SetHeaderValue_Call) Return() *MockWsClient_SetHeaderValue_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetHeaderValue_Call) RunAndReturn(run func(string, string)) *MockWsClient_SetHeaderValue_Call { + _c.Call.Return(run) + return _c +} + +// SetMessageHandler provides a mock function with given fields: handler +func (_m *MockWsClient) SetMessageHandler(handler func([]byte) error) { + _m.Called(handler) +} + +// MockWsClient_SetMessageHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMessageHandler' +type MockWsClient_SetMessageHandler_Call struct { + *mock.Call +} + +// SetMessageHandler is a helper method to define mock.On call +// - handler func([]byte) error +func (_e *MockWsClient_Expecter) SetMessageHandler(handler interface{}) *MockWsClient_SetMessageHandler_Call { + return &MockWsClient_SetMessageHandler_Call{Call: _e.mock.On("SetMessageHandler", handler)} +} + +func (_c *MockWsClient_SetMessageHandler_Call) Run(run func(handler func([]byte) error)) *MockWsClient_SetMessageHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func([]byte) error)) + }) + return _c +} + +func (_c *MockWsClient_SetMessageHandler_Call) Return() *MockWsClient_SetMessageHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetMessageHandler_Call) RunAndReturn(run func(func([]byte) error)) *MockWsClient_SetMessageHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetReconnectedHandler provides a mock function with given fields: handler +func (_m *MockWsClient) SetReconnectedHandler(handler func()) { + _m.Called(handler) +} + +// MockWsClient_SetReconnectedHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetReconnectedHandler' +type MockWsClient_SetReconnectedHandler_Call struct { + *mock.Call +} + +// SetReconnectedHandler is a helper method to define mock.On call +// - handler func() +func (_e *MockWsClient_Expecter) SetReconnectedHandler(handler interface{}) *MockWsClient_SetReconnectedHandler_Call { + return &MockWsClient_SetReconnectedHandler_Call{Call: _e.mock.On("SetReconnectedHandler", handler)} +} + +func (_c *MockWsClient_SetReconnectedHandler_Call) Run(run func(handler func())) *MockWsClient_SetReconnectedHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func())) + }) + return _c +} + +func (_c *MockWsClient_SetReconnectedHandler_Call) Return() *MockWsClient_SetReconnectedHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetReconnectedHandler_Call) RunAndReturn(run func(func())) *MockWsClient_SetReconnectedHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetRequestedSubProtocol provides a mock function with given fields: subProto +func (_m *MockWsClient) SetRequestedSubProtocol(subProto string) { + _m.Called(subProto) +} + +// MockWsClient_SetRequestedSubProtocol_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetRequestedSubProtocol' +type MockWsClient_SetRequestedSubProtocol_Call struct { + *mock.Call +} + +// SetRequestedSubProtocol is a helper method to define mock.On call +// - subProto string +func (_e *MockWsClient_Expecter) SetRequestedSubProtocol(subProto interface{}) *MockWsClient_SetRequestedSubProtocol_Call { + return &MockWsClient_SetRequestedSubProtocol_Call{Call: _e.mock.On("SetRequestedSubProtocol", subProto)} +} + +func (_c *MockWsClient_SetRequestedSubProtocol_Call) Run(run func(subProto string)) *MockWsClient_SetRequestedSubProtocol_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockWsClient_SetRequestedSubProtocol_Call) Return() *MockWsClient_SetRequestedSubProtocol_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetRequestedSubProtocol_Call) RunAndReturn(run func(string)) *MockWsClient_SetRequestedSubProtocol_Call { + _c.Call.Return(run) + return _c +} + +// SetTimeoutConfig provides a mock function with given fields: config +func (_m *MockWsClient) SetTimeoutConfig(config ws.ClientTimeoutConfig) { + _m.Called(config) +} + +// MockWsClient_SetTimeoutConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTimeoutConfig' +type MockWsClient_SetTimeoutConfig_Call struct { + *mock.Call +} + +// SetTimeoutConfig is a helper method to define mock.On call +// - config ws.ClientTimeoutConfig +func (_e *MockWsClient_Expecter) SetTimeoutConfig(config interface{}) *MockWsClient_SetTimeoutConfig_Call { + return &MockWsClient_SetTimeoutConfig_Call{Call: _e.mock.On("SetTimeoutConfig", config)} +} + +func (_c *MockWsClient_SetTimeoutConfig_Call) Run(run func(config ws.ClientTimeoutConfig)) *MockWsClient_SetTimeoutConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.ClientTimeoutConfig)) + }) + return _c +} + +func (_c *MockWsClient_SetTimeoutConfig_Call) Return() *MockWsClient_SetTimeoutConfig_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_SetTimeoutConfig_Call) RunAndReturn(run func(ws.ClientTimeoutConfig)) *MockWsClient_SetTimeoutConfig_Call { + _c.Call.Return(run) + return _c +} + +// Start provides a mock function with given fields: url +func (_m *MockWsClient) Start(url string) error { + ret := _m.Called(url) + + if len(ret) == 0 { + panic("no return value specified for Start") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(url) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockWsClient_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type MockWsClient_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +// - url string +func (_e *MockWsClient_Expecter) Start(url interface{}) *MockWsClient_Start_Call { + return &MockWsClient_Start_Call{Call: _e.mock.On("Start", url)} +} + +func (_c *MockWsClient_Start_Call) Run(run func(url string)) *MockWsClient_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockWsClient_Start_Call) Return(_a0 error) *MockWsClient_Start_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsClient_Start_Call) RunAndReturn(run func(string) error) *MockWsClient_Start_Call { + _c.Call.Return(run) + return _c +} + +// StartWithRetries provides a mock function with given fields: url +func (_m *MockWsClient) StartWithRetries(url string) { + _m.Called(url) +} + +// MockWsClient_StartWithRetries_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartWithRetries' +type MockWsClient_StartWithRetries_Call struct { + *mock.Call +} + +// StartWithRetries is a helper method to define mock.On call +// - url string +func (_e *MockWsClient_Expecter) StartWithRetries(url interface{}) *MockWsClient_StartWithRetries_Call { + return &MockWsClient_StartWithRetries_Call{Call: _e.mock.On("StartWithRetries", url)} +} + +func (_c *MockWsClient_StartWithRetries_Call) Run(run func(url string)) *MockWsClient_StartWithRetries_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockWsClient_StartWithRetries_Call) Return() *MockWsClient_StartWithRetries_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_StartWithRetries_Call) RunAndReturn(run func(string)) *MockWsClient_StartWithRetries_Call { + _c.Call.Return(run) + return _c +} + +// Stop provides a mock function with given fields: +func (_m *MockWsClient) Stop() { + _m.Called() +} + +// MockWsClient_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type MockWsClient_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *MockWsClient_Expecter) Stop() *MockWsClient_Stop_Call { + return &MockWsClient_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *MockWsClient_Stop_Call) Run(run func()) *MockWsClient_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWsClient_Stop_Call) Return() *MockWsClient_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsClient_Stop_Call) RunAndReturn(run func()) *MockWsClient_Stop_Call { + _c.Call.Return(run) + return _c +} + +// Write provides a mock function with given fields: data +func (_m *MockWsClient) Write(data []byte) error { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for Write") + } + + var r0 error + if rf, ok := ret.Get(0).(func([]byte) error); ok { + r0 = rf(data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockWsClient_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write' +type MockWsClient_Write_Call struct { + *mock.Call +} + +// Write is a helper method to define mock.On call +// - data []byte +func (_e *MockWsClient_Expecter) Write(data interface{}) *MockWsClient_Write_Call { + return &MockWsClient_Write_Call{Call: _e.mock.On("Write", data)} +} + +func (_c *MockWsClient_Write_Call) Run(run func(data []byte)) *MockWsClient_Write_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]byte)) + }) + return _c +} + +func (_c *MockWsClient_Write_Call) Return(_a0 error) *MockWsClient_Write_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsClient_Write_Call) RunAndReturn(run func([]byte) error) *MockWsClient_Write_Call { + _c.Call.Return(run) + return _c +} + +// NewMockWsClient creates a new instance of MockWsClient. 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 NewMockWsClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockWsClient { + mock := &MockWsClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/ws/mocks/mock_WsServer.go b/ws/mocks/mock_WsServer.go new file mode 100644 index 00000000..3fe68e4b --- /dev/null +++ b/ws/mocks/mock_WsServer.go @@ -0,0 +1,559 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + net "net" + http "net/http" + + mock "github.com/stretchr/testify/mock" + + websocket "github.com/gorilla/websocket" + + ws "github.com/lorenzodonini/ocpp-go/ws" +) + +// MockWsServer is an autogenerated mock type for the WsServer type +type MockWsServer struct { + mock.Mock +} + +type MockWsServer_Expecter struct { + mock *mock.Mock +} + +func (_m *MockWsServer) EXPECT() *MockWsServer_Expecter { + return &MockWsServer_Expecter{mock: &_m.Mock} +} + +// AddSupportedSubprotocol provides a mock function with given fields: subProto +func (_m *MockWsServer) AddSupportedSubprotocol(subProto string) { + _m.Called(subProto) +} + +// MockWsServer_AddSupportedSubprotocol_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddSupportedSubprotocol' +type MockWsServer_AddSupportedSubprotocol_Call struct { + *mock.Call +} + +// AddSupportedSubprotocol is a helper method to define mock.On call +// - subProto string +func (_e *MockWsServer_Expecter) AddSupportedSubprotocol(subProto interface{}) *MockWsServer_AddSupportedSubprotocol_Call { + return &MockWsServer_AddSupportedSubprotocol_Call{Call: _e.mock.On("AddSupportedSubprotocol", subProto)} +} + +func (_c *MockWsServer_AddSupportedSubprotocol_Call) Run(run func(subProto string)) *MockWsServer_AddSupportedSubprotocol_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockWsServer_AddSupportedSubprotocol_Call) Return() *MockWsServer_AddSupportedSubprotocol_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_AddSupportedSubprotocol_Call) RunAndReturn(run func(string)) *MockWsServer_AddSupportedSubprotocol_Call { + _c.Call.Return(run) + return _c +} + +// Addr provides a mock function with given fields: +func (_m *MockWsServer) Addr() *net.TCPAddr { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Addr") + } + + var r0 *net.TCPAddr + if rf, ok := ret.Get(0).(func() *net.TCPAddr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*net.TCPAddr) + } + } + + return r0 +} + +// MockWsServer_Addr_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Addr' +type MockWsServer_Addr_Call struct { + *mock.Call +} + +// Addr is a helper method to define mock.On call +func (_e *MockWsServer_Expecter) Addr() *MockWsServer_Addr_Call { + return &MockWsServer_Addr_Call{Call: _e.mock.On("Addr")} +} + +func (_c *MockWsServer_Addr_Call) Run(run func()) *MockWsServer_Addr_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWsServer_Addr_Call) Return(_a0 *net.TCPAddr) *MockWsServer_Addr_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsServer_Addr_Call) RunAndReturn(run func() *net.TCPAddr) *MockWsServer_Addr_Call { + _c.Call.Return(run) + return _c +} + +// Errors provides a mock function with given fields: +func (_m *MockWsServer) Errors() <-chan error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Errors") + } + + var r0 <-chan error + if rf, ok := ret.Get(0).(func() <-chan error); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(<-chan error) + } + } + + return r0 +} + +// MockWsServer_Errors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Errors' +type MockWsServer_Errors_Call struct { + *mock.Call +} + +// Errors is a helper method to define mock.On call +func (_e *MockWsServer_Expecter) Errors() *MockWsServer_Errors_Call { + return &MockWsServer_Errors_Call{Call: _e.mock.On("Errors")} +} + +func (_c *MockWsServer_Errors_Call) Run(run func()) *MockWsServer_Errors_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWsServer_Errors_Call) Return(_a0 <-chan error) *MockWsServer_Errors_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsServer_Errors_Call) RunAndReturn(run func() <-chan error) *MockWsServer_Errors_Call { + _c.Call.Return(run) + return _c +} + +// SetBasicAuthHandler provides a mock function with given fields: handler +func (_m *MockWsServer) SetBasicAuthHandler(handler func(string, string) bool) { + _m.Called(handler) +} + +// MockWsServer_SetBasicAuthHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetBasicAuthHandler' +type MockWsServer_SetBasicAuthHandler_Call struct { + *mock.Call +} + +// SetBasicAuthHandler is a helper method to define mock.On call +// - handler func(string , string) bool +func (_e *MockWsServer_Expecter) SetBasicAuthHandler(handler interface{}) *MockWsServer_SetBasicAuthHandler_Call { + return &MockWsServer_SetBasicAuthHandler_Call{Call: _e.mock.On("SetBasicAuthHandler", handler)} +} + +func (_c *MockWsServer_SetBasicAuthHandler_Call) Run(run func(handler func(string, string) bool)) *MockWsServer_SetBasicAuthHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(string, string) bool)) + }) + return _c +} + +func (_c *MockWsServer_SetBasicAuthHandler_Call) Return() *MockWsServer_SetBasicAuthHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetBasicAuthHandler_Call) RunAndReturn(run func(func(string, string) bool)) *MockWsServer_SetBasicAuthHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetCheckClientHandler provides a mock function with given fields: handler +func (_m *MockWsServer) SetCheckClientHandler(handler func(string, *http.Request) bool) { + _m.Called(handler) +} + +// MockWsServer_SetCheckClientHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCheckClientHandler' +type MockWsServer_SetCheckClientHandler_Call struct { + *mock.Call +} + +// SetCheckClientHandler is a helper method to define mock.On call +// - handler func(string , *http.Request) bool +func (_e *MockWsServer_Expecter) SetCheckClientHandler(handler interface{}) *MockWsServer_SetCheckClientHandler_Call { + return &MockWsServer_SetCheckClientHandler_Call{Call: _e.mock.On("SetCheckClientHandler", handler)} +} + +func (_c *MockWsServer_SetCheckClientHandler_Call) Run(run func(handler func(string, *http.Request) bool)) *MockWsServer_SetCheckClientHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(string, *http.Request) bool)) + }) + return _c +} + +func (_c *MockWsServer_SetCheckClientHandler_Call) Return() *MockWsServer_SetCheckClientHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetCheckClientHandler_Call) RunAndReturn(run func(func(string, *http.Request) bool)) *MockWsServer_SetCheckClientHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetCheckOriginHandler provides a mock function with given fields: handler +func (_m *MockWsServer) SetCheckOriginHandler(handler func(*http.Request) bool) { + _m.Called(handler) +} + +// MockWsServer_SetCheckOriginHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCheckOriginHandler' +type MockWsServer_SetCheckOriginHandler_Call struct { + *mock.Call +} + +// SetCheckOriginHandler is a helper method to define mock.On call +// - handler func(*http.Request) bool +func (_e *MockWsServer_Expecter) SetCheckOriginHandler(handler interface{}) *MockWsServer_SetCheckOriginHandler_Call { + return &MockWsServer_SetCheckOriginHandler_Call{Call: _e.mock.On("SetCheckOriginHandler", handler)} +} + +func (_c *MockWsServer_SetCheckOriginHandler_Call) Run(run func(handler func(*http.Request) bool)) *MockWsServer_SetCheckOriginHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(*http.Request) bool)) + }) + return _c +} + +func (_c *MockWsServer_SetCheckOriginHandler_Call) Return() *MockWsServer_SetCheckOriginHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetCheckOriginHandler_Call) RunAndReturn(run func(func(*http.Request) bool)) *MockWsServer_SetCheckOriginHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetDisconnectedClientHandler provides a mock function with given fields: handler +func (_m *MockWsServer) SetDisconnectedClientHandler(handler func(ws.Channel)) { + _m.Called(handler) +} + +// MockWsServer_SetDisconnectedClientHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDisconnectedClientHandler' +type MockWsServer_SetDisconnectedClientHandler_Call struct { + *mock.Call +} + +// SetDisconnectedClientHandler is a helper method to define mock.On call +// - handler func(ws.Channel) +func (_e *MockWsServer_Expecter) SetDisconnectedClientHandler(handler interface{}) *MockWsServer_SetDisconnectedClientHandler_Call { + return &MockWsServer_SetDisconnectedClientHandler_Call{Call: _e.mock.On("SetDisconnectedClientHandler", handler)} +} + +func (_c *MockWsServer_SetDisconnectedClientHandler_Call) Run(run func(handler func(ws.Channel))) *MockWsServer_SetDisconnectedClientHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(ws.Channel))) + }) + return _c +} + +func (_c *MockWsServer_SetDisconnectedClientHandler_Call) Return() *MockWsServer_SetDisconnectedClientHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetDisconnectedClientHandler_Call) RunAndReturn(run func(func(ws.Channel))) *MockWsServer_SetDisconnectedClientHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetMessageHandler provides a mock function with given fields: handler +func (_m *MockWsServer) SetMessageHandler(handler func(ws.Channel, []byte) error) { + _m.Called(handler) +} + +// MockWsServer_SetMessageHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMessageHandler' +type MockWsServer_SetMessageHandler_Call struct { + *mock.Call +} + +// SetMessageHandler is a helper method to define mock.On call +// - handler func(ws.Channel , []byte) error +func (_e *MockWsServer_Expecter) SetMessageHandler(handler interface{}) *MockWsServer_SetMessageHandler_Call { + return &MockWsServer_SetMessageHandler_Call{Call: _e.mock.On("SetMessageHandler", handler)} +} + +func (_c *MockWsServer_SetMessageHandler_Call) Run(run func(handler func(ws.Channel, []byte) error)) *MockWsServer_SetMessageHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(ws.Channel, []byte) error)) + }) + return _c +} + +func (_c *MockWsServer_SetMessageHandler_Call) Return() *MockWsServer_SetMessageHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetMessageHandler_Call) RunAndReturn(run func(func(ws.Channel, []byte) error)) *MockWsServer_SetMessageHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetNewClientHandler provides a mock function with given fields: handler +func (_m *MockWsServer) SetNewClientHandler(handler func(ws.Channel)) { + _m.Called(handler) +} + +// MockWsServer_SetNewClientHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetNewClientHandler' +type MockWsServer_SetNewClientHandler_Call struct { + *mock.Call +} + +// SetNewClientHandler is a helper method to define mock.On call +// - handler func(ws.Channel) +func (_e *MockWsServer_Expecter) SetNewClientHandler(handler interface{}) *MockWsServer_SetNewClientHandler_Call { + return &MockWsServer_SetNewClientHandler_Call{Call: _e.mock.On("SetNewClientHandler", handler)} +} + +func (_c *MockWsServer_SetNewClientHandler_Call) Run(run func(handler func(ws.Channel))) *MockWsServer_SetNewClientHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(ws.Channel))) + }) + return _c +} + +func (_c *MockWsServer_SetNewClientHandler_Call) Return() *MockWsServer_SetNewClientHandler_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetNewClientHandler_Call) RunAndReturn(run func(func(ws.Channel))) *MockWsServer_SetNewClientHandler_Call { + _c.Call.Return(run) + return _c +} + +// SetTimeoutConfig provides a mock function with given fields: config +func (_m *MockWsServer) SetTimeoutConfig(config ws.ServerTimeoutConfig) { + _m.Called(config) +} + +// MockWsServer_SetTimeoutConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTimeoutConfig' +type MockWsServer_SetTimeoutConfig_Call struct { + *mock.Call +} + +// SetTimeoutConfig is a helper method to define mock.On call +// - config ws.ServerTimeoutConfig +func (_e *MockWsServer_Expecter) SetTimeoutConfig(config interface{}) *MockWsServer_SetTimeoutConfig_Call { + return &MockWsServer_SetTimeoutConfig_Call{Call: _e.mock.On("SetTimeoutConfig", config)} +} + +func (_c *MockWsServer_SetTimeoutConfig_Call) Run(run func(config ws.ServerTimeoutConfig)) *MockWsServer_SetTimeoutConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(ws.ServerTimeoutConfig)) + }) + return _c +} + +func (_c *MockWsServer_SetTimeoutConfig_Call) Return() *MockWsServer_SetTimeoutConfig_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_SetTimeoutConfig_Call) RunAndReturn(run func(ws.ServerTimeoutConfig)) *MockWsServer_SetTimeoutConfig_Call { + _c.Call.Return(run) + return _c +} + +// Start provides a mock function with given fields: port, listenPath +func (_m *MockWsServer) Start(port int, listenPath string) { + _m.Called(port, listenPath) +} + +// MockWsServer_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type MockWsServer_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +// - port int +// - listenPath string +func (_e *MockWsServer_Expecter) Start(port interface{}, listenPath interface{}) *MockWsServer_Start_Call { + return &MockWsServer_Start_Call{Call: _e.mock.On("Start", port, listenPath)} +} + +func (_c *MockWsServer_Start_Call) Run(run func(port int, listenPath string)) *MockWsServer_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int), args[1].(string)) + }) + return _c +} + +func (_c *MockWsServer_Start_Call) Return() *MockWsServer_Start_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_Start_Call) RunAndReturn(run func(int, string)) *MockWsServer_Start_Call { + _c.Call.Return(run) + return _c +} + +// Stop provides a mock function with given fields: +func (_m *MockWsServer) Stop() { + _m.Called() +} + +// MockWsServer_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type MockWsServer_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *MockWsServer_Expecter) Stop() *MockWsServer_Stop_Call { + return &MockWsServer_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *MockWsServer_Stop_Call) Run(run func()) *MockWsServer_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWsServer_Stop_Call) Return() *MockWsServer_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *MockWsServer_Stop_Call) RunAndReturn(run func()) *MockWsServer_Stop_Call { + _c.Call.Return(run) + return _c +} + +// StopConnection provides a mock function with given fields: id, closeError +func (_m *MockWsServer) StopConnection(id string, closeError websocket.CloseError) error { + ret := _m.Called(id, closeError) + + if len(ret) == 0 { + panic("no return value specified for StopConnection") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, websocket.CloseError) error); ok { + r0 = rf(id, closeError) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockWsServer_StopConnection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopConnection' +type MockWsServer_StopConnection_Call struct { + *mock.Call +} + +// StopConnection is a helper method to define mock.On call +// - id string +// - closeError websocket.CloseError +func (_e *MockWsServer_Expecter) StopConnection(id interface{}, closeError interface{}) *MockWsServer_StopConnection_Call { + return &MockWsServer_StopConnection_Call{Call: _e.mock.On("StopConnection", id, closeError)} +} + +func (_c *MockWsServer_StopConnection_Call) Run(run func(id string, closeError websocket.CloseError)) *MockWsServer_StopConnection_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(websocket.CloseError)) + }) + return _c +} + +func (_c *MockWsServer_StopConnection_Call) Return(_a0 error) *MockWsServer_StopConnection_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsServer_StopConnection_Call) RunAndReturn(run func(string, websocket.CloseError) error) *MockWsServer_StopConnection_Call { + _c.Call.Return(run) + return _c +} + +// Write provides a mock function with given fields: webSocketId, data +func (_m *MockWsServer) Write(webSocketId string, data []byte) error { + ret := _m.Called(webSocketId, data) + + if len(ret) == 0 { + panic("no return value specified for Write") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, []byte) error); ok { + r0 = rf(webSocketId, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockWsServer_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write' +type MockWsServer_Write_Call struct { + *mock.Call +} + +// Write is a helper method to define mock.On call +// - webSocketId string +// - data []byte +func (_e *MockWsServer_Expecter) Write(webSocketId interface{}, data interface{}) *MockWsServer_Write_Call { + return &MockWsServer_Write_Call{Call: _e.mock.On("Write", webSocketId, data)} +} + +func (_c *MockWsServer_Write_Call) Run(run func(webSocketId string, data []byte)) *MockWsServer_Write_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].([]byte)) + }) + return _c +} + +func (_c *MockWsServer_Write_Call) Return(_a0 error) *MockWsServer_Write_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWsServer_Write_Call) RunAndReturn(run func(string, []byte) error) *MockWsServer_Write_Call { + _c.Call.Return(run) + return _c +} + +// NewMockWsServer creates a new instance of MockWsServer. 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 NewMockWsServer(t interface { + mock.TestingT + Cleanup(func()) +}) *MockWsServer { + mock := &MockWsServer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}