github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/common/deliver/mock/policy_checker.go (about)

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