github.com/xiaqingdoc/fabric@v2.1.1+incompatible/core/chaincode/extcc/mock/ccstreamhandler.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 StreamHandler struct { 12 HandleChaincodeStreamStub func(ccintf.ChaincodeStream) error 13 handleChaincodeStreamMutex sync.RWMutex 14 handleChaincodeStreamArgsForCall []struct { 15 arg1 ccintf.ChaincodeStream 16 } 17 handleChaincodeStreamReturns struct { 18 result1 error 19 } 20 handleChaincodeStreamReturnsOnCall map[int]struct { 21 result1 error 22 } 23 invocations map[string][][]interface{} 24 invocationsMutex sync.RWMutex 25 } 26 27 func (fake *StreamHandler) HandleChaincodeStream(arg1 ccintf.ChaincodeStream) error { 28 fake.handleChaincodeStreamMutex.Lock() 29 ret, specificReturn := fake.handleChaincodeStreamReturnsOnCall[len(fake.handleChaincodeStreamArgsForCall)] 30 fake.handleChaincodeStreamArgsForCall = append(fake.handleChaincodeStreamArgsForCall, struct { 31 arg1 ccintf.ChaincodeStream 32 }{arg1}) 33 fake.recordInvocation("HandleChaincodeStream", []interface{}{arg1}) 34 fake.handleChaincodeStreamMutex.Unlock() 35 if fake.HandleChaincodeStreamStub != nil { 36 return fake.HandleChaincodeStreamStub(arg1) 37 } 38 if specificReturn { 39 return ret.result1 40 } 41 fakeReturns := fake.handleChaincodeStreamReturns 42 return fakeReturns.result1 43 } 44 45 func (fake *StreamHandler) HandleChaincodeStreamCallCount() int { 46 fake.handleChaincodeStreamMutex.RLock() 47 defer fake.handleChaincodeStreamMutex.RUnlock() 48 return len(fake.handleChaincodeStreamArgsForCall) 49 } 50 51 func (fake *StreamHandler) HandleChaincodeStreamCalls(stub func(ccintf.ChaincodeStream) error) { 52 fake.handleChaincodeStreamMutex.Lock() 53 defer fake.handleChaincodeStreamMutex.Unlock() 54 fake.HandleChaincodeStreamStub = stub 55 } 56 57 func (fake *StreamHandler) HandleChaincodeStreamArgsForCall(i int) ccintf.ChaincodeStream { 58 fake.handleChaincodeStreamMutex.RLock() 59 defer fake.handleChaincodeStreamMutex.RUnlock() 60 argsForCall := fake.handleChaincodeStreamArgsForCall[i] 61 return argsForCall.arg1 62 } 63 64 func (fake *StreamHandler) HandleChaincodeStreamReturns(result1 error) { 65 fake.handleChaincodeStreamMutex.Lock() 66 defer fake.handleChaincodeStreamMutex.Unlock() 67 fake.HandleChaincodeStreamStub = nil 68 fake.handleChaincodeStreamReturns = struct { 69 result1 error 70 }{result1} 71 } 72 73 func (fake *StreamHandler) HandleChaincodeStreamReturnsOnCall(i int, result1 error) { 74 fake.handleChaincodeStreamMutex.Lock() 75 defer fake.handleChaincodeStreamMutex.Unlock() 76 fake.HandleChaincodeStreamStub = nil 77 if fake.handleChaincodeStreamReturnsOnCall == nil { 78 fake.handleChaincodeStreamReturnsOnCall = make(map[int]struct { 79 result1 error 80 }) 81 } 82 fake.handleChaincodeStreamReturnsOnCall[i] = struct { 83 result1 error 84 }{result1} 85 } 86 87 func (fake *StreamHandler) Invocations() map[string][][]interface{} { 88 fake.invocationsMutex.RLock() 89 defer fake.invocationsMutex.RUnlock() 90 fake.handleChaincodeStreamMutex.RLock() 91 defer fake.handleChaincodeStreamMutex.RUnlock() 92 copiedInvocations := map[string][][]interface{}{} 93 for key, value := range fake.invocations { 94 copiedInvocations[key] = value 95 } 96 return copiedInvocations 97 } 98 99 func (fake *StreamHandler) recordInvocation(key string, args []interface{}) { 100 fake.invocationsMutex.Lock() 101 defer fake.invocationsMutex.Unlock() 102 if fake.invocations == nil { 103 fake.invocations = map[string][][]interface{}{} 104 } 105 if fake.invocations[key] == nil { 106 fake.invocations[key] = [][]interface{}{} 107 } 108 fake.invocations[key] = append(fake.invocations[key], args) 109 } 110 111 var _ extcc.StreamHandler = new(StreamHandler)