github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/cluster/mocks/policy_manager.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mocks
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric/common/policies"
     8  )
     9  
    10  type PolicyManager struct {
    11  	GetPolicyStub        func(string) (policies.Policy, bool)
    12  	getPolicyMutex       sync.RWMutex
    13  	getPolicyArgsForCall []struct {
    14  		arg1 string
    15  	}
    16  	getPolicyReturns struct {
    17  		result1 policies.Policy
    18  		result2 bool
    19  	}
    20  	getPolicyReturnsOnCall map[int]struct {
    21  		result1 policies.Policy
    22  		result2 bool
    23  	}
    24  	ManagerStub        func([]string) (policies.Manager, bool)
    25  	managerMutex       sync.RWMutex
    26  	managerArgsForCall []struct {
    27  		arg1 []string
    28  	}
    29  	managerReturns struct {
    30  		result1 policies.Manager
    31  		result2 bool
    32  	}
    33  	managerReturnsOnCall map[int]struct {
    34  		result1 policies.Manager
    35  		result2 bool
    36  	}
    37  	invocations      map[string][][]interface{}
    38  	invocationsMutex sync.RWMutex
    39  }
    40  
    41  func (fake *PolicyManager) GetPolicy(arg1 string) (policies.Policy, bool) {
    42  	fake.getPolicyMutex.Lock()
    43  	ret, specificReturn := fake.getPolicyReturnsOnCall[len(fake.getPolicyArgsForCall)]
    44  	fake.getPolicyArgsForCall = append(fake.getPolicyArgsForCall, struct {
    45  		arg1 string
    46  	}{arg1})
    47  	fake.recordInvocation("GetPolicy", []interface{}{arg1})
    48  	fake.getPolicyMutex.Unlock()
    49  	if fake.GetPolicyStub != nil {
    50  		return fake.GetPolicyStub(arg1)
    51  	}
    52  	if specificReturn {
    53  		return ret.result1, ret.result2
    54  	}
    55  	fakeReturns := fake.getPolicyReturns
    56  	return fakeReturns.result1, fakeReturns.result2
    57  }
    58  
    59  func (fake *PolicyManager) GetPolicyCallCount() int {
    60  	fake.getPolicyMutex.RLock()
    61  	defer fake.getPolicyMutex.RUnlock()
    62  	return len(fake.getPolicyArgsForCall)
    63  }
    64  
    65  func (fake *PolicyManager) GetPolicyCalls(stub func(string) (policies.Policy, bool)) {
    66  	fake.getPolicyMutex.Lock()
    67  	defer fake.getPolicyMutex.Unlock()
    68  	fake.GetPolicyStub = stub
    69  }
    70  
    71  func (fake *PolicyManager) GetPolicyArgsForCall(i int) string {
    72  	fake.getPolicyMutex.RLock()
    73  	defer fake.getPolicyMutex.RUnlock()
    74  	argsForCall := fake.getPolicyArgsForCall[i]
    75  	return argsForCall.arg1
    76  }
    77  
    78  func (fake *PolicyManager) GetPolicyReturns(result1 policies.Policy, result2 bool) {
    79  	fake.getPolicyMutex.Lock()
    80  	defer fake.getPolicyMutex.Unlock()
    81  	fake.GetPolicyStub = nil
    82  	fake.getPolicyReturns = struct {
    83  		result1 policies.Policy
    84  		result2 bool
    85  	}{result1, result2}
    86  }
    87  
    88  func (fake *PolicyManager) GetPolicyReturnsOnCall(i int, result1 policies.Policy, result2 bool) {
    89  	fake.getPolicyMutex.Lock()
    90  	defer fake.getPolicyMutex.Unlock()
    91  	fake.GetPolicyStub = nil
    92  	if fake.getPolicyReturnsOnCall == nil {
    93  		fake.getPolicyReturnsOnCall = make(map[int]struct {
    94  			result1 policies.Policy
    95  			result2 bool
    96  		})
    97  	}
    98  	fake.getPolicyReturnsOnCall[i] = struct {
    99  		result1 policies.Policy
   100  		result2 bool
   101  	}{result1, result2}
   102  }
   103  
   104  func (fake *PolicyManager) Manager(arg1 []string) (policies.Manager, bool) {
   105  	var arg1Copy []string
   106  	if arg1 != nil {
   107  		arg1Copy = make([]string, len(arg1))
   108  		copy(arg1Copy, arg1)
   109  	}
   110  	fake.managerMutex.Lock()
   111  	ret, specificReturn := fake.managerReturnsOnCall[len(fake.managerArgsForCall)]
   112  	fake.managerArgsForCall = append(fake.managerArgsForCall, struct {
   113  		arg1 []string
   114  	}{arg1Copy})
   115  	fake.recordInvocation("Manager", []interface{}{arg1Copy})
   116  	fake.managerMutex.Unlock()
   117  	if fake.ManagerStub != nil {
   118  		return fake.ManagerStub(arg1)
   119  	}
   120  	if specificReturn {
   121  		return ret.result1, ret.result2
   122  	}
   123  	fakeReturns := fake.managerReturns
   124  	return fakeReturns.result1, fakeReturns.result2
   125  }
   126  
   127  func (fake *PolicyManager) ManagerCallCount() int {
   128  	fake.managerMutex.RLock()
   129  	defer fake.managerMutex.RUnlock()
   130  	return len(fake.managerArgsForCall)
   131  }
   132  
   133  func (fake *PolicyManager) ManagerCalls(stub func([]string) (policies.Manager, bool)) {
   134  	fake.managerMutex.Lock()
   135  	defer fake.managerMutex.Unlock()
   136  	fake.ManagerStub = stub
   137  }
   138  
   139  func (fake *PolicyManager) ManagerArgsForCall(i int) []string {
   140  	fake.managerMutex.RLock()
   141  	defer fake.managerMutex.RUnlock()
   142  	argsForCall := fake.managerArgsForCall[i]
   143  	return argsForCall.arg1
   144  }
   145  
   146  func (fake *PolicyManager) ManagerReturns(result1 policies.Manager, result2 bool) {
   147  	fake.managerMutex.Lock()
   148  	defer fake.managerMutex.Unlock()
   149  	fake.ManagerStub = nil
   150  	fake.managerReturns = struct {
   151  		result1 policies.Manager
   152  		result2 bool
   153  	}{result1, result2}
   154  }
   155  
   156  func (fake *PolicyManager) ManagerReturnsOnCall(i int, result1 policies.Manager, result2 bool) {
   157  	fake.managerMutex.Lock()
   158  	defer fake.managerMutex.Unlock()
   159  	fake.ManagerStub = nil
   160  	if fake.managerReturnsOnCall == nil {
   161  		fake.managerReturnsOnCall = make(map[int]struct {
   162  			result1 policies.Manager
   163  			result2 bool
   164  		})
   165  	}
   166  	fake.managerReturnsOnCall[i] = struct {
   167  		result1 policies.Manager
   168  		result2 bool
   169  	}{result1, result2}
   170  }
   171  
   172  func (fake *PolicyManager) Invocations() map[string][][]interface{} {
   173  	fake.invocationsMutex.RLock()
   174  	defer fake.invocationsMutex.RUnlock()
   175  	fake.getPolicyMutex.RLock()
   176  	defer fake.getPolicyMutex.RUnlock()
   177  	fake.managerMutex.RLock()
   178  	defer fake.managerMutex.RUnlock()
   179  	copiedInvocations := map[string][][]interface{}{}
   180  	for key, value := range fake.invocations {
   181  		copiedInvocations[key] = value
   182  	}
   183  	return copiedInvocations
   184  }
   185  
   186  func (fake *PolicyManager) recordInvocation(key string, args []interface{}) {
   187  	fake.invocationsMutex.Lock()
   188  	defer fake.invocationsMutex.Unlock()
   189  	if fake.invocations == nil {
   190  		fake.invocations = map[string][][]interface{}{}
   191  	}
   192  	if fake.invocations[key] == nil {
   193  		fake.invocations[key] = [][]interface{}{}
   194  	}
   195  	fake.invocations[key] = append(fake.invocations[key], args)
   196  }