You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/05/08 18:09:44 UTC
[plc4x] 01/02: test(plc4go/spi): replace temp mock with mockery mock
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 0490b152b98ac4107bd96cadc8016f20b34116c0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon May 8 19:36:55 2023 +0200
test(plc4go/spi): replace temp mock with mockery mock
---
plc4go/spi/model/mock_PlcBrowseItem_test.go | 350 ++++++++++++++++++++++++++++
plc4go/spi/model/mock_PlcQuery_test.go | 93 ++++++++
plc4go/spi/model/mock_PlcTag_test.go | 182 +++++++++++++++
plc4go/spi/model/mock_requirements.go | 20 +-
plc4go/spi/model/render_test.go | 126 +---------
5 files changed, 649 insertions(+), 122 deletions(-)
diff --git a/plc4go/spi/model/mock_PlcBrowseItem_test.go b/plc4go/spi/model/mock_PlcBrowseItem_test.go
new file mode 100644
index 0000000000..31c0655384
--- /dev/null
+++ b/plc4go/spi/model/mock_PlcBrowseItem_test.go
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Code generated by mockery v2.26.1. DO NOT EDIT.
+
+package model
+
+import (
+ apimodel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ mock "github.com/stretchr/testify/mock"
+
+ values "github.com/apache/plc4x/plc4go/pkg/api/values"
+)
+
+// MockPlcBrowseItem is an autogenerated mock type for the PlcBrowseItem type
+type MockPlcBrowseItem struct {
+ mock.Mock
+}
+
+type MockPlcBrowseItem_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockPlcBrowseItem) EXPECT() *MockPlcBrowseItem_Expecter {
+ return &MockPlcBrowseItem_Expecter{mock: &_m.Mock}
+}
+
+// GetChildren provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) GetChildren() map[string]apimodel.PlcBrowseItem {
+ ret := _m.Called()
+
+ var r0 map[string]apimodel.PlcBrowseItem
+ if rf, ok := ret.Get(0).(func() map[string]apimodel.PlcBrowseItem); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(map[string]apimodel.PlcBrowseItem)
+ }
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_GetChildren_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetChildren'
+type MockPlcBrowseItem_GetChildren_Call struct {
+ *mock.Call
+}
+
+// GetChildren is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) GetChildren() *MockPlcBrowseItem_GetChildren_Call {
+ return &MockPlcBrowseItem_GetChildren_Call{Call: _e.mock.On("GetChildren")}
+}
+
+func (_c *MockPlcBrowseItem_GetChildren_Call) Run(run func()) *MockPlcBrowseItem_GetChildren_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetChildren_Call) Return(_a0 map[string]apimodel.PlcBrowseItem) *MockPlcBrowseItem_GetChildren_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetChildren_Call) RunAndReturn(run func() map[string]apimodel.PlcBrowseItem) *MockPlcBrowseItem_GetChildren_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// GetName provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) GetName() string {
+ ret := _m.Called()
+
+ var r0 string
+ if rf, ok := ret.Get(0).(func() string); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(string)
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_GetName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetName'
+type MockPlcBrowseItem_GetName_Call struct {
+ *mock.Call
+}
+
+// GetName is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) GetName() *MockPlcBrowseItem_GetName_Call {
+ return &MockPlcBrowseItem_GetName_Call{Call: _e.mock.On("GetName")}
+}
+
+func (_c *MockPlcBrowseItem_GetName_Call) Run(run func()) *MockPlcBrowseItem_GetName_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetName_Call) Return(_a0 string) *MockPlcBrowseItem_GetName_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetName_Call) RunAndReturn(run func() string) *MockPlcBrowseItem_GetName_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// GetOptions provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) GetOptions() map[string]values.PlcValue {
+ ret := _m.Called()
+
+ var r0 map[string]values.PlcValue
+ if rf, ok := ret.Get(0).(func() map[string]values.PlcValue); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(map[string]values.PlcValue)
+ }
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_GetOptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOptions'
+type MockPlcBrowseItem_GetOptions_Call struct {
+ *mock.Call
+}
+
+// GetOptions is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) GetOptions() *MockPlcBrowseItem_GetOptions_Call {
+ return &MockPlcBrowseItem_GetOptions_Call{Call: _e.mock.On("GetOptions")}
+}
+
+func (_c *MockPlcBrowseItem_GetOptions_Call) Run(run func()) *MockPlcBrowseItem_GetOptions_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetOptions_Call) Return(_a0 map[string]values.PlcValue) *MockPlcBrowseItem_GetOptions_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetOptions_Call) RunAndReturn(run func() map[string]values.PlcValue) *MockPlcBrowseItem_GetOptions_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// GetTag provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) GetTag() apimodel.PlcTag {
+ ret := _m.Called()
+
+ var r0 apimodel.PlcTag
+ if rf, ok := ret.Get(0).(func() apimodel.PlcTag); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(apimodel.PlcTag)
+ }
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_GetTag_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTag'
+type MockPlcBrowseItem_GetTag_Call struct {
+ *mock.Call
+}
+
+// GetTag is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) GetTag() *MockPlcBrowseItem_GetTag_Call {
+ return &MockPlcBrowseItem_GetTag_Call{Call: _e.mock.On("GetTag")}
+}
+
+func (_c *MockPlcBrowseItem_GetTag_Call) Run(run func()) *MockPlcBrowseItem_GetTag_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetTag_Call) Return(_a0 apimodel.PlcTag) *MockPlcBrowseItem_GetTag_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_GetTag_Call) RunAndReturn(run func() apimodel.PlcTag) *MockPlcBrowseItem_GetTag_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// IsReadable provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) IsReadable() bool {
+ ret := _m.Called()
+
+ var r0 bool
+ if rf, ok := ret.Get(0).(func() bool); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(bool)
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_IsReadable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsReadable'
+type MockPlcBrowseItem_IsReadable_Call struct {
+ *mock.Call
+}
+
+// IsReadable is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) IsReadable() *MockPlcBrowseItem_IsReadable_Call {
+ return &MockPlcBrowseItem_IsReadable_Call{Call: _e.mock.On("IsReadable")}
+}
+
+func (_c *MockPlcBrowseItem_IsReadable_Call) Run(run func()) *MockPlcBrowseItem_IsReadable_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_IsReadable_Call) Return(_a0 bool) *MockPlcBrowseItem_IsReadable_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_IsReadable_Call) RunAndReturn(run func() bool) *MockPlcBrowseItem_IsReadable_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// IsSubscribable provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) IsSubscribable() bool {
+ ret := _m.Called()
+
+ var r0 bool
+ if rf, ok := ret.Get(0).(func() bool); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(bool)
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_IsSubscribable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsSubscribable'
+type MockPlcBrowseItem_IsSubscribable_Call struct {
+ *mock.Call
+}
+
+// IsSubscribable is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) IsSubscribable() *MockPlcBrowseItem_IsSubscribable_Call {
+ return &MockPlcBrowseItem_IsSubscribable_Call{Call: _e.mock.On("IsSubscribable")}
+}
+
+func (_c *MockPlcBrowseItem_IsSubscribable_Call) Run(run func()) *MockPlcBrowseItem_IsSubscribable_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_IsSubscribable_Call) Return(_a0 bool) *MockPlcBrowseItem_IsSubscribable_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_IsSubscribable_Call) RunAndReturn(run func() bool) *MockPlcBrowseItem_IsSubscribable_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// IsWritable provides a mock function with given fields:
+func (_m *MockPlcBrowseItem) IsWritable() bool {
+ ret := _m.Called()
+
+ var r0 bool
+ if rf, ok := ret.Get(0).(func() bool); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(bool)
+ }
+
+ return r0
+}
+
+// MockPlcBrowseItem_IsWritable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsWritable'
+type MockPlcBrowseItem_IsWritable_Call struct {
+ *mock.Call
+}
+
+// IsWritable is a helper method to define mock.On call
+func (_e *MockPlcBrowseItem_Expecter) IsWritable() *MockPlcBrowseItem_IsWritable_Call {
+ return &MockPlcBrowseItem_IsWritable_Call{Call: _e.mock.On("IsWritable")}
+}
+
+func (_c *MockPlcBrowseItem_IsWritable_Call) Run(run func()) *MockPlcBrowseItem_IsWritable_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_IsWritable_Call) Return(_a0 bool) *MockPlcBrowseItem_IsWritable_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcBrowseItem_IsWritable_Call) RunAndReturn(run func() bool) *MockPlcBrowseItem_IsWritable_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+type mockConstructorTestingTNewMockPlcBrowseItem interface {
+ mock.TestingT
+ Cleanup(func())
+}
+
+// NewMockPlcBrowseItem creates a new instance of MockPlcBrowseItem. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+func NewMockPlcBrowseItem(t mockConstructorTestingTNewMockPlcBrowseItem) *MockPlcBrowseItem {
+ mock := &MockPlcBrowseItem{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
diff --git a/plc4go/spi/model/mock_PlcQuery_test.go b/plc4go/spi/model/mock_PlcQuery_test.go
new file mode 100644
index 0000000000..de6ee8f425
--- /dev/null
+++ b/plc4go/spi/model/mock_PlcQuery_test.go
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Code generated by mockery v2.26.1. DO NOT EDIT.
+
+package model
+
+import mock "github.com/stretchr/testify/mock"
+
+// MockPlcQuery is an autogenerated mock type for the PlcQuery type
+type MockPlcQuery struct {
+ mock.Mock
+}
+
+type MockPlcQuery_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockPlcQuery) EXPECT() *MockPlcQuery_Expecter {
+ return &MockPlcQuery_Expecter{mock: &_m.Mock}
+}
+
+// GetQueryString provides a mock function with given fields:
+func (_m *MockPlcQuery) GetQueryString() string {
+ ret := _m.Called()
+
+ var r0 string
+ if rf, ok := ret.Get(0).(func() string); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(string)
+ }
+
+ return r0
+}
+
+// MockPlcQuery_GetQueryString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetQueryString'
+type MockPlcQuery_GetQueryString_Call struct {
+ *mock.Call
+}
+
+// GetQueryString is a helper method to define mock.On call
+func (_e *MockPlcQuery_Expecter) GetQueryString() *MockPlcQuery_GetQueryString_Call {
+ return &MockPlcQuery_GetQueryString_Call{Call: _e.mock.On("GetQueryString")}
+}
+
+func (_c *MockPlcQuery_GetQueryString_Call) Run(run func()) *MockPlcQuery_GetQueryString_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcQuery_GetQueryString_Call) Return(_a0 string) *MockPlcQuery_GetQueryString_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcQuery_GetQueryString_Call) RunAndReturn(run func() string) *MockPlcQuery_GetQueryString_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+type mockConstructorTestingTNewMockPlcQuery interface {
+ mock.TestingT
+ Cleanup(func())
+}
+
+// NewMockPlcQuery creates a new instance of MockPlcQuery. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+func NewMockPlcQuery(t mockConstructorTestingTNewMockPlcQuery) *MockPlcQuery {
+ mock := &MockPlcQuery{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
diff --git a/plc4go/spi/model/mock_PlcTag_test.go b/plc4go/spi/model/mock_PlcTag_test.go
new file mode 100644
index 0000000000..6e651af006
--- /dev/null
+++ b/plc4go/spi/model/mock_PlcTag_test.go
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Code generated by mockery v2.26.1. DO NOT EDIT.
+
+package model
+
+import (
+ apimodel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ mock "github.com/stretchr/testify/mock"
+
+ values "github.com/apache/plc4x/plc4go/pkg/api/values"
+)
+
+// MockPlcTag is an autogenerated mock type for the PlcTag type
+type MockPlcTag struct {
+ mock.Mock
+}
+
+type MockPlcTag_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockPlcTag) EXPECT() *MockPlcTag_Expecter {
+ return &MockPlcTag_Expecter{mock: &_m.Mock}
+}
+
+// GetAddressString provides a mock function with given fields:
+func (_m *MockPlcTag) GetAddressString() string {
+ ret := _m.Called()
+
+ var r0 string
+ if rf, ok := ret.Get(0).(func() string); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(string)
+ }
+
+ return r0
+}
+
+// MockPlcTag_GetAddressString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAddressString'
+type MockPlcTag_GetAddressString_Call struct {
+ *mock.Call
+}
+
+// GetAddressString is a helper method to define mock.On call
+func (_e *MockPlcTag_Expecter) GetAddressString() *MockPlcTag_GetAddressString_Call {
+ return &MockPlcTag_GetAddressString_Call{Call: _e.mock.On("GetAddressString")}
+}
+
+func (_c *MockPlcTag_GetAddressString_Call) Run(run func()) *MockPlcTag_GetAddressString_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcTag_GetAddressString_Call) Return(_a0 string) *MockPlcTag_GetAddressString_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcTag_GetAddressString_Call) RunAndReturn(run func() string) *MockPlcTag_GetAddressString_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// GetArrayInfo provides a mock function with given fields:
+func (_m *MockPlcTag) GetArrayInfo() []apimodel.ArrayInfo {
+ ret := _m.Called()
+
+ var r0 []apimodel.ArrayInfo
+ if rf, ok := ret.Get(0).(func() []apimodel.ArrayInfo); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]apimodel.ArrayInfo)
+ }
+ }
+
+ return r0
+}
+
+// MockPlcTag_GetArrayInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetArrayInfo'
+type MockPlcTag_GetArrayInfo_Call struct {
+ *mock.Call
+}
+
+// GetArrayInfo is a helper method to define mock.On call
+func (_e *MockPlcTag_Expecter) GetArrayInfo() *MockPlcTag_GetArrayInfo_Call {
+ return &MockPlcTag_GetArrayInfo_Call{Call: _e.mock.On("GetArrayInfo")}
+}
+
+func (_c *MockPlcTag_GetArrayInfo_Call) Run(run func()) *MockPlcTag_GetArrayInfo_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcTag_GetArrayInfo_Call) Return(_a0 []apimodel.ArrayInfo) *MockPlcTag_GetArrayInfo_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []apimodel.ArrayInfo) *MockPlcTag_GetArrayInfo_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// GetValueType provides a mock function with given fields:
+func (_m *MockPlcTag) GetValueType() values.PlcValueType {
+ ret := _m.Called()
+
+ var r0 values.PlcValueType
+ if rf, ok := ret.Get(0).(func() values.PlcValueType); ok {
+ r0 = rf()
+ } else {
+ r0 = ret.Get(0).(values.PlcValueType)
+ }
+
+ return r0
+}
+
+// MockPlcTag_GetValueType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetValueType'
+type MockPlcTag_GetValueType_Call struct {
+ *mock.Call
+}
+
+// GetValueType is a helper method to define mock.On call
+func (_e *MockPlcTag_Expecter) GetValueType() *MockPlcTag_GetValueType_Call {
+ return &MockPlcTag_GetValueType_Call{Call: _e.mock.On("GetValueType")}
+}
+
+func (_c *MockPlcTag_GetValueType_Call) Run(run func()) *MockPlcTag_GetValueType_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockPlcTag_GetValueType_Call) Return(_a0 values.PlcValueType) *MockPlcTag_GetValueType_Call {
+ _c.Call.Return(_a0)
+ return _c
+}
+
+func (_c *MockPlcTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueType) *MockPlcTag_GetValueType_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+type mockConstructorTestingTNewMockPlcTag interface {
+ mock.TestingT
+ Cleanup(func())
+}
+
+// NewMockPlcTag creates a new instance of MockPlcTag. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+func NewMockPlcTag(t mockConstructorTestingTNewMockPlcTag) *MockPlcTag {
+ mock := &MockPlcTag{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
diff --git a/plc4go/spi/model/mock_requirements.go b/plc4go/spi/model/mock_requirements.go
index 154989fa3b..0adb840f1e 100644
--- a/plc4go/spi/model/mock_requirements.go
+++ b/plc4go/spi/model/mock_requirements.go
@@ -19,7 +19,10 @@
package model
-import "github.com/apache/plc4x/plc4go/spi"
+import (
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+ "github.com/apache/plc4x/plc4go/spi"
+)
// Note this file is a Helper for mockery to generate use mocks from other package
@@ -27,3 +30,18 @@ import "github.com/apache/plc4x/plc4go/spi"
type PlcTagHandler interface {
spi.PlcTagHandler
}
+
+// Deprecated: don't use it in productive code
+type PlcTag interface {
+ apiModel.PlcTag
+}
+
+// Deprecated: don't use it in productive code
+type PlcBrowseItem interface {
+ apiModel.PlcBrowseItem
+}
+
+// Deprecated: don't use it in productive code
+type PlcQuery interface {
+ apiModel.PlcQuery
+}
diff --git a/plc4go/spi/model/render_test.go b/plc4go/spi/model/render_test.go
index 33831453cb..7710bd0cb8 100644
--- a/plc4go/spi/model/render_test.go
+++ b/plc4go/spi/model/render_test.go
@@ -20,7 +20,6 @@
package model
import (
- "context"
"fmt"
"net/url"
"reflect"
@@ -98,121 +97,6 @@ func TestRenderTest(t *testing.T) {
}
}
-type _TestRenderTestCustomPlcTag struct {
-}
-
-func (_ _TestRenderTestCustomPlcTag) GetAddressString() string {
- return "address string"
-}
-
-func (_ _TestRenderTestCustomPlcTag) GetValueType() apiValues.PlcValueType {
- return 1
-}
-
-func (_ _TestRenderTestCustomPlcTag) GetArrayInfo() []apiModel.ArrayInfo {
- return nil
-}
-
-func (_ _TestRenderTestCustomPlcTag) Serialize() ([]byte, error) {
- return nil, nil // TODO: maybe we return something here... or not
-}
-
-func (_ _TestRenderTestCustomPlcTag) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
- return nil // TODO: maybe we return something here... or not
-}
-
-type _TestRenderTestCustomPlcBrowseItem struct {
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) GetTag() apiModel.PlcTag {
- return _TestRenderTestCustomPlcTag{}
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) GetName() string {
- return "tagid"
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) IsReadable() bool {
- return true
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) IsWritable() bool {
- return true
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) IsSubscribable() bool {
- return true
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) GetChildren() map[string]apiModel.PlcBrowseItem {
- return nil // TODO: maybe we return something here... or not
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) GetOptions() map[string]apiValues.PlcValue {
- return nil // TODO: maybe we return something here... or not
-}
-
-type _TestRenderTestCustomPlcBrowseItem2 struct {
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) GetTag() apiModel.PlcTag {
- return _TestRenderTestCustomPlcTag{}
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) GetName() string {
- return "tagid"
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) IsReadable() bool {
- return true
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) IsWritable() bool {
- return true
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) IsSubscribable() bool {
- return true
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) GetChildren() map[string]apiModel.PlcBrowseItem {
- return nil // TODO: maybe we return something here... or not
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem2) GetOptions() map[string]apiValues.PlcValue {
- return nil // TODO: maybe we return something here... or not
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) Serialize() ([]byte, error) {
- return nil, nil // TODO: maybe we return something here... or not
-}
-
-func (_ _TestRenderTestCustomPlcBrowseItem) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
- return nil // TODO: maybe we return something here... or not
-}
-
-type _TestRenderTestCustom_TestPlcQuery struct {
-}
-
-func (_ _TestRenderTestCustom_TestPlcQuery) GetQueryString() string {
- return "123456"
-}
-
-type _TestRenderTestCustom_TestPlcQuery2 struct {
-}
-
-func (_ _TestRenderTestCustom_TestPlcQuery2) GetQueryString() string {
- return "123456"
-}
-
-func (_ _TestRenderTestCustom_TestPlcQuery2) Serialize() ([]byte, error) {
- return nil, nil // TODO: maybe we return something here... or not
-}
-
-func (_ _TestRenderTestCustom_TestPlcQuery2) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
- return nil // TODO: maybe we return something here... or not
-}
-
// TestRenderTestCustom test some custom objects
func TestRenderTestCustom(t *testing.T) {
tests := []struct {
@@ -225,15 +109,15 @@ func TestRenderTestCustom(t *testing.T) {
}{
{
sut: NewDefaultPlcBrowseItem(
- _TestRenderTestCustomPlcTag{},
+ NewMockPlcTag(t),
"some name",
"some datatype",
true,
true,
true,
map[string]apiModel.PlcBrowseItem{
- "tagid1": _TestRenderTestCustomPlcBrowseItem{},
- "tagid2": _TestRenderTestCustomPlcBrowseItem2{},
+ "tagid1": NewMockPlcBrowseItem(t),
+ "tagid2": NewMockPlcBrowseItem(t),
},
map[string]apiValues.PlcValue{
"tagid1": spiValue.PlcNull{},
@@ -248,8 +132,8 @@ func TestRenderTestCustom(t *testing.T) {
{
sut: NewDefaultPlcBrowseRequest(
map[string]apiModel.PlcQuery{
- "tagid1": _TestRenderTestCustom_TestPlcQuery{},
- "tagid2": _TestRenderTestCustom_TestPlcQuery2{},
+ "tagid1": NewMockPlcQuery(t),
+ "tagid2": NewMockPlcQuery(t),
},
[]string{
"tagid1",