github.com/true-sqn/fabric@v2.1.1+incompatible/core/chaincode/mock/connectionhandler.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mock
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric/core/chaincode/extcc"
     8  	"github.com/hyperledger/fabric/core/container/ccintf"
     9  )
    10  
    11  type ConnectionHandler struct {
    12  	StreamStub        func(string, *ccintf.ChaincodeServerInfo, extcc.StreamHandler) error
    13  	streamMutex       sync.RWMutex
    14  	streamArgsForCall []struct {
    15  		arg1 string
    16  		arg2 *ccintf.ChaincodeServerInfo
    17  		arg3 extcc.StreamHandler
    18  	}
    19  	streamReturns struct {
    20  		result1 error
    21  	}
    22  	streamReturnsOnCall map[int]struct {
    23  		result1 error
    24  	}
    25  	invocations      map[string][][]interface{}
    26  	invocationsMutex sync.RWMutex
    27  }
    28  
    29  func (fake *ConnectionHandler) Stream(arg1 string, arg2 *ccintf.ChaincodeServerInfo, arg3 extcc.StreamHandler) error {
    30  	fake.streamMutex.Lock()
    31  	ret, specificReturn := fake.streamReturnsOnCall[len(fake.streamArgsForCall)]
    32  	fake.streamArgsForCall = append(fake.streamArgsForCall, struct {
    33  		arg1 string
    34  		arg2 *ccintf.ChaincodeServerInfo
    35  		arg3 extcc.StreamHandler
    36  	}{arg1, arg2, arg3})
    37  	fake.recordInvocation("Stream", []interface{}{arg1, arg2, arg3})
    38  	fake.streamMutex.Unlock()
    39  	if fake.StreamStub != nil {
    40  		return fake.StreamStub(arg1, arg2, arg3)
    41  	}
    42  	if specificReturn {
    43  		return ret.result1
    44  	}
    45  	fakeReturns := fake.streamReturns
    46  	return fakeReturns.result1
    47  }
    48  
    49  func (fake *ConnectionHandler) StreamCallCount() int {
    50  	fake.streamMutex.RLock()
    51  	defer fake.streamMutex.RUnlock()
    52  	return len(fake.streamArgsForCall)
    53  }
    54  
    55  func (fake *ConnectionHandler) StreamCalls(stub func(string, *ccintf.ChaincodeServerInfo, extcc.StreamHandler) error) {
    56  	fake.streamMutex.Lock()
    57  	defer fake.streamMutex.Unlock()
    58  	fake.StreamStub = stub
    59  }
    60  
    61  func (fake *ConnectionHandler) StreamArgsForCall(i int) (string, *ccintf.ChaincodeServerInfo, extcc.StreamHandler) {
    62  	fake.streamMutex.RLock()
    63  	defer fake.streamMutex.RUnlock()
    64  	argsForCall := fake.streamArgsForCall[i]
    65  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
    66  }
    67  
    68  func (fake *ConnectionHandler) StreamReturns(result1 error) {
    69  	fake.streamMutex.Lock()
    70  	defer fake.streamMutex.Unlock()
    71  	fake.StreamStub = nil
    72  	fake.streamReturns = struct {
    73  		result1 error
    74  	}{result1}
    75  }
    76  
    77  func (fake *ConnectionHandler) StreamReturnsOnCall(i int, result1 error) {
    78  	fake.streamMutex.Lock()
    79  	defer fake.streamMutex.Unlock()
    80  	fake.StreamStub = nil
    81  	if fake.streamReturnsOnCall == nil {
    82  		fake.streamReturnsOnCall = make(map[int]struct {
    83  			result1 error
    84  		})
    85  	}
    86  	fake.streamReturnsOnCall[i] = struct {
    87  		result1 error
    88  	}{result1}
    89  }
    90  
    91  func (fake *ConnectionHandler) Invocations() map[string][][]interface{} {
    92  	fake.invocationsMutex.RLock()
    93  	defer fake.invocationsMutex.RUnlock()
    94  	fake.streamMutex.RLock()
    95  	defer fake.streamMutex.RUnlock()
    96  	copiedInvocations := map[string][][]interface{}{}
    97  	for key, value := range fake.invocations {
    98  		copiedInvocations[key] = value
    99  	}
   100  	return copiedInvocations
   101  }
   102  
   103  func (fake *ConnectionHandler) recordInvocation(key string, args []interface{}) {
   104  	fake.invocationsMutex.Lock()
   105  	defer fake.invocationsMutex.Unlock()
   106  	if fake.invocations == nil {
   107  		fake.invocations = map[string][][]interface{}{}
   108  	}
   109  	if fake.invocations[key] == nil {
   110  		fake.invocations[key] = [][]interface{}{}
   111  	}
   112  	fake.invocations[key] = append(fake.invocations[key], args)
   113  }