github.com/hyperledger-labs/bdls@v2.1.1+incompatible/core/chaincode/fake/context_registry.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package fake
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric/core/chaincode"
     8  	"github.com/hyperledger/fabric/core/common/ccprovider"
     9  )
    10  
    11  type ContextRegistry struct {
    12  	CloseStub        func()
    13  	closeMutex       sync.RWMutex
    14  	closeArgsForCall []struct {
    15  	}
    16  	CreateStub        func(*ccprovider.TransactionParams) (*chaincode.TransactionContext, error)
    17  	createMutex       sync.RWMutex
    18  	createArgsForCall []struct {
    19  		arg1 *ccprovider.TransactionParams
    20  	}
    21  	createReturns struct {
    22  		result1 *chaincode.TransactionContext
    23  		result2 error
    24  	}
    25  	createReturnsOnCall map[int]struct {
    26  		result1 *chaincode.TransactionContext
    27  		result2 error
    28  	}
    29  	DeleteStub        func(string, string)
    30  	deleteMutex       sync.RWMutex
    31  	deleteArgsForCall []struct {
    32  		arg1 string
    33  		arg2 string
    34  	}
    35  	GetStub        func(string, string) *chaincode.TransactionContext
    36  	getMutex       sync.RWMutex
    37  	getArgsForCall []struct {
    38  		arg1 string
    39  		arg2 string
    40  	}
    41  	getReturns struct {
    42  		result1 *chaincode.TransactionContext
    43  	}
    44  	getReturnsOnCall map[int]struct {
    45  		result1 *chaincode.TransactionContext
    46  	}
    47  	invocations      map[string][][]interface{}
    48  	invocationsMutex sync.RWMutex
    49  }
    50  
    51  func (fake *ContextRegistry) Close() {
    52  	fake.closeMutex.Lock()
    53  	fake.closeArgsForCall = append(fake.closeArgsForCall, struct {
    54  	}{})
    55  	fake.recordInvocation("Close", []interface{}{})
    56  	fake.closeMutex.Unlock()
    57  	if fake.CloseStub != nil {
    58  		fake.CloseStub()
    59  	}
    60  }
    61  
    62  func (fake *ContextRegistry) CloseCallCount() int {
    63  	fake.closeMutex.RLock()
    64  	defer fake.closeMutex.RUnlock()
    65  	return len(fake.closeArgsForCall)
    66  }
    67  
    68  func (fake *ContextRegistry) CloseCalls(stub func()) {
    69  	fake.closeMutex.Lock()
    70  	defer fake.closeMutex.Unlock()
    71  	fake.CloseStub = stub
    72  }
    73  
    74  func (fake *ContextRegistry) Create(arg1 *ccprovider.TransactionParams) (*chaincode.TransactionContext, error) {
    75  	fake.createMutex.Lock()
    76  	ret, specificReturn := fake.createReturnsOnCall[len(fake.createArgsForCall)]
    77  	fake.createArgsForCall = append(fake.createArgsForCall, struct {
    78  		arg1 *ccprovider.TransactionParams
    79  	}{arg1})
    80  	fake.recordInvocation("Create", []interface{}{arg1})
    81  	fake.createMutex.Unlock()
    82  	if fake.CreateStub != nil {
    83  		return fake.CreateStub(arg1)
    84  	}
    85  	if specificReturn {
    86  		return ret.result1, ret.result2
    87  	}
    88  	fakeReturns := fake.createReturns
    89  	return fakeReturns.result1, fakeReturns.result2
    90  }
    91  
    92  func (fake *ContextRegistry) CreateCallCount() int {
    93  	fake.createMutex.RLock()
    94  	defer fake.createMutex.RUnlock()
    95  	return len(fake.createArgsForCall)
    96  }
    97  
    98  func (fake *ContextRegistry) CreateCalls(stub func(*ccprovider.TransactionParams) (*chaincode.TransactionContext, error)) {
    99  	fake.createMutex.Lock()
   100  	defer fake.createMutex.Unlock()
   101  	fake.CreateStub = stub
   102  }
   103  
   104  func (fake *ContextRegistry) CreateArgsForCall(i int) *ccprovider.TransactionParams {
   105  	fake.createMutex.RLock()
   106  	defer fake.createMutex.RUnlock()
   107  	argsForCall := fake.createArgsForCall[i]
   108  	return argsForCall.arg1
   109  }
   110  
   111  func (fake *ContextRegistry) CreateReturns(result1 *chaincode.TransactionContext, result2 error) {
   112  	fake.createMutex.Lock()
   113  	defer fake.createMutex.Unlock()
   114  	fake.CreateStub = nil
   115  	fake.createReturns = struct {
   116  		result1 *chaincode.TransactionContext
   117  		result2 error
   118  	}{result1, result2}
   119  }
   120  
   121  func (fake *ContextRegistry) CreateReturnsOnCall(i int, result1 *chaincode.TransactionContext, result2 error) {
   122  	fake.createMutex.Lock()
   123  	defer fake.createMutex.Unlock()
   124  	fake.CreateStub = nil
   125  	if fake.createReturnsOnCall == nil {
   126  		fake.createReturnsOnCall = make(map[int]struct {
   127  			result1 *chaincode.TransactionContext
   128  			result2 error
   129  		})
   130  	}
   131  	fake.createReturnsOnCall[i] = struct {
   132  		result1 *chaincode.TransactionContext
   133  		result2 error
   134  	}{result1, result2}
   135  }
   136  
   137  func (fake *ContextRegistry) Delete(arg1 string, arg2 string) {
   138  	fake.deleteMutex.Lock()
   139  	fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct {
   140  		arg1 string
   141  		arg2 string
   142  	}{arg1, arg2})
   143  	fake.recordInvocation("Delete", []interface{}{arg1, arg2})
   144  	fake.deleteMutex.Unlock()
   145  	if fake.DeleteStub != nil {
   146  		fake.DeleteStub(arg1, arg2)
   147  	}
   148  }
   149  
   150  func (fake *ContextRegistry) DeleteCallCount() int {
   151  	fake.deleteMutex.RLock()
   152  	defer fake.deleteMutex.RUnlock()
   153  	return len(fake.deleteArgsForCall)
   154  }
   155  
   156  func (fake *ContextRegistry) DeleteCalls(stub func(string, string)) {
   157  	fake.deleteMutex.Lock()
   158  	defer fake.deleteMutex.Unlock()
   159  	fake.DeleteStub = stub
   160  }
   161  
   162  func (fake *ContextRegistry) DeleteArgsForCall(i int) (string, string) {
   163  	fake.deleteMutex.RLock()
   164  	defer fake.deleteMutex.RUnlock()
   165  	argsForCall := fake.deleteArgsForCall[i]
   166  	return argsForCall.arg1, argsForCall.arg2
   167  }
   168  
   169  func (fake *ContextRegistry) Get(arg1 string, arg2 string) *chaincode.TransactionContext {
   170  	fake.getMutex.Lock()
   171  	ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)]
   172  	fake.getArgsForCall = append(fake.getArgsForCall, struct {
   173  		arg1 string
   174  		arg2 string
   175  	}{arg1, arg2})
   176  	fake.recordInvocation("Get", []interface{}{arg1, arg2})
   177  	fake.getMutex.Unlock()
   178  	if fake.GetStub != nil {
   179  		return fake.GetStub(arg1, arg2)
   180  	}
   181  	if specificReturn {
   182  		return ret.result1
   183  	}
   184  	fakeReturns := fake.getReturns
   185  	return fakeReturns.result1
   186  }
   187  
   188  func (fake *ContextRegistry) GetCallCount() int {
   189  	fake.getMutex.RLock()
   190  	defer fake.getMutex.RUnlock()
   191  	return len(fake.getArgsForCall)
   192  }
   193  
   194  func (fake *ContextRegistry) GetCalls(stub func(string, string) *chaincode.TransactionContext) {
   195  	fake.getMutex.Lock()
   196  	defer fake.getMutex.Unlock()
   197  	fake.GetStub = stub
   198  }
   199  
   200  func (fake *ContextRegistry) GetArgsForCall(i int) (string, string) {
   201  	fake.getMutex.RLock()
   202  	defer fake.getMutex.RUnlock()
   203  	argsForCall := fake.getArgsForCall[i]
   204  	return argsForCall.arg1, argsForCall.arg2
   205  }
   206  
   207  func (fake *ContextRegistry) GetReturns(result1 *chaincode.TransactionContext) {
   208  	fake.getMutex.Lock()
   209  	defer fake.getMutex.Unlock()
   210  	fake.GetStub = nil
   211  	fake.getReturns = struct {
   212  		result1 *chaincode.TransactionContext
   213  	}{result1}
   214  }
   215  
   216  func (fake *ContextRegistry) GetReturnsOnCall(i int, result1 *chaincode.TransactionContext) {
   217  	fake.getMutex.Lock()
   218  	defer fake.getMutex.Unlock()
   219  	fake.GetStub = nil
   220  	if fake.getReturnsOnCall == nil {
   221  		fake.getReturnsOnCall = make(map[int]struct {
   222  			result1 *chaincode.TransactionContext
   223  		})
   224  	}
   225  	fake.getReturnsOnCall[i] = struct {
   226  		result1 *chaincode.TransactionContext
   227  	}{result1}
   228  }
   229  
   230  func (fake *ContextRegistry) Invocations() map[string][][]interface{} {
   231  	fake.invocationsMutex.RLock()
   232  	defer fake.invocationsMutex.RUnlock()
   233  	fake.closeMutex.RLock()
   234  	defer fake.closeMutex.RUnlock()
   235  	fake.createMutex.RLock()
   236  	defer fake.createMutex.RUnlock()
   237  	fake.deleteMutex.RLock()
   238  	defer fake.deleteMutex.RUnlock()
   239  	fake.getMutex.RLock()
   240  	defer fake.getMutex.RUnlock()
   241  	copiedInvocations := map[string][][]interface{}{}
   242  	for key, value := range fake.invocations {
   243  		copiedInvocations[key] = value
   244  	}
   245  	return copiedInvocations
   246  }
   247  
   248  func (fake *ContextRegistry) recordInvocation(key string, args []interface{}) {
   249  	fake.invocationsMutex.Lock()
   250  	defer fake.invocationsMutex.Unlock()
   251  	if fake.invocations == nil {
   252  		fake.invocations = map[string][][]interface{}{}
   253  	}
   254  	if fake.invocations[key] == nil {
   255  		fake.invocations[key] = [][]interface{}{}
   256  	}
   257  	fake.invocations[key] = append(fake.invocations[key], args)
   258  }