github.com/xmidt-org/webpa-common@v1.11.9/device/mocks.go (about)

     1  package device
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/stretchr/testify/mock"
     7  	"github.com/xmidt-org/webpa-common/convey"
     8  )
     9  
    10  type MockConnector struct {
    11  	mock.Mock
    12  }
    13  
    14  var _ Connector = (*MockConnector)(nil)
    15  
    16  func (m *MockConnector) Connect(response http.ResponseWriter, request *http.Request, header http.Header) (Interface, error) {
    17  	arguments := m.Called(response, request, header)
    18  	first, _ := arguments.Get(0).(Interface)
    19  	return first, arguments.Error(1)
    20  }
    21  
    22  func (m *MockConnector) Disconnect(id ID, reason CloseReason) bool {
    23  	return m.Called(id, reason).Bool(0)
    24  }
    25  
    26  func (m *MockConnector) DisconnectIf(predicate func(ID) (CloseReason, bool)) int {
    27  	return m.Called(predicate).Int(0)
    28  }
    29  
    30  func (m *MockConnector) DisconnectAll(reason CloseReason) int {
    31  	return m.Called(reason).Int(0)
    32  }
    33  
    34  func (m *MockConnector) GetFilter() Filter {
    35  	return m.Called().Get(0).(Filter)
    36  }
    37  
    38  type MockRegistry struct {
    39  	mock.Mock
    40  }
    41  
    42  var _ Registry = (*MockRegistry)(nil)
    43  
    44  func (m *MockRegistry) Len() int {
    45  	return m.Called().Int(0)
    46  }
    47  
    48  func (m *MockRegistry) Get(id ID) (Interface, bool) {
    49  	arguments := m.Called(id)
    50  	first, _ := arguments.Get(0).(Interface)
    51  	return first, arguments.Bool(1)
    52  }
    53  
    54  func (m *MockRegistry) VisitAll(f func(Interface) bool) int {
    55  	return m.Called(f).Int(0)
    56  }
    57  
    58  type MockDevice struct {
    59  	mock.Mock
    60  }
    61  
    62  func (m *MockDevice) String() string {
    63  	return m.Called().String(0)
    64  }
    65  
    66  func (m *MockDevice) MarshalJSON() ([]byte, error) {
    67  	arguments := m.Called()
    68  	return arguments.Get(0).([]byte), arguments.Error(1)
    69  }
    70  
    71  func (m *MockDevice) ID() ID {
    72  	return m.Called().Get(0).(ID)
    73  }
    74  
    75  func (m *MockDevice) Pending() int {
    76  	return m.Called().Int(0)
    77  }
    78  
    79  func (m *MockDevice) Close() error {
    80  	return m.Called().Error(0)
    81  }
    82  
    83  func (m *MockDevice) Closed() bool {
    84  	arguments := m.Called()
    85  	return arguments.Bool(0)
    86  }
    87  
    88  func (m *MockDevice) Statistics() Statistics {
    89  	arguments := m.Called()
    90  	first, _ := arguments.Get(0).(Statistics)
    91  	return first
    92  }
    93  
    94  func (m *MockDevice) Convey() convey.Interface {
    95  	arguments := m.Called()
    96  	first, _ := arguments.Get(0).(convey.Interface)
    97  	return first
    98  }
    99  
   100  func (m *MockDevice) ConveyCompliance() convey.Compliance {
   101  	arguments := m.Called()
   102  	first, _ := arguments.Get(0).(convey.Compliance)
   103  	return first
   104  }
   105  
   106  func (m *MockDevice) Metadata() *Metadata {
   107  	arguments := m.Called()
   108  	first, _ := arguments.Get(0).(*Metadata)
   109  	return first
   110  }
   111  
   112  func (m *MockDevice) CloseReason() CloseReason {
   113  	arguments := m.Called()
   114  	first, _ := arguments.Get(0).(CloseReason)
   115  	return first
   116  }
   117  
   118  func (m *MockDevice) Send(request *Request) (*Response, error) {
   119  	arguments := m.Called(request)
   120  	first, _ := arguments.Get(0).(*Response)
   121  	return first, arguments.Error(1)
   122  }