github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/broadcast/mock/metrics_counter.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hyperledger/fabric/common/metrics" 8 ) 9 10 type MetricsCounter struct { 11 AddStub func(float64) 12 addMutex sync.RWMutex 13 addArgsForCall []struct { 14 arg1 float64 15 } 16 WithStub func(...string) metrics.Counter 17 withMutex sync.RWMutex 18 withArgsForCall []struct { 19 arg1 []string 20 } 21 withReturns struct { 22 result1 metrics.Counter 23 } 24 withReturnsOnCall map[int]struct { 25 result1 metrics.Counter 26 } 27 invocations map[string][][]interface{} 28 invocationsMutex sync.RWMutex 29 } 30 31 func (fake *MetricsCounter) Add(arg1 float64) { 32 fake.addMutex.Lock() 33 fake.addArgsForCall = append(fake.addArgsForCall, struct { 34 arg1 float64 35 }{arg1}) 36 fake.recordInvocation("Add", []interface{}{arg1}) 37 fake.addMutex.Unlock() 38 if fake.AddStub != nil { 39 fake.AddStub(arg1) 40 } 41 } 42 43 func (fake *MetricsCounter) AddCallCount() int { 44 fake.addMutex.RLock() 45 defer fake.addMutex.RUnlock() 46 return len(fake.addArgsForCall) 47 } 48 49 func (fake *MetricsCounter) AddCalls(stub func(float64)) { 50 fake.addMutex.Lock() 51 defer fake.addMutex.Unlock() 52 fake.AddStub = stub 53 } 54 55 func (fake *MetricsCounter) AddArgsForCall(i int) float64 { 56 fake.addMutex.RLock() 57 defer fake.addMutex.RUnlock() 58 argsForCall := fake.addArgsForCall[i] 59 return argsForCall.arg1 60 } 61 62 func (fake *MetricsCounter) With(arg1 ...string) metrics.Counter { 63 fake.withMutex.Lock() 64 ret, specificReturn := fake.withReturnsOnCall[len(fake.withArgsForCall)] 65 fake.withArgsForCall = append(fake.withArgsForCall, struct { 66 arg1 []string 67 }{arg1}) 68 fake.recordInvocation("With", []interface{}{arg1}) 69 fake.withMutex.Unlock() 70 if fake.WithStub != nil { 71 return fake.WithStub(arg1...) 72 } 73 if specificReturn { 74 return ret.result1 75 } 76 fakeReturns := fake.withReturns 77 return fakeReturns.result1 78 } 79 80 func (fake *MetricsCounter) WithCallCount() int { 81 fake.withMutex.RLock() 82 defer fake.withMutex.RUnlock() 83 return len(fake.withArgsForCall) 84 } 85 86 func (fake *MetricsCounter) WithCalls(stub func(...string) metrics.Counter) { 87 fake.withMutex.Lock() 88 defer fake.withMutex.Unlock() 89 fake.WithStub = stub 90 } 91 92 func (fake *MetricsCounter) WithArgsForCall(i int) []string { 93 fake.withMutex.RLock() 94 defer fake.withMutex.RUnlock() 95 argsForCall := fake.withArgsForCall[i] 96 return argsForCall.arg1 97 } 98 99 func (fake *MetricsCounter) WithReturns(result1 metrics.Counter) { 100 fake.withMutex.Lock() 101 defer fake.withMutex.Unlock() 102 fake.WithStub = nil 103 fake.withReturns = struct { 104 result1 metrics.Counter 105 }{result1} 106 } 107 108 func (fake *MetricsCounter) WithReturnsOnCall(i int, result1 metrics.Counter) { 109 fake.withMutex.Lock() 110 defer fake.withMutex.Unlock() 111 fake.WithStub = nil 112 if fake.withReturnsOnCall == nil { 113 fake.withReturnsOnCall = make(map[int]struct { 114 result1 metrics.Counter 115 }) 116 } 117 fake.withReturnsOnCall[i] = struct { 118 result1 metrics.Counter 119 }{result1} 120 } 121 122 func (fake *MetricsCounter) Invocations() map[string][][]interface{} { 123 fake.invocationsMutex.RLock() 124 defer fake.invocationsMutex.RUnlock() 125 fake.addMutex.RLock() 126 defer fake.addMutex.RUnlock() 127 fake.withMutex.RLock() 128 defer fake.withMutex.RUnlock() 129 copiedInvocations := map[string][][]interface{}{} 130 for key, value := range fake.invocations { 131 copiedInvocations[key] = value 132 } 133 return copiedInvocations 134 } 135 136 func (fake *MetricsCounter) recordInvocation(key string, args []interface{}) { 137 fake.invocationsMutex.Lock() 138 defer fake.invocationsMutex.Unlock() 139 if fake.invocations == nil { 140 fake.invocations = map[string][][]interface{}{} 141 } 142 if fake.invocations[key] == nil { 143 fake.invocations[key] = [][]interface{}{} 144 } 145 fake.invocations[key] = append(fake.invocations[key], args) 146 }