github.com/yous1230/fabric@v2.0.0-beta.0.20191224111736-74345bee6ac2+incompatible/core/handlers/validation/builtin/v20/mocks/state_fetcher.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mocks
     3  
     4  import (
     5  	"sync"
     6  
     7  	validation "github.com/hyperledger/fabric/core/handlers/validation/api/state"
     8  )
     9  
    10  type StateFetcher struct {
    11  	FetchStateStub        func() (validation.State, error)
    12  	fetchStateMutex       sync.RWMutex
    13  	fetchStateArgsForCall []struct {
    14  	}
    15  	fetchStateReturns struct {
    16  		result1 validation.State
    17  		result2 error
    18  	}
    19  	fetchStateReturnsOnCall map[int]struct {
    20  		result1 validation.State
    21  		result2 error
    22  	}
    23  	invocations      map[string][][]interface{}
    24  	invocationsMutex sync.RWMutex
    25  }
    26  
    27  func (fake *StateFetcher) FetchState() (validation.State, error) {
    28  	fake.fetchStateMutex.Lock()
    29  	ret, specificReturn := fake.fetchStateReturnsOnCall[len(fake.fetchStateArgsForCall)]
    30  	fake.fetchStateArgsForCall = append(fake.fetchStateArgsForCall, struct {
    31  	}{})
    32  	fake.recordInvocation("FetchState", []interface{}{})
    33  	fake.fetchStateMutex.Unlock()
    34  	if fake.FetchStateStub != nil {
    35  		return fake.FetchStateStub()
    36  	}
    37  	if specificReturn {
    38  		return ret.result1, ret.result2
    39  	}
    40  	fakeReturns := fake.fetchStateReturns
    41  	return fakeReturns.result1, fakeReturns.result2
    42  }
    43  
    44  func (fake *StateFetcher) FetchStateCallCount() int {
    45  	fake.fetchStateMutex.RLock()
    46  	defer fake.fetchStateMutex.RUnlock()
    47  	return len(fake.fetchStateArgsForCall)
    48  }
    49  
    50  func (fake *StateFetcher) FetchStateCalls(stub func() (validation.State, error)) {
    51  	fake.fetchStateMutex.Lock()
    52  	defer fake.fetchStateMutex.Unlock()
    53  	fake.FetchStateStub = stub
    54  }
    55  
    56  func (fake *StateFetcher) FetchStateReturns(result1 validation.State, result2 error) {
    57  	fake.fetchStateMutex.Lock()
    58  	defer fake.fetchStateMutex.Unlock()
    59  	fake.FetchStateStub = nil
    60  	fake.fetchStateReturns = struct {
    61  		result1 validation.State
    62  		result2 error
    63  	}{result1, result2}
    64  }
    65  
    66  func (fake *StateFetcher) FetchStateReturnsOnCall(i int, result1 validation.State, result2 error) {
    67  	fake.fetchStateMutex.Lock()
    68  	defer fake.fetchStateMutex.Unlock()
    69  	fake.FetchStateStub = nil
    70  	if fake.fetchStateReturnsOnCall == nil {
    71  		fake.fetchStateReturnsOnCall = make(map[int]struct {
    72  			result1 validation.State
    73  			result2 error
    74  		})
    75  	}
    76  	fake.fetchStateReturnsOnCall[i] = struct {
    77  		result1 validation.State
    78  		result2 error
    79  	}{result1, result2}
    80  }
    81  
    82  func (fake *StateFetcher) Invocations() map[string][][]interface{} {
    83  	fake.invocationsMutex.RLock()
    84  	defer fake.invocationsMutex.RUnlock()
    85  	fake.fetchStateMutex.RLock()
    86  	defer fake.fetchStateMutex.RUnlock()
    87  	copiedInvocations := map[string][][]interface{}{}
    88  	for key, value := range fake.invocations {
    89  		copiedInvocations[key] = value
    90  	}
    91  	return copiedInvocations
    92  }
    93  
    94  func (fake *StateFetcher) recordInvocation(key string, args []interface{}) {
    95  	fake.invocationsMutex.Lock()
    96  	defer fake.invocationsMutex.Unlock()
    97  	if fake.invocations == nil {
    98  		fake.invocations = map[string][][]interface{}{}
    99  	}
   100  	if fake.invocations[key] == nil {
   101  		fake.invocations[key] = [][]interface{}{}
   102  	}
   103  	fake.invocations[key] = append(fake.invocations[key], args)
   104  }